This is an automated email from the ASF dual-hosted git repository. btellier pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/james-project.git
commit dddf0bd38b6f6b9c7ce280245c5e2137d2d1a479 Author: quanth <hqt...@linagora.com> AuthorDate: Mon Oct 26 14:46:49 2020 +0700 JAMES-3416 Add Domain commands --- server/protocols/webadmin-cli/README.md | 41 ++++---- .../java/org/apache/james/cli/WebAdminCli.java | 35 +++++-- .../DomainCommand.java} | 44 ++++---- .../DomainListCommand.java} | 42 ++++---- .../DomainClient.java} | 33 ++---- ...rsionCommandTest.java => DomainManageTest.java} | 47 +++++---- .../apache/james/cli/HelpVersionCommandTest.java | 11 +- .../webadmin-cli/src/test/resources/dnsservice.xml | 25 +++++ .../webadmin-cli/src/test/resources/domainlist.xml | 24 +++++ .../webadmin-cli/src/test/resources/imapserver.xml | 54 ++++++++++ .../webadmin-cli/src/test/resources/jwt_publickey | 9 ++ .../webadmin-cli/src/test/resources/keystore | Bin 0 -> 2245 bytes .../webadmin-cli/src/test/resources/listeners.xml | 46 +++++++++ .../webadmin-cli/src/test/resources/lmtpserver.xml | 41 ++++++++ .../src/test/resources/mailetcontainer.xml | 114 +++++++++++++++++++++ .../src/test/resources/mailrepositorystore.xml | 30 ++++++ .../src/test/resources/managesieveserver.xml | 65 ++++++++++++ .../webadmin-cli/src/test/resources/pop3server.xml | 42 ++++++++ .../webadmin-cli/src/test/resources/smtpserver.xml | 105 +++++++++++++++++++ src/adr/0042-james-cli-based-on-webadmin.md | 6 +- 20 files changed, 685 insertions(+), 129 deletions(-) diff --git a/server/protocols/webadmin-cli/README.md b/server/protocols/webadmin-cli/README.md index ab8185b..ad6b5ee 100644 --- a/server/protocols/webadmin-cli/README.md +++ b/server/protocols/webadmin-cli/README.md @@ -11,7 +11,7 @@ Webadmin command-line interface is an upcoming replacement for the outdated, sec General syntax to run the command line ``` -$ java -jar james-cli.jar [OPTION] ENTITY ACTION {ARGUMENT} +$ ./james-cli [OPTION] ENTITY ACTION {ARGUMENT} ``` where @@ -26,11 +26,11 @@ where Example: ``` -$ java -jar james-cli.jar --url http://127.0.0.1 --port 9999 domain list +$ ./james-cli --url http://127.0.0.1:9999 domain list ``` The above command lists all domain names available on domain route at address http://127.0.0.1:9999. -It does not require any argument to execute. Options --url and --port are optional. Without them, the default value is http://127.0.0.0:8000. +It does not require any argument to execute. Options --url are optional. Without it, the default value is http://127.0.0.1:8000. As for other commands, arguments might be required after the sub-command (ACTION such as list, add and remove). Note: the command line before ENTITY will be documented as {cli}. @@ -43,11 +43,11 @@ Note: the command line before ENTITY will be documented as {cli}. - [Check if a domain exists](#check-if-a-domain-exists) - [Get the list of domains](#get-the-list-of-domains) - [Manage Users](#manage-users) - - [Create an user](#create-a-user) - - [Test an user existence](#test-a-user-existence) - - [Delete an user](#delete-a-user) + - [Create a user](#create-a-user) + - [Test a user existence](#test-a-user-existence) + - [Delete a user](#delete-a-user) - [Get users list](#get-users-list) - - [Update an user password](#update-a-user-password) + - [Update a user password](#update-a-user-password) ## Manage Domains @@ -58,10 +58,10 @@ Add a domain to the domain list. ``` Resource name **domainToBeCreated**: -- can not be null or empty -- can not contain ‘@’ -- can not be more than 255 characters -- can not contain ‘/’ +- cannot be null or empty +- cannot contain ‘@’ +- cannot be more than 255 characters +- cannot contain ‘/’ ### Delete a domain @@ -87,9 +87,9 @@ Show all domains' name on the list. ## Manage Users -### Create an user +### Create a user -Add an user to the user list. +Add a user to the user list. ``` {cli} user create <username> <password> ``` @@ -97,17 +97,17 @@ Resource name <username> representing valid users, hence it should match the cri Note: if the user exists already, its password will be updated. -### Test an user existence +### Test a user existence -Check whether an user exists on the user list or not. +Check whether a user exists on the user list or not. ``` {cli} user exist <username> ``` Resource name <username> representing valid users, hence it should match the criteria at [User Repositories documentation](https://james.apache.org/server/config-users.html) -### Delete an user +### Delete a user -Remove an user from the user list. +Remove a user from the user list. ``` {cli} user delete <username> ``` @@ -120,8 +120,7 @@ Show all users' name on the list. {cli} user list ``` -### Update an user password -Same as Create, but an user need to exist. - -If the user do not exist, then it will be created. +### Update a user password +Same as Create, but a user need to exist. +If the user do not exist, then it will be created. \ No newline at end of file diff --git a/server/protocols/webadmin-cli/src/main/java/org/apache/james/cli/WebAdminCli.java b/server/protocols/webadmin-cli/src/main/java/org/apache/james/cli/WebAdminCli.java index 895d617..0160461 100644 --- a/server/protocols/webadmin-cli/src/main/java/org/apache/james/cli/WebAdminCli.java +++ b/server/protocols/webadmin-cli/src/main/java/org/apache/james/cli/WebAdminCli.java @@ -19,34 +19,49 @@ package org.apache.james.cli; +import java.io.PrintStream; import java.util.concurrent.Callable; +import org.apache.james.cli.domain.DomainCommand; + import picocli.CommandLine; @CommandLine.Command( - name = "james-cli", - description = "James Webadmin CLI") + name = "james-cli", + description = "James Webadmin CLI") public class WebAdminCli implements Callable<Integer> { + public static final int CLI_FINISHED_SUCCEED = 0; + public static final int CLI_FINISHED_FAILED = 1; + + public @CommandLine.Option( + names = "--url", + description = "James server URL", + defaultValue = "http://127.0.0.1:8000") + String jamesUrl; + @Override public Integer call() { - return 0; + return CLI_FINISHED_SUCCEED; } public static void main(String[] args) { - int exitCode = execute(args); + PrintStream out = System.out; + PrintStream err = System.err; + int exitCode = execute(out, err, args); System.exit(exitCode); } - public static int execute(String[] args) { + public static int execute(PrintStream out, PrintStream err, String[] args) { WebAdminCli parent = new WebAdminCli(); return new CommandLine(parent) - .addSubcommand(new CommandLine.HelpCommand()) - .execute(args); + .addSubcommand(new CommandLine.HelpCommand()) + .addSubcommand(new DomainCommand(out, parent, err)) + .execute(args); } - public static int executeFluent(String... args) { - return execute(args); + public static int executeFluent(PrintStream out, PrintStream err, String... args) { + return execute(out, err, args); } -} +} \ No newline at end of file diff --git a/server/protocols/webadmin-cli/src/main/java/org/apache/james/cli/WebAdminCli.java b/server/protocols/webadmin-cli/src/main/java/org/apache/james/cli/domain/DomainCommand.java similarity index 68% copy from server/protocols/webadmin-cli/src/main/java/org/apache/james/cli/WebAdminCli.java copy to server/protocols/webadmin-cli/src/main/java/org/apache/james/cli/domain/DomainCommand.java index 895d617..affff59 100644 --- a/server/protocols/webadmin-cli/src/main/java/org/apache/james/cli/WebAdminCli.java +++ b/server/protocols/webadmin-cli/src/main/java/org/apache/james/cli/domain/DomainCommand.java @@ -17,36 +17,36 @@ * under the License. * ******************************************************************/ -package org.apache.james.cli; +package org.apache.james.cli.domain; +import java.io.PrintStream; import java.util.concurrent.Callable; +import org.apache.james.cli.WebAdminCli; + import picocli.CommandLine; @CommandLine.Command( - name = "james-cli", - description = "James Webadmin CLI") -public class WebAdminCli implements Callable<Integer> { + name = "domain", + description = "Manage Domains", + subcommands = { + DomainListCommand.class + }) +public class DomainCommand implements Callable<Integer> { + + protected final WebAdminCli webAdminCli; + protected final PrintStream out; + protected final PrintStream err; + + public DomainCommand(PrintStream out, WebAdminCli webAdminCli, PrintStream err) { + this.out = out; + this.webAdminCli = webAdminCli; + this.err = err; + } @Override public Integer call() { - return 0; - } - - public static void main(String[] args) { - int exitCode = execute(args); - System.exit(exitCode); - } - - public static int execute(String[] args) { - WebAdminCli parent = new WebAdminCli(); - return new CommandLine(parent) - .addSubcommand(new CommandLine.HelpCommand()) - .execute(args); - } - - public static int executeFluent(String... args) { - return execute(args); + return WebAdminCli.CLI_FINISHED_SUCCEED; } -} +} \ No newline at end of file diff --git a/server/protocols/webadmin-cli/src/main/java/org/apache/james/cli/WebAdminCli.java b/server/protocols/webadmin-cli/src/main/java/org/apache/james/cli/domain/DomainListCommand.java similarity index 60% copy from server/protocols/webadmin-cli/src/main/java/org/apache/james/cli/WebAdminCli.java copy to server/protocols/webadmin-cli/src/main/java/org/apache/james/cli/domain/DomainListCommand.java index 895d617..ef4ab43 100644 --- a/server/protocols/webadmin-cli/src/main/java/org/apache/james/cli/WebAdminCli.java +++ b/server/protocols/webadmin-cli/src/main/java/org/apache/james/cli/domain/DomainListCommand.java @@ -17,36 +17,36 @@ * under the License. * ******************************************************************/ -package org.apache.james.cli; +package org.apache.james.cli.domain; import java.util.concurrent.Callable; +import org.apache.james.cli.WebAdminCli; +import org.apache.james.httpclient.DomainClient; + +import feign.Feign; +import feign.jackson.JacksonDecoder; import picocli.CommandLine; @CommandLine.Command( - name = "james-cli", - description = "James Webadmin CLI") -public class WebAdminCli implements Callable<Integer> { + name = "list", + description = "Show all domains on the domains list") +public class DomainListCommand implements Callable<Integer> { + + @CommandLine.ParentCommand DomainCommand domainCommand; @Override public Integer call() { - return 0; - } - - public static void main(String[] args) { - int exitCode = execute(args); - System.exit(exitCode); - } - - public static int execute(String[] args) { - WebAdminCli parent = new WebAdminCli(); - return new CommandLine(parent) - .addSubcommand(new CommandLine.HelpCommand()) - .execute(args); - } - - public static int executeFluent(String... args) { - return execute(args); + try { + DomainClient domainClient = Feign.builder() + .decoder(new JacksonDecoder()) + .target(DomainClient.class, domainCommand.webAdminCli.jamesUrl + "/domains"); + domainClient.getDomainList().forEach(domainCommand.out::println); + return WebAdminCli.CLI_FINISHED_SUCCEED; + } catch (Exception e) { + e.printStackTrace(domainCommand.err); + return WebAdminCli.CLI_FINISHED_FAILED; + } } } diff --git a/server/protocols/webadmin-cli/src/main/java/org/apache/james/cli/WebAdminCli.java b/server/protocols/webadmin-cli/src/main/java/org/apache/james/httpclient/DomainClient.java similarity index 61% copy from server/protocols/webadmin-cli/src/main/java/org/apache/james/cli/WebAdminCli.java copy to server/protocols/webadmin-cli/src/main/java/org/apache/james/httpclient/DomainClient.java index 895d617..0329c20 100644 --- a/server/protocols/webadmin-cli/src/main/java/org/apache/james/cli/WebAdminCli.java +++ b/server/protocols/webadmin-cli/src/main/java/org/apache/james/httpclient/DomainClient.java @@ -17,36 +17,15 @@ * under the License. * ******************************************************************/ -package org.apache.james.cli; +package org.apache.james.httpclient; -import java.util.concurrent.Callable; +import java.util.List; -import picocli.CommandLine; +import feign.RequestLine; -@CommandLine.Command( - name = "james-cli", - description = "James Webadmin CLI") -public class WebAdminCli implements Callable<Integer> { +public interface DomainClient { - @Override - public Integer call() { - return 0; - } - - public static void main(String[] args) { - int exitCode = execute(args); - System.exit(exitCode); - } - - public static int execute(String[] args) { - WebAdminCli parent = new WebAdminCli(); - return new CommandLine(parent) - .addSubcommand(new CommandLine.HelpCommand()) - .execute(args); - } - - public static int executeFluent(String... args) { - return execute(args); - } + @RequestLine("GET") + List<String> getDomainList(); } diff --git a/server/protocols/webadmin-cli/src/test/java/org/apache/james/cli/HelpVersionCommandTest.java b/server/protocols/webadmin-cli/src/test/java/org/apache/james/cli/DomainManageTest.java similarity index 50% copy from server/protocols/webadmin-cli/src/test/java/org/apache/james/cli/HelpVersionCommandTest.java copy to server/protocols/webadmin-cli/src/test/java/org/apache/james/cli/DomainManageTest.java index 1d8c5cd..a036852 100644 --- a/server/protocols/webadmin-cli/src/test/java/org/apache/james/cli/HelpVersionCommandTest.java +++ b/server/protocols/webadmin-cli/src/test/java/org/apache/james/cli/DomainManageTest.java @@ -19,36 +19,43 @@ package org.apache.james.cli; -import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; +import static org.apache.james.MemoryJamesServerMain.IN_MEMORY_SERVER_AGGREGATE_MODULE; +import static org.assertj.core.api.Assertions.assertThat; import java.io.ByteArrayOutputStream; import java.io.PrintStream; -import static org.assertj.core.api.Assertions.assertThat; - -public class HelpVersionCommandTest { +import org.apache.james.GuiceJamesServer; +import org.apache.james.JamesServerBuilder; +import org.apache.james.JamesServerExtension; +import org.apache.james.modules.TestJMAPServerModule; +import org.apache.james.util.Port; +import org.apache.james.utils.WebAdminGuiceProbe; +import org.apache.james.webadmin.integration.WebadminIntegrationTestModule; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; - private final PrintStream standardOut = System.out; - private final ByteArrayOutputStream outputStreamCaptor = new ByteArrayOutputStream(); +public class DomainManageTest { - @BeforeEach - void setup() { - System.setOut(new PrintStream(outputStreamCaptor)); - } + @RegisterExtension + static JamesServerExtension testExtension = new JamesServerBuilder<>(JamesServerBuilder.defaultConfigurationProvider()) + .server(configuration -> GuiceJamesServer.forConfiguration(configuration) + .combineWith(IN_MEMORY_SERVER_AGGREGATE_MODULE) + .overrideWith(new WebadminIntegrationTestModule()) + .overrideWith(new TestJMAPServerModule())) + .build(); - @AfterEach - void tearDown() { - System.setOut(standardOut); - } + private final ByteArrayOutputStream outputStreamCaptor = new ByteArrayOutputStream(); + private final ByteArrayOutputStream errorStreamCaptor = new ByteArrayOutputStream(); @Test - void helpCommandShouldShowHelpMessage() { - int exitCode = WebAdminCli.executeFluent("help"); + void domainListCommandShouldWShowOnlyDefaultDomain(GuiceJamesServer server) { + Port port = server.getProbe(WebAdminGuiceProbe.class).getWebAdminPort(); + + int exitCode = WebAdminCli.executeFluent(new PrintStream(outputStreamCaptor), new PrintStream(errorStreamCaptor), + "--url", "http://127.0.0.1:" + port.getValue(), "domain", "list"); assertThat(exitCode).isEqualTo(0); - assertThat(outputStreamCaptor.toString()).contains("help"); - assertThat(outputStreamCaptor.toString()).contains("Displays help information about the specified command"); + assertThat(outputStreamCaptor.toString().trim().toCharArray()).containsOnly("localhost".toCharArray()); } } diff --git a/server/protocols/webadmin-cli/src/test/java/org/apache/james/cli/HelpVersionCommandTest.java b/server/protocols/webadmin-cli/src/test/java/org/apache/james/cli/HelpVersionCommandTest.java index 1d8c5cd..f0af042 100644 --- a/server/protocols/webadmin-cli/src/test/java/org/apache/james/cli/HelpVersionCommandTest.java +++ b/server/protocols/webadmin-cli/src/test/java/org/apache/james/cli/HelpVersionCommandTest.java @@ -19,19 +19,20 @@ package org.apache.james.cli; -import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; +import static org.assertj.core.api.Assertions.assertThat; import java.io.ByteArrayOutputStream; import java.io.PrintStream; -import static org.assertj.core.api.Assertions.assertThat; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; public class HelpVersionCommandTest { private final PrintStream standardOut = System.out; private final ByteArrayOutputStream outputStreamCaptor = new ByteArrayOutputStream(); + private final ByteArrayOutputStream errorStreamCaptor = new ByteArrayOutputStream(); @BeforeEach void setup() { @@ -45,7 +46,7 @@ public class HelpVersionCommandTest { @Test void helpCommandShouldShowHelpMessage() { - int exitCode = WebAdminCli.executeFluent("help"); + int exitCode = WebAdminCli.executeFluent(new PrintStream(outputStreamCaptor), new PrintStream(errorStreamCaptor), "help"); assertThat(exitCode).isEqualTo(0); assertThat(outputStreamCaptor.toString()).contains("help"); assertThat(outputStreamCaptor.toString()).contains("Displays help information about the specified command"); diff --git a/server/protocols/webadmin-cli/src/test/resources/dnsservice.xml b/server/protocols/webadmin-cli/src/test/resources/dnsservice.xml new file mode 100644 index 0000000..6e4fbd2 --- /dev/null +++ b/server/protocols/webadmin-cli/src/test/resources/dnsservice.xml @@ -0,0 +1,25 @@ +<?xml version="1.0"?> +<!-- + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. + --> + +<dnsservice> + <autodiscover>true</autodiscover> + <authoritative>false</authoritative> + <maxcachesize>50000</maxcachesize> +</dnsservice> diff --git a/server/protocols/webadmin-cli/src/test/resources/domainlist.xml b/server/protocols/webadmin-cli/src/test/resources/domainlist.xml new file mode 100644 index 0000000..fe17431 --- /dev/null +++ b/server/protocols/webadmin-cli/src/test/resources/domainlist.xml @@ -0,0 +1,24 @@ +<?xml version="1.0"?> +<!-- + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. + --> + +<domainlist> + <autodetect>false</autodetect> + <autodetectIP>false</autodetectIP> +</domainlist> diff --git a/server/protocols/webadmin-cli/src/test/resources/imapserver.xml b/server/protocols/webadmin-cli/src/test/resources/imapserver.xml new file mode 100644 index 0000000..e997022 --- /dev/null +++ b/server/protocols/webadmin-cli/src/test/resources/imapserver.xml @@ -0,0 +1,54 @@ +<?xml version="1.0"?> + +<!-- +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, +software distributed under the License is distributed on an +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, either express or implied. See the License for the +specific language governing permissions and limitations +under the License. +--> + + +<imapservers> + <imapserver enabled="true"> + <jmxName>imapserver</jmxName> + <bind>0.0.0.0:0</bind> + <connectionBacklog>200</connectionBacklog> + <tls socketTLS="false" startTLS="false"> + <!-- To create a new keystore execute: + keytool -genkey -alias james -keyalg RSA -keystore /path/to/james/conf/keystore + --> + <keystore>file://conf/keystore</keystore> + <secret>james72laBalle</secret> + <provider>org.bouncycastle.jce.provider.BouncyCastleProvider</provider> + </tls> + <connectionLimit>0</connectionLimit> + <connectionLimitPerIP>0</connectionLimitPerIP> + </imapserver> + <imapserver enabled="true"> + <jmxName>imapserver-ssl</jmxName> + <bind>0.0.0.0:0</bind> + <connectionBacklog>200</connectionBacklog> + <tls socketTLS="false" startTLS="false"> + <!-- To create a new keystore execute: + keytool -genkey -alias james -keyalg RSA -keystore /path/to/james/conf/keystore + --> + <keystore>file://conf/keystore</keystore> + <secret>james72laBalle</secret> + <provider>org.bouncycastle.jce.provider.BouncyCastleProvider</provider> + </tls> + <connectionLimit>0</connectionLimit> + <connectionLimitPerIP>0</connectionLimitPerIP> + </imapserver> +</imapservers> diff --git a/server/protocols/webadmin-cli/src/test/resources/jwt_publickey b/server/protocols/webadmin-cli/src/test/resources/jwt_publickey new file mode 100644 index 0000000..53914e0 --- /dev/null +++ b/server/protocols/webadmin-cli/src/test/resources/jwt_publickey @@ -0,0 +1,9 @@ +-----BEGIN PUBLIC KEY----- +MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAtlChO/nlVP27MpdkG0Bh +16XrMRf6M4NeyGa7j5+1UKm42IKUf3lM28oe82MqIIRyvskPc11NuzSor8HmvH8H +lhDs5DyJtx2qp35AT0zCqfwlaDnlDc/QDlZv1CoRZGpQk1Inyh6SbZwYpxxwh0fi ++d/4RpE3LBVo8wgOaXPylOlHxsDizfkL8QwXItyakBfMO6jWQRrj7/9WDhGf4Hi+ +GQur1tPGZDl9mvCoRHjFrD5M/yypIPlfMGWFVEvV5jClNMLAQ9bYFuOc7H1fEWw6 +U1LZUUbJW9/CH45YXz82CYqkrfbnQxqRb2iVbVjs/sHopHd1NTiCfUtwvcYJiBVj +kwIDAQAB +-----END PUBLIC KEY----- diff --git a/server/protocols/webadmin-cli/src/test/resources/keystore b/server/protocols/webadmin-cli/src/test/resources/keystore new file mode 100644 index 0000000..536a6c7 Binary files /dev/null and b/server/protocols/webadmin-cli/src/test/resources/keystore differ diff --git a/server/protocols/webadmin-cli/src/test/resources/listeners.xml b/server/protocols/webadmin-cli/src/test/resources/listeners.xml new file mode 100644 index 0000000..59e3fec --- /dev/null +++ b/server/protocols/webadmin-cli/src/test/resources/listeners.xml @@ -0,0 +1,46 @@ +<?xml version="1.0"?> +<!-- + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. + --> + +<listeners> + <listener> + <class>org.apache.james.mailbox.quota.mailing.listeners.QuotaThresholdCrossingListener</class> + <group>QuotaThresholdCrossingListener-lower-threshold</group> + <configuration> + <thresholds> + <threshold> + <value>0.1</value> + </threshold> + </thresholds> + <name>first</name> + </configuration> + </listener> + <listener> + <class>org.apache.james.mailbox.quota.mailing.listeners.QuotaThresholdCrossingListener</class> + <group>QuotaThresholdCrossingListener-upper-threshold</group> + <configuration> + <thresholds> + <threshold> + <value>0.2</value> + </threshold> + </thresholds> + <name>second</name> + </configuration> + </listener> +</listeners> \ No newline at end of file diff --git a/server/protocols/webadmin-cli/src/test/resources/lmtpserver.xml b/server/protocols/webadmin-cli/src/test/resources/lmtpserver.xml new file mode 100644 index 0000000..7739071 --- /dev/null +++ b/server/protocols/webadmin-cli/src/test/resources/lmtpserver.xml @@ -0,0 +1,41 @@ +<?xml version="1.0"?> +<!-- + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. + --> + +<lmtpservers> + + <lmtpserver enabled="true"> + <jmxName>lmtpserver</jmxName> + <!-- LMTP should not be reachable from outside your network so bind it to loopback--> + <bind>127.0.0.1:0</bind> + <connectionBacklog>200</connectionBacklog> + <connectiontimeout>1200</connectiontimeout> + <!-- Set the maximum simultaneous incoming connections for this service --> + <connectionLimit>0</connectionLimit> + <!-- Set the maximum simultaneous incoming connections per IP for this service --> + <connectionLimitPerIP>0</connectionLimitPerIP> + <!-- This sets the maximum allowed message size (in kilobytes) for this --> + <!-- LMTP service. If unspecified, the value defaults to 0, which means no limit. --> + <maxmessagesize>0</maxmessagesize> + <handlerchain> + <handler class="org.apache.james.lmtpserver.CoreCmdHandlerLoader"/> + </handlerchain> + </lmtpserver> + +</lmtpservers> diff --git a/server/protocols/webadmin-cli/src/test/resources/mailetcontainer.xml b/server/protocols/webadmin-cli/src/test/resources/mailetcontainer.xml new file mode 100644 index 0000000..e52366e --- /dev/null +++ b/server/protocols/webadmin-cli/src/test/resources/mailetcontainer.xml @@ -0,0 +1,114 @@ +<?xml version="1.0"?> + +<!-- + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. + --> + +<mailetcontainer enableJmx="false"> + + <context> + <postmaster>postmaster</postmaster> + </context> + + <spooler> + <threads>20</threads> + <errorRepository>memory://var/mail/error/</errorRepository> + </spooler> + + <processors> + <processor state="root" enableJmx="false"> + <mailet match="All" class="PostmasterAlias"/> + <mailet match="RelayLimit=30" class="Null"/> + <mailet match="All" class="ToProcessor"> + <processor>transport</processor> + </mailet> + </processor> + + <processor state="error" enableJmx="false"> + <mailet match="All" class="Bounce"/> + <mailet match="All" class="ToRepository"> + <repositoryPath>memory://var/mail/error/</repositoryPath> + </mailet> + </processor> + + + <processor state="transport" enableJmx="false"> + <matcher name="relay-allowed" match="org.apache.james.mailetcontainer.impl.matchers.Or"> + <matcher match="SMTPAuthSuccessful"/> + <matcher match="SMTPIsAuthNetwork"/> + <matcher match="SentByMailet"/> + <matcher match="org.apache.james.jmap.mailet.SentByJmap"/> + </matcher> + + <mailet match="All" class="RemoveMimeHeader"> + <name>bcc</name> + </mailet> + <mailet match="All" class="RecipientRewriteTable" /> + <mailet match="RecipientIsLocal" class="org.apache.james.jmap.mailet.VacationMailet"/> + <mailet match="RecipientIsLocal" class="Sieve"/> + <mailet match="RecipientIsLocal" class="org.apache.james.jmap.mailet.filter.JMAPFiltering"/> + <mailet match="RecipientIsLocal" class="LocalDelivery"/> + <mailet match="HostIsLocal" class="ToProcessor"> + <processor>local-address-error</processor> + <notice>550 - Requested action not taken: no such user here</notice> + </mailet> + + <mailet match="relay-allowed" class="RemoteDelivery"> + <outgoingQueue>outgoing</outgoingQueue> + <delayTime>5000, 100000, 500000</delayTime> + <maxRetries>3</maxRetries> + <maxDnsProblemRetries>0</maxDnsProblemRetries> + <deliveryThreads>10</deliveryThreads> + <sendpartial>true</sendpartial> + <bounceProcessor>bounces</bounceProcessor> + </mailet> + <mailet match="All" class="ToProcessor"> + <processor>relay-denied</processor> + </mailet> + </processor> + + <processor state="local-address-error" enableJmx="false"> + <mailet match="All" class="Bounce"> + <attachment>none</attachment> + </mailet> + <mailet match="All" class="ToRepository"> + <repositoryPath>memory://var/mail/address-error/</repositoryPath> + </mailet> + </processor> + + <processor state="relay-denied" enableJmx="false"> + <mailet match="All" class="Bounce"> + <attachment>none</attachment> + </mailet> + <mailet match="All" class="ToRepository"> + <repositoryPath>memory://var/mail/relay-denied/</repositoryPath> + <notice>Warning: You are sending an e-mail to a remote server. You must be authentified to perform such an operation</notice> + </mailet> + </processor> + + <processor state="bounces" enableJmx="false"> + <mailet match="All" class="DSNBounce"> + <passThrough>false</passThrough> + </mailet> + </processor> + + </processors> + +</mailetcontainer> + + diff --git a/server/protocols/webadmin-cli/src/test/resources/mailrepositorystore.xml b/server/protocols/webadmin-cli/src/test/resources/mailrepositorystore.xml new file mode 100644 index 0000000..ed3e003 --- /dev/null +++ b/server/protocols/webadmin-cli/src/test/resources/mailrepositorystore.xml @@ -0,0 +1,30 @@ +<?xml version="1.0"?> + +<!-- + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. + --> + +<mailrepositorystore> + <mailrepositories> + <mailrepository class="org.apache.james.mailrepository.memory.MemoryMailRepository"> + <protocols> + <protocol>memory</protocol> + </protocols> + </mailrepository> + </mailrepositories> +</mailrepositorystore> diff --git a/server/protocols/webadmin-cli/src/test/resources/managesieveserver.xml b/server/protocols/webadmin-cli/src/test/resources/managesieveserver.xml new file mode 100644 index 0000000..eee4052 --- /dev/null +++ b/server/protocols/webadmin-cli/src/test/resources/managesieveserver.xml @@ -0,0 +1,65 @@ +<?xml version="1.0"?> +<!-- + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. + --> + +<!-- + This template file can be used as example for James Server configuration + DO NOT USE IT AS SUCH AND ADAPT IT TO YOUR NEEDS +--> + +<!-- See http://james.apache.org/server/3/config.html for usage --> + +<managesieveservers> + + <managesieveserver enabled="true"> + + <jmxName>managesieveserver</jmxName> + + <bind>0.0.0.0:0</bind> + + <connectionBacklog>200</connectionBacklog> + + <tls socketTLS="false" startTLS="false"> + <!-- To create a new keystore execute: + keytool -genkey -alias james -keyalg RSA -keystore /path/to/james/conf/keystore + --> + <keystore>file://conf/keystore</keystore> + <secret>james72laBalle</secret> + <provider>org.bouncycastle.jce.provider.BouncyCastleProvider</provider> + <!-- The algorithm is optional and only needs to be specified when using something other + than the Sun JCE provider - You could use IbmX509 with IBM Java runtime. --> + <algorithm>SunX509</algorithm> + </tls> + + <!-- connection timeout in secconds --> + <connectiontimeout>360</connectiontimeout> + + <!-- Set the maximum simultaneous incoming connections for this service --> + <connectionLimit>0</connectionLimit> + + <!-- Set the maximum simultaneous incoming connections per IP for this service --> + <connectionLimitPerIP>0</connectionLimitPerIP> + <maxmessagesize>0</maxmessagesize> + <addressBracketsEnforcement>true</addressBracketsEnforcement> + + </managesieveserver> + +</managesieveservers> + + diff --git a/server/protocols/webadmin-cli/src/test/resources/pop3server.xml b/server/protocols/webadmin-cli/src/test/resources/pop3server.xml new file mode 100644 index 0000000..595c313 --- /dev/null +++ b/server/protocols/webadmin-cli/src/test/resources/pop3server.xml @@ -0,0 +1,42 @@ +<?xml version="1.0"?> +<!-- + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. + --> + + +<pop3servers> + <pop3server enabled="true"> + <jmxName>pop3server</jmxName> + <bind>0.0.0.0:0</bind> + <connectionBacklog>200</connectionBacklog> + <tls socketTLS="false" startTLS="false"> + <!-- To create a new keystore execute: + keytool -genkey -alias james -keyalg RSA -keystore /path/to/james/conf/keystore + --> + <keystore>file://conf/keystore</keystore> + <secret>james72laBalle</secret> + <provider>org.bouncycastle.jce.provider.BouncyCastleProvider</provider> + </tls> + <connectiontimeout>1200</connectiontimeout> + <connectionLimit>0</connectionLimit> + <connectionLimitPerIP>0</connectionLimitPerIP> + <handlerchain> + <handler class="org.apache.james.pop3server.core.CoreCmdHandlerLoader"/> + </handlerchain> + </pop3server> +</pop3servers> diff --git a/server/protocols/webadmin-cli/src/test/resources/smtpserver.xml b/server/protocols/webadmin-cli/src/test/resources/smtpserver.xml new file mode 100644 index 0000000..66cc7e8 --- /dev/null +++ b/server/protocols/webadmin-cli/src/test/resources/smtpserver.xml @@ -0,0 +1,105 @@ +<?xml version="1.0"?> + +<!-- + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. + --> + +<smtpservers> + <smtpserver enabled="true"> + <jmxName>smtpserver-global</jmxName> + <bind>0.0.0.0:0</bind> + <connectionBacklog>200</connectionBacklog> + <tls socketTLS="false" startTLS="false"> + <keystore>file://conf/keystore</keystore> + <secret>james72laBalle</secret> + <provider>org.bouncycastle.jce.provider.BouncyCastleProvider</provider> + <algorithm>SunX509</algorithm> + </tls> + <connectiontimeout>360</connectiontimeout> + <connectionLimit>0</connectionLimit> + <connectionLimitPerIP>0</connectionLimitPerIP> + <authRequired>false</authRequired> + <authorizedAddresses>0.0.0.0/0</authorizedAddresses> + <verifyIdentity>true</verifyIdentity> + <maxmessagesize>0</maxmessagesize> + <addressBracketsEnforcement>true</addressBracketsEnforcement> + <smtpGreeting>Apache JAMES awesome SMTP Server</smtpGreeting> + <handlerchain> + <handler class="org.apache.james.smtpserver.fastfail.ValidRcptHandler"/> + <handler class="org.apache.james.smtpserver.CoreCmdHandlerLoader"/> + </handlerchain> + </smtpserver> + <smtpserver enabled="true"> + <jmxName>smtpserver-TLS</jmxName> + <bind>0.0.0.0:0</bind> + <connectionBacklog>200</connectionBacklog> + <tls socketTLS="false" startTLS="false"> + <keystore>file://conf/keystore</keystore> + <secret>james72laBalle</secret> + <provider>org.bouncycastle.jce.provider.BouncyCastleProvider</provider> + <algorithm>SunX509</algorithm> + </tls> + <connectiontimeout>360</connectiontimeout> + <connectionLimit>0</connectionLimit> + <connectionLimitPerIP>0</connectionLimitPerIP> + <!-- + Authorize only local users + --> + <authRequired>true</authRequired> + <authorizedAddresses>0.0.0.0/0</authorizedAddresses> + <!-- Trust authenticated users --> + <verifyIdentity>false</verifyIdentity> + <maxmessagesize>0</maxmessagesize> + <addressBracketsEnforcement>true</addressBracketsEnforcement> + <smtpGreeting>Apache JAMES awesome SMTP Server</smtpGreeting> + <handlerchain> + <handler class="org.apache.james.smtpserver.fastfail.ValidRcptHandler"/> + <handler class="org.apache.james.smtpserver.CoreCmdHandlerLoader"/> + </handlerchain> + </smtpserver> + <smtpserver enabled="true"> + <jmxName>smtpserver-authenticated</jmxName> + <bind>0.0.0.0:0</bind> + <connectionBacklog>200</connectionBacklog> + <tls socketTLS="false" startTLS="false"> + <keystore>file://conf/keystore</keystore> + <secret>james72laBalle</secret> + <provider>org.bouncycastle.jce.provider.BouncyCastleProvider</provider> + <algorithm>SunX509</algorithm> + </tls> + <connectiontimeout>360</connectiontimeout> + <connectionLimit>0</connectionLimit> + <connectionLimitPerIP>0</connectionLimitPerIP> + <!-- + Authorize only local users + --> + <authRequired>true</authRequired> + <authorizedAddresses>0.0.0.0/0</authorizedAddresses> + <!-- Trust authenticated users --> + <verifyIdentity>false</verifyIdentity> + <maxmessagesize>0</maxmessagesize> + <addressBracketsEnforcement>true</addressBracketsEnforcement> + <smtpGreeting>Apache JAMES awesome SMTP Server</smtpGreeting> + <handlerchain> + <handler class="org.apache.james.smtpserver.fastfail.ValidRcptHandler"/> + <handler class="org.apache.james.smtpserver.CoreCmdHandlerLoader"/> + </handlerchain> + </smtpserver> +</smtpservers> + + diff --git a/src/adr/0042-james-cli-based-on-webadmin.md b/src/adr/0042-james-cli-based-on-webadmin.md index 8ce5562..3f09f11 100644 --- a/src/adr/0042-james-cli-based-on-webadmin.md +++ b/src/adr/0042-james-cli-based-on-webadmin.md @@ -41,7 +41,7 @@ We decided to write a new CLI client, running on top of the JVM, communicating w * We decided to adopt a more modern, modular CLI syntax: ``` -$ java -jar james-cli.jar [OPTION] ENTITY ACTION {ARGUMENT} +$ ./james-cli [OPTION] ENTITY ACTION {ARGUMENT} ``` where @@ -57,12 +57,12 @@ where Add a domain to the domain list. ``` -$ java -jar james-cli.jar --url http://127.0.0.1 --port 9999 domain create domainNameToBeCreated +$ ./james-cli --url http://127.0.0.1:9999 domain create domainNameToBeCreated ``` In above command-line - OPTION: --url http://127.0.0.1 --port 9999 + OPTION: --url http://127.0.0.1:9999 ENTITY: domain --------------------------------------------------------------------- To unsubscribe, e-mail: notifications-unsubscr...@james.apache.org For additional commands, e-mail: notifications-h...@james.apache.org