[jira] [Commented] (JAMES-3032) [JMAP] Allow a user to send an email with a from address containing one of her alias
[ https://issues.apache.org/jira/browse/JAMES-3032?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17035867#comment-17035867 ] René Cordier commented on JAMES-3032: - https://github.com/linagora/james-project/pull/3071 contributed to this > [JMAP] Allow a user to send an email with a from address containing one of > her alias > > > Key: JAMES-3032 > URL: https://issues.apache.org/jira/browse/JAMES-3032 > Project: James Server > Issue Type: Improvement >Affects Versions: 3.5.0 >Reporter: Rémi Kowalski >Priority: Major > > Currently James checks that the user connected matches the user is the From > header of a mail being sent. > Instead, James should allow that the From header contains any alias of the > connected user. > This also matches the current JMAP specification security considerations: > https://jmap.io/spec-mail.html#permission-to-send-from-an-address -- This message was sent by Atlassian Jira (v8.3.4#803005) - To unsubscribe, e-mail: server-dev-unsubscr...@james.apache.org For additional commands, e-mail: server-dev-h...@james.apache.org
[jira] [Closed] (JAMES-3032) [JMAP] Allow a user to send an email with a from address containing one of her alias
[ https://issues.apache.org/jira/browse/JAMES-3032?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] René Cordier closed JAMES-3032. --- Fix Version/s: 3.5.0 Resolution: Done > [JMAP] Allow a user to send an email with a from address containing one of > her alias > > > Key: JAMES-3032 > URL: https://issues.apache.org/jira/browse/JAMES-3032 > Project: James Server > Issue Type: Improvement >Affects Versions: 3.5.0 >Reporter: Rémi Kowalski >Priority: Major > Fix For: 3.5.0 > > > Currently James checks that the user connected matches the user is the From > header of a mail being sent. > Instead, James should allow that the From header contains any alias of the > connected user. > This also matches the current JMAP specification security considerations: > https://jmap.io/spec-mail.html#permission-to-send-from-an-address -- This message was sent by Atlassian Jira (v8.3.4#803005) - To unsubscribe, e-mail: server-dev-unsubscr...@james.apache.org For additional commands, e-mail: server-dev-h...@james.apache.org
[jira] [Closed] (JAMES-3039) Provision a LinShare technical user within James "LinShare testing" tooling
[ https://issues.apache.org/jira/browse/JAMES-3039?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] René Cordier closed JAMES-3039. --- Fix Version/s: 3.5.0 Resolution: Done > Provision a LinShare technical user within James "LinShare testing" tooling > --- > > Key: JAMES-3039 > URL: https://issues.apache.org/jira/browse/JAMES-3039 > Project: James Server > Issue Type: Improvement >Reporter: Nguyễn Việt Đức >Priority: Major > Fix For: 3.5.0 > > > The LinShare shipped in James should have a preprovision "james" technical > account able to perform uploads. > # Requirements: > - A Linshare backend instance (or docker linshare backend) > - An administrator account (default is > root@localhost.localdomain/adminlinshare) > # Steps: > - Send a POST request with the body containing the custom name & mail of the > delegation account > {code:java} > POST http://localhost:28080/linshare/webservice/rest/admin/technical_accounts > -u "root@localhost.localdomain:adminlinshare" > 200: Ok, created > Not 200: Bad result > {code} > {code:java} > json > { > "name":"delegation", > "mail":"delegat...@linshare.org", > "password":"secret", > "enable":"true", > "role":"DELEGATION" > } > {code} > Reponse body: > {code:java} > json > { "uuid": "8be85afc-5e7d-41c8-8b8f-1ee6db0d392b", "creationDate": > 1568084857046, "modificationDate": 1568084857046, "locale": null, > "externalMailLocale": null, "domain": "LinShareRootDomain", "password": "", > "enable": true, "name": "Delegation", "mail": > "82f6eb74-8ab6-4b6a-9ece-12ec81c8ca88", "permissions": [], "role": > "DELEGATION" } > {code} > - Grant necessary permissions to the delegation account > {code:java} > PUT > [http://localhost:28080/linshare/webservice/rest/admin/technical_accounts] > -u "root@localhost.localdomain:adminlinshare" > 200: Ok, created > Not 200: Bad result > {code} > {code:java} > json > { > "uuid": "uuid-delegation-account", > "mail": "mail-delegation-account(UUID)", > "name": "Delegation", > "permissions": ["DOCUMENT_ENTRIES_CREATE"] > } > {code} > Response body: > {code:java} > json > { > "uuid": "8be85afc-5e7d-41c8-8b8f-1ee6db0d392b", > "creationDate": 1568084857046, > "modificationDate": 1568085050411, > "locale": null, > "externalMailLocale": null, > "domain": "LinShareRootDomain", > "password": "", > "enable": false, > "name": "Delegation", > "mail": "82f6eb74-8ab6-4b6a-9ece-12ec81c8ca88", > "permissions": ["DOCUMENT_ENTRIES_CREATE"], > "role": "DELEGATION" > } > {code} -- This message was sent by Atlassian Jira (v8.3.4#803005) - To unsubscribe, e-mail: server-dev-unsubscr...@james.apache.org For additional commands, e-mail: server-dev-h...@james.apache.org
[jira] [Commented] (JAMES-3039) Provision a LinShare technical user within James "LinShare testing" tooling
[ https://issues.apache.org/jira/browse/JAMES-3039?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17035866#comment-17035866 ] René Cordier commented on JAMES-3039: - https://github.com/linagora/james-project/pull/3054 provisionned a LinShare technical user within James "LinShare testing" tooling > Provision a LinShare technical user within James "LinShare testing" tooling > --- > > Key: JAMES-3039 > URL: https://issues.apache.org/jira/browse/JAMES-3039 > Project: James Server > Issue Type: Improvement >Reporter: Nguyễn Việt Đức >Priority: Major > > The LinShare shipped in James should have a preprovision "james" technical > account able to perform uploads. > # Requirements: > - A Linshare backend instance (or docker linshare backend) > - An administrator account (default is > root@localhost.localdomain/adminlinshare) > # Steps: > - Send a POST request with the body containing the custom name & mail of the > delegation account > {code:java} > POST http://localhost:28080/linshare/webservice/rest/admin/technical_accounts > -u "root@localhost.localdomain:adminlinshare" > 200: Ok, created > Not 200: Bad result > {code} > {code:java} > json > { > "name":"delegation", > "mail":"delegat...@linshare.org", > "password":"secret", > "enable":"true", > "role":"DELEGATION" > } > {code} > Reponse body: > {code:java} > json > { "uuid": "8be85afc-5e7d-41c8-8b8f-1ee6db0d392b", "creationDate": > 1568084857046, "modificationDate": 1568084857046, "locale": null, > "externalMailLocale": null, "domain": "LinShareRootDomain", "password": "", > "enable": true, "name": "Delegation", "mail": > "82f6eb74-8ab6-4b6a-9ece-12ec81c8ca88", "permissions": [], "role": > "DELEGATION" } > {code} > - Grant necessary permissions to the delegation account > {code:java} > PUT > [http://localhost:28080/linshare/webservice/rest/admin/technical_accounts] > -u "root@localhost.localdomain:adminlinshare" > 200: Ok, created > Not 200: Bad result > {code} > {code:java} > json > { > "uuid": "uuid-delegation-account", > "mail": "mail-delegation-account(UUID)", > "name": "Delegation", > "permissions": ["DOCUMENT_ENTRIES_CREATE"] > } > {code} > Response body: > {code:java} > json > { > "uuid": "8be85afc-5e7d-41c8-8b8f-1ee6db0d392b", > "creationDate": 1568084857046, > "modificationDate": 1568085050411, > "locale": null, > "externalMailLocale": null, > "domain": "LinShareRootDomain", > "password": "", > "enable": false, > "name": "Delegation", > "mail": "82f6eb74-8ab6-4b6a-9ece-12ec81c8ca88", > "permissions": ["DOCUMENT_ENTRIES_CREATE"], > "role": "DELEGATION" > } > {code} -- This message was sent by Atlassian Jira (v8.3.4#803005) - To unsubscribe, e-mail: server-dev-unsubscr...@james.apache.org For additional commands, e-mail: server-dev-h...@james.apache.org
[jira] [Commented] (JAMES-2917) Rely on ElasticSearch routing key
[ https://issues.apache.org/jira/browse/JAMES-2917?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17035865#comment-17035865 ] René Cordier commented on JAMES-2917: - https://github.com/linagora/james-project/pull/3101 add avoiding specifying an unbounded count of routing keys > Rely on ElasticSearch routing key > - > > Key: JAMES-2917 > URL: https://issues.apache.org/jira/browse/JAMES-2917 > Project: James Server > Issue Type: Improvement > Components: elasticsearch >Reporter: Benoit Tellier >Priority: Major > Labels: perfomance > Fix For: 3.5.0 > > > Our queries are mostly bounded to a mailbox or an user. We can easily > limit the number of ElasticSearch nodes involved in a given query by > grouping the underlying documents on the same node using a routingKey. > Without routing key, each shard needs to execute the query. The coordinator > needs also to be waiting for the slowest shard. > Using the routing key unlocks significant throughput enhancement > (proportional > to the number of shard) and also a possible high percentile latencies > enhancement. This allows to be more lineary scalable. > However a data reindex is needed. -- This message was sent by Atlassian Jira (v8.3.4#803005) - To unsubscribe, e-mail: server-dev-unsubscr...@james.apache.org For additional commands, e-mail: server-dev-h...@james.apache.org
[james-project] 08/21: [Refactoring] Add a StringValidator
This is an automated email from the ASF dual-hosted git repository. rcordier pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/james-project.git commit 4c8009d8b700d3bab9b1c881f28bc9a352631f75 Author: Benoit Tellier AuthorDate: Fri Dec 13 07:40:11 2019 +0100 [Refactoring] Add a StringValidator This code snipset was duplicated in several places --- .../james/imap/decode/ImapRequestLineReader.java | 19 +++ 1 file changed, 19 insertions(+) diff --git a/protocols/imap/src/main/java/org/apache/james/imap/decode/ImapRequestLineReader.java b/protocols/imap/src/main/java/org/apache/james/imap/decode/ImapRequestLineReader.java index a5b5bbe..1501634 100644 --- a/protocols/imap/src/main/java/org/apache/james/imap/decode/ImapRequestLineReader.java +++ b/protocols/imap/src/main/java/org/apache/james/imap/decode/ImapRequestLineReader.java @@ -28,6 +28,7 @@ import java.nio.charset.Charset; import java.nio.charset.CharsetDecoder; import java.nio.charset.CoderResult; import java.nio.charset.CodingErrorAction; +import java.nio.charset.StandardCharsets; import java.time.LocalDateTime; import java.util.ArrayList; import java.util.List; @@ -814,6 +815,24 @@ public abstract class ImapRequestLineReader { boolean isValid(char chr); } +public static class StringValidator implements CharacterValidator { +private final byte[] expectedStringAsBytes; +private int position = 0; + +public StringValidator(String expectedString) { +this.expectedStringAsBytes = expectedString.getBytes(StandardCharsets.US_ASCII); +} + +@Override +public boolean isValid(char chr) { +if (position >= expectedStringAsBytes.length) { +return false; +} else { +return ImapRequestLineReader.cap(chr) == expectedStringAsBytes[position++]; +} +} +} + public static class NoopCharValidator implements CharacterValidator { @Override public boolean isValid(char chr) { - To unsubscribe, e-mail: server-dev-unsubscr...@james.apache.org For additional commands, e-mail: server-dev-h...@james.apache.org
[james-project] 21/21: JAMES-3039: Provision a LinShare technical user within James
This is an automated email from the ASF dual-hosted git repository. rcordier pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/james-project.git commit 11765992e2240d801e781665c2a37e03d16e1221 Author: duc91 AuthorDate: Tue Feb 4 11:02:57 2020 +0700 JAMES-3039: Provision a LinShare technical user within James --- .../apache/james/linshare/LinshareExtension.java | 36 +- .../org/apache/james/linshare/LinshareFixture.java | 7 ++ .../org/apache/james/linshare/LinshareTest.java| 19 ++ .../client/TechnicalAccountCreationRequest.java| 76 ++ .../TechnicalAccountGrantPermissionsRequest.java | 66 +++ .../linshare/client/TechnicalAccountResponse.java | 66 +++ 6 files changed, 269 insertions(+), 1 deletion(-) diff --git a/third-party/linshare/src/test/java/org/apache/james/linshare/LinshareExtension.java b/third-party/linshare/src/test/java/org/apache/james/linshare/LinshareExtension.java index 488083b..103ef3d 100644 --- a/third-party/linshare/src/test/java/org/apache/james/linshare/LinshareExtension.java +++ b/third-party/linshare/src/test/java/org/apache/james/linshare/LinshareExtension.java @@ -18,17 +18,23 @@ / package org.apache.james.linshare; +import static org.apache.james.linshare.LinshareFixture.ADMIN_ACCOUNT; import static org.apache.james.linshare.LinshareFixture.USER_1; import static org.apache.james.linshare.LinshareFixture.USER_CREDENTIAL_MAP; import static org.apache.james.linshare.client.LinshareAPI.Headers.ACCEPT_APPLICATION_JSON; +import static org.apache.james.linshare.client.LinshareAPI.Headers.CONTENT_TYPE_APPLICATION_JSON; import java.util.List; import java.util.Optional; import org.apache.james.linshare.client.Document; import org.apache.james.linshare.client.LinshareAPI; +import org.apache.james.linshare.client.TechnicalAccountCreationRequest; +import org.apache.james.linshare.client.TechnicalAccountGrantPermissionsRequest; +import org.apache.james.linshare.client.TechnicalAccountResponse; import org.apache.james.linshare.client.User; import org.apache.james.utils.FakeSmtp; +import org.junit.jupiter.api.extension.BeforeAllCallback; import org.junit.jupiter.api.extension.BeforeEachCallback; import org.junit.jupiter.api.extension.ExtensionContext; @@ -45,7 +51,7 @@ import feign.jackson.JacksonDecoder; import feign.jackson.JacksonEncoder; import feign.slf4j.Slf4jLogger; -public class LinshareExtension implements BeforeEachCallback { +public class LinshareExtension implements BeforeEachCallback, BeforeAllCallback { private interface LinshareAPIForTesting { @@ -74,9 +80,21 @@ public class LinshareExtension implements BeforeEachCallback { @Headers(ACCEPT_APPLICATION_JSON) List allUsers(); +@RequestLine("GET /linshare/webservice/rest/admin/technical_accounts") +@Headers(ACCEPT_APPLICATION_JSON) +List allTechnicalAccounts(); + @RequestLine("GET /linshare/webservice/rest/user/v2/received_shares/{documentId}/download") @Headers({ CONTENT_TYPE_APPLICATION_OCTET_STREAM, CONTENT_DISPOSITION_ATTACHMENT }) byte[] downloadShare(@Param("documentId") String documentId, @Param("filename") String filename); + +@RequestLine("POST /linshare/webservice/rest/admin/technical_accounts") +@Headers({ ACCEPT_APPLICATION_JSON, CONTENT_TYPE_APPLICATION_JSON }) +TechnicalAccountResponse createTechnicalAccount(TechnicalAccountCreationRequest accountCreationRequest); + +@RequestLine("PUT /linshare/webservice/rest/admin/technical_accounts") +@Headers({ ACCEPT_APPLICATION_JSON, CONTENT_TYPE_APPLICATION_JSON }) +TechnicalAccountResponse grantTechnicalAccountPermissions(TechnicalAccountGrantPermissionsRequest accountGrantPermissionsRequest); } private final Linshare linshare = LinshareSingleton.singleton; @@ -109,6 +127,22 @@ public class LinshareExtension implements BeforeEachCallback { .downloadShare(document.asString(), filename); } +@Override +public void beforeAll(ExtensionContext extensionContext){ + createTechnicalAccount(TechnicalAccountCreationRequest.defaultAccount()); +} + +private void createTechnicalAccount(TechnicalAccountCreationRequest technicalAccountDTO) { +TechnicalAccountResponse technicalAccountResponse = LinshareAPIForTesting.from(ADMIN_ACCOUNT, linshare).createTechnicalAccount(technicalAccountDTO); + +TechnicalAccountGrantPermissionsRequest technicalAccountGrantPermissionsRequest = new TechnicalAccountGrantPermissionsRequest(technicalAccountResponse); +LinshareAPIForTesting.from(ADMIN_ACCOUNT, linshare).grantTechnicalAccountPermissions(technicalAccountGrantPermissionsRequest); +} + +public List getAllTechnicalAccounts(LinshareFixture.Credential credential) {
[james-project] 18/21: [REFACTORING] Remove final variable in FetchCommandParser
This is an automated email from the ASF dual-hosted git repository. rcordier pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/james-project.git commit 06038c87e569b3634c6ae6da833548c816856115 Author: Benoit Tellier AuthorDate: Tue Jan 14 09:49:39 2020 +0700 [REFACTORING] Remove final variable in FetchCommandParser --- .../james/imap/decode/parser/FetchCommandParser.java | 16 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/protocols/imap/src/main/java/org/apache/james/imap/decode/parser/FetchCommandParser.java b/protocols/imap/src/main/java/org/apache/james/imap/decode/parser/FetchCommandParser.java index 864ffa3..caf93cc 100644 --- a/protocols/imap/src/main/java/org/apache/james/imap/decode/parser/FetchCommandParser.java +++ b/protocols/imap/src/main/java/org/apache/james/imap/decode/parser/FetchCommandParser.java @@ -128,8 +128,8 @@ public class FetchCommandParser extends AbstractUidCommandParser { reader.consumeChar(']'); -final Long firstOctet; -final Long numberOfOctets; +Long firstOctet; +Long numberOfOctets; if (reader.nextChar() == '<') { reader.consumeChar('<'); firstOctet = reader.number(); @@ -145,8 +145,8 @@ public class FetchCommandParser extends AbstractUidCommandParser { numberOfOctets = null; } -final BodyFetchElement bodyFetchElement = createBodyElement(parameter, firstOctet, numberOfOctets); -final boolean isPeek = isPeek(name); +BodyFetchElement bodyFetchElement = createBodyElement(parameter, firstOctet, numberOfOctets); +boolean isPeek = isPeek(name); fetch.add(bodyFetchElement, isPeek); } } @@ -199,13 +199,13 @@ public class FetchCommandParser extends AbstractUidCommandParser { } private BodyFetchElement createBodyElement(String parameter, Long firstOctet, Long numberOfOctets) throws DecodingException { -final String responseName = "BODY[" + parameter + "]"; +String responseName = "BODY[" + parameter + "]"; FetchPartPathDecoder decoder = new FetchPartPathDecoder(); decoder.decode(parameter); -final SectionType sectionType = decoder.getSpecifier(); +SectionType sectionType = decoder.getSpecifier(); -final List names = decoder.getNames(); -final int[] path = decoder.getPath(); +List names = decoder.getNames(); +int[] path = decoder.getPath(); return new BodyFetchElement(responseName, sectionType, path, names, firstOctet, numberOfOctets); } - To unsubscribe, e-mail: server-dev-unsubscr...@james.apache.org For additional commands, e-mail: server-dev-h...@james.apache.org
[james-project] 13/21: [Refactoring] (slightly) Improve Select command parser readability
This is an automated email from the ASF dual-hosted git repository. rcordier pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/james-project.git commit ba43a3eeef2e48f38edc7738dd01a4afc34a2ba1 Author: Benoit Tellier AuthorDate: Fri Dec 13 07:44:04 2019 +0100 [Refactoring] (slightly) Improve Select command parser readability --- .../parser/AbstractSelectionCommandParser.java | 26 +- 1 file changed, 5 insertions(+), 21 deletions(-) diff --git a/protocols/imap/src/main/java/org/apache/james/imap/decode/parser/AbstractSelectionCommandParser.java b/protocols/imap/src/main/java/org/apache/james/imap/decode/parser/AbstractSelectionCommandParser.java index c381ce2..812cdfc 100644 --- a/protocols/imap/src/main/java/org/apache/james/imap/decode/parser/AbstractSelectionCommandParser.java +++ b/protocols/imap/src/main/java/org/apache/james/imap/decode/parser/AbstractSelectionCommandParser.java @@ -29,14 +29,14 @@ import org.apache.james.imap.api.message.response.StatusResponseFactory; import org.apache.james.imap.api.process.ImapSession; import org.apache.james.imap.decode.DecodingException; import org.apache.james.imap.decode.ImapRequestLineReader; -import org.apache.james.imap.decode.ImapRequestLineReader.CharacterValidator; +import org.apache.james.imap.decode.ImapRequestLineReader.StringValidator; import org.apache.james.imap.decode.base.AbstractImapCommandParser; import org.apache.james.imap.message.request.AbstractMailboxSelectionRequest; import org.apache.james.mailbox.MessageUid; public abstract class AbstractSelectionCommandParser extends AbstractImapCommandParser { -private static final byte[] CONDSTORE = ImapConstants.SUPPORTS_CONDSTORE.asString().getBytes(); -private static final byte[] QRESYNC = ImapConstants.SUPPORTS_QRESYNC.asString().getBytes(); +private static final String CONDSTORE = ImapConstants.SUPPORTS_CONDSTORE.asString(); +private static final String QRESYNC = ImapConstants.SUPPORTS_QRESYNC.asString(); public AbstractSelectionCommandParser(ImapCommand command, StatusResponseFactory statusResponseFactory) { super(command, statusResponseFactory); @@ -67,28 +67,12 @@ public abstract class AbstractSelectionCommandParser extends AbstractImapCommand switch (n) { case 'C': // It starts with C so it should be CONDSTORE -int pos = 0; -while (pos < CONDSTORE.length) { -if (CONDSTORE[pos++] != ImapRequestLineReader.cap(request.consume())) { -throw new DecodingException(HumanReadableText.ILLEGAL_ARGUMENTS, "Unknown option"); -} -} +request.consumeWord(new StringValidator(CONDSTORE)); condstore = true; break; case 'Q': // It starts with Q so it should be QRESYNC -request.consumeWord(new CharacterValidator() { -int pos = 0; - -@Override -public boolean isValid(char chr) { -if (pos >= QRESYNC.length) { -return false; -} else { -return ImapRequestLineReader.cap(chr) == QRESYNC[pos++]; -} -} -}); +request.consumeWord(new StringValidator(QRESYNC)); // Consume the SP request.consumeChar(' '); - To unsubscribe, e-mail: server-dev-unsubscr...@james.apache.org For additional commands, e-mail: server-dev-h...@james.apache.org
[james-project] 04/21: JAMES-3032 add a class to check if a user can senda a mail from a given address
This is an automated email from the ASF dual-hosted git repository. rcordier pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/james-project.git commit 03cfc8d03c1be11034b0d3a896c85cf1ea40d6f7 Author: Rémi KOWALSKI AuthorDate: Tue Feb 4 16:02:05 2020 +0100 JAMES-3032 add a class to check if a user can senda a mail from a given address --- .../java/org/apache/james/rrt/api/CanSendFrom.java | 30 +++ .../apache/james/rrt/lib/CanSendFromContract.java | 96 ++ .../org/apache/james/rrt/lib/CanSendFromImpl.java | 63 ++ server/data/data-memory/pom.xml| 5 ++ .../apache/james/rrt/lib/CanSendFromImplTest.java | 72 5 files changed, 266 insertions(+) diff --git a/server/data/data-api/src/main/java/org/apache/james/rrt/api/CanSendFrom.java b/server/data/data-api/src/main/java/org/apache/james/rrt/api/CanSendFrom.java new file mode 100644 index 000..41e495c --- /dev/null +++ b/server/data/data-api/src/main/java/org/apache/james/rrt/api/CanSendFrom.java @@ -0,0 +1,30 @@ +/ + * 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. * + / +package org.apache.james.rrt.api; + +import org.apache.james.core.Username; + +public interface CanSendFrom { + +/** + * Indicate if the connectedUser can send a mail using the fromUser in the from clause. + */ +boolean userCanSendFrom(Username connectedUser, Username fromUser); + +} diff --git a/server/data/data-api/src/test/java/org/apache/james/rrt/lib/CanSendFromContract.java b/server/data/data-api/src/test/java/org/apache/james/rrt/lib/CanSendFromContract.java new file mode 100644 index 000..b806193 --- /dev/null +++ b/server/data/data-api/src/test/java/org/apache/james/rrt/lib/CanSendFromContract.java @@ -0,0 +1,96 @@ +/ + * 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. * + / +package org.apache.james.rrt.lib; + +import static org.assertj.core.api.Assertions.assertThat; + +import org.apache.james.core.Domain; +import org.apache.james.core.Username; +import org.apache.james.rrt.api.CanSendFrom; +import org.junit.jupiter.api.Test; + +public interface CanSendFromContract { + +Domain DOMAIN = Domain.of("example.com"); +Domain OTHER_DOMAIN = Domain.of("other.org"); +Username USER = Username.of("u...@example.com"); +Username USER_ALIAS = Username.of("al...@example.com"); +Username OTHER_USER = Username.of("ot...@example.com"); + +CanSendFrom canSendFrom(); + +void addAliasMapping(Username alias, Username user) throws Exception; + +void addDomainMapping(Domain alias, Domain domain) throws Exception; + +void addGroupMapping(String group, Username user)
[james-project] 07/21: JAMES-3032 allow user to send a mail from an alias, allow alias in SetMessageUpdateProcessor
This is an automated email from the ASF dual-hosted git repository. rcordier pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/james-project.git commit 441d729c6073073587d5db6342429f0799fdf609 Author: Rémi KOWALSKI AuthorDate: Mon Feb 10 11:43:46 2020 +0100 JAMES-3032 allow user to send a mail from an alias, allow alias in SetMessageUpdateProcessor --- .../methods/integration/SetMessagesMethodTest.java | 54 ++ .../draft/methods/SetMessagesUpdateProcessor.java | 23 ++- .../methods/SetMessagesUpdateProcessorTest.java| 211 +++-- 3 files changed, 258 insertions(+), 30 deletions(-) diff --git a/server/protocols/jmap-draft-integration-testing/jmap-draft-integration-testing-common/src/test/java/org/apache/james/jmap/draft/methods/integration/SetMessagesMethodTest.java b/server/protocols/jmap-draft-integration-testing/jmap-draft-integration-testing-common/src/test/java/org/apache/james/jmap/draft/methods/integration/SetMessagesMethodTest.java index a5776b2..85a6743 100644 --- a/server/protocols/jmap-draft-integration-testing/jmap-draft-integration-testing-common/src/test/java/org/apache/james/jmap/draft/methods/integration/SetMessagesMethodTest.java +++ b/server/protocols/jmap-draft-integration-testing/jmap-draft-integration-testing-common/src/test/java/org/apache/james/jmap/draft/methods/integration/SetMessagesMethodTest.java @@ -2164,6 +2164,60 @@ public abstract class SetMessagesMethodTest { } @Test +public void setMessagesShouldSendMessageByMovingDraftToOutboxForAMailSentFromAnAlias() throws Exception { + dataProbe.addUserAliasMapping(Username.of(ALIAS_OF_USERNAME_MAIL).getLocalPart(), ALIAS_OF_USERNAME.getDomainPart().get().asString(), USERNAME.asString()); + +String draftCreationId = "creationId1337"; +String fromAddress = USERNAME.asString(); +String createDraft = "[" + +" [" + +"\"setMessages\"," + +"{" + +" \"create\": { \"" + draftCreationId + "\" : {" + +"\"from\": { \"name\": \"Me\", \"email\": \"" + ALIAS_OF_USERNAME.asString() + "\"}," + +"\"to\": [{ \"name\": \"BOB\", \"email\": \"" + BOB.asString() + "\"}]," + +"\"subject\": \"subject\"," + +"\"keywords\": {\"$Draft\": true}," + +"\"mailboxIds\": [\"" + getDraftId(accessToken) + "\"]" + +" }}" + +"}," + +"\"#0\"" + +" ]" + +"]"; + +String draftId = +with() +.header("Authorization", accessToken.asString()) +.body(createDraft) +.post("/jmap") +.then() +.extract() +.path(ARGUMENTS + ".created[\"" + draftCreationId + "\"].id"); + +String moveDraftToOutBox = "[" + +" [" + +"\"setMessages\"," + +"{" + +" \"update\": { \"" + draftId + "\" : {" + +"\"keywords\": {}," + +"\"mailboxIds\": [\"" + getOutboxId(accessToken) + "\"]" + +" }}" + +"}," + +"\"#0\"" + +" ]" + +"]"; + +with() +.header("Authorization", accessToken.asString()) +.body(moveDraftToOutBox) +.post("/jmap"); + +calmlyAwait +.pollDelay(Duration.FIVE_HUNDRED_MILLISECONDS) +.atMost(30, TimeUnit.SECONDS).until(() -> isAnyMessageFoundInRecipientsMailboxes(bobAccessToken)); +} + +@Test public void setMessagesShouldRejectDraftCopyToOutbox() { String draftCreationId = "creationId1337"; String fromAddress = USERNAME.asString(); diff --git a/server/protocols/jmap-draft/src/main/java/org/apache/james/jmap/draft/methods/SetMessagesUpdateProcessor.java b/server/protocols/jmap-draft/src/main/java/org/apache/james/jmap/draft/methods/SetMessagesUpdateProcessor.java index 07816cb..054e7ab 100644 --- a/server/protocols/jmap-draft/src/main/java/org/apache/james/jmap/draft/methods/SetMessagesUpdateProcessor.java +++ b/server/protocols/jmap-draft/src/main/java/org/apache/james/jmap/draft/methods/SetMessagesUpdateProcessor.java @@ -35,7 +35,6 @@ import javax.mail.MessagingException; import javax.mail.Session; import javax.mail.internet.MimeMessage; -import org.apache.james.core.MailAddress; import org.apache.james.core.Username; import org.apache.james.jmap.draft.exceptions.DraftMessageMailboxUpdateException; import org.apache.james.jmap.draft.exceptions.InvalidOutboxMoveException; @@ -64,6 +63,7 @@ import org.apache.james.mailbox.model.MessageMoves; import org.apache.james.mailbox.model.MessageResult; import org.apache.james.metrics.api.MetricFactory; import org.apache.james.metrics.api.TimeMetric; +import
[james-project] 10/21: [Refactoring] Improve Expunge command parser readability
This is an automated email from the ASF dual-hosted git repository. rcordier pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/james-project.git commit ad63013927640474f2e0032f7fba66d57ee8c1cd Author: Benoit Tellier AuthorDate: Fri Dec 13 07:41:03 2019 +0100 [Refactoring] Improve Expunge command parser readability --- .../apache/james/imap/decode/parser/ExpungeCommandParser.java | 11 +++ 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/protocols/imap/src/main/java/org/apache/james/imap/decode/parser/ExpungeCommandParser.java b/protocols/imap/src/main/java/org/apache/james/imap/decode/parser/ExpungeCommandParser.java index 04040f7..5216975 100644 --- a/protocols/imap/src/main/java/org/apache/james/imap/decode/parser/ExpungeCommandParser.java +++ b/protocols/imap/src/main/java/org/apache/james/imap/decode/parser/ExpungeCommandParser.java @@ -39,13 +39,16 @@ public class ExpungeCommandParser extends AbstractUidCommandParser { @Override protected ImapMessage decode(ImapRequestLineReader request, Tag tag, boolean useUids, ImapSession session) throws DecodingException { -IdRange[] uidSet = null; -if (useUids) { -uidSet = request.parseIdRange(session); -} +IdRange[] uidSet = parseIdRange(request, useUids, session); request.eol(); return new ExpungeRequest(tag, uidSet); } +private IdRange[] parseIdRange(ImapRequestLineReader request, boolean useUids, ImapSession session) throws DecodingException { +if (useUids) { +return request.parseIdRange(session); +} +return null; +} } - To unsubscribe, e-mail: server-dev-unsubscr...@james.apache.org For additional commands, e-mail: server-dev-h...@james.apache.org
[james-project] 19/21: [REFACTORING] Use switch instead of chained 'if' within StoreCommandParser
This is an automated email from the ASF dual-hosted git repository. rcordier pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/james-project.git commit 4dd7fbe3c3a0d484e0428a56ecb939430f7e6755 Author: Benoit Tellier AuthorDate: Tue Jan 14 09:51:09 2020 +0700 [REFACTORING] Use switch instead of chained 'if' within StoreCommandParser --- .../imap/decode/parser/StoreCommandParser.java | 33 -- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/protocols/imap/src/main/java/org/apache/james/imap/decode/parser/StoreCommandParser.java b/protocols/imap/src/main/java/org/apache/james/imap/decode/parser/StoreCommandParser.java index a00df86..d161f14 100644 --- a/protocols/imap/src/main/java/org/apache/james/imap/decode/parser/StoreCommandParser.java +++ b/protocols/imap/src/main/java/org/apache/james/imap/decode/parser/StoreCommandParser.java @@ -18,6 +18,8 @@ / package org.apache.james.imap.decode.parser; +import java.util.Locale; + import javax.mail.Flags; import org.apache.james.imap.api.ImapConstants; @@ -91,25 +93,26 @@ public class StoreCommandParser extends AbstractUidCommandParser { } private boolean parseSilent(String directive) throws DecodingException { -if ("FLAGS".equalsIgnoreCase(directive)) { -return false; -} else if ("FLAGS.SILENT".equalsIgnoreCase(directive)) { -return true; -} else { -throw new DecodingException(HumanReadableText.ILLEGAL_ARGUMENTS, "Invalid Store Directive: '" + directive + "'"); +switch (directive.toUpperCase(Locale.US)) { +case "FLAGS": +return false; +case "FLAGS.SILENT": +return true; +default: +throw new DecodingException(HumanReadableText.ILLEGAL_ARGUMENTS, "Invalid Store Directive: '" + directive + "'"); } } private MessageManager.FlagsUpdateMode parseFlagsUpdateMode(ImapRequestLineReader request, char next) throws DecodingException { -if (next == '+') { -MessageManager.FlagsUpdateMode flagsUpdateMode = MessageManager.FlagsUpdateMode.ADD; -request.consume(); -return flagsUpdateMode; -} else if (next == '-') { -MessageManager.FlagsUpdateMode flagsUpdateMode = MessageManager.FlagsUpdateMode.REMOVE; -request.consume(); -return flagsUpdateMode; +switch (next) { +case '+': +request.consume(); +return MessageManager.FlagsUpdateMode.ADD; +case '-': +request.consume(); +return MessageManager.FlagsUpdateMode.REMOVE; +default: +return MessageManager.FlagsUpdateMode.REPLACE; } -return MessageManager.FlagsUpdateMode.REPLACE; } } - To unsubscribe, e-mail: server-dev-unsubscr...@james.apache.org For additional commands, e-mail: server-dev-h...@james.apache.org
[james-project] 16/21: [Refactoring] Tests for StoreCommandParser::parseDateTime
This is an automated email from the ASF dual-hosted git repository. rcordier pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/james-project.git commit 30d00acb57661db5a3757ce414cab7bde0ddc727 Author: Benoit Tellier AuthorDate: Thu Dec 19 15:07:40 2019 +0700 [Refactoring] Tests for StoreCommandParser::parseDateTime --- .../imap/decode/parser/AppendCommandParser.java| 13 +++- .../imap/decode/parser/ImapParserFactory.java | 3 +- .../decode/parser/AppendCommandParserTest.java | 87 ++ 3 files changed, 99 insertions(+), 4 deletions(-) diff --git a/protocols/imap/src/main/java/org/apache/james/imap/decode/parser/AppendCommandParser.java b/protocols/imap/src/main/java/org/apache/james/imap/decode/parser/AppendCommandParser.java index 239fa80..7f4b520 100644 --- a/protocols/imap/src/main/java/org/apache/james/imap/decode/parser/AppendCommandParser.java +++ b/protocols/imap/src/main/java/org/apache/james/imap/decode/parser/AppendCommandParser.java @@ -18,6 +18,7 @@ / package org.apache.james.imap.decode.parser; +import java.time.Clock; import java.time.LocalDateTime; import java.time.ZoneId; import java.util.Date; @@ -34,12 +35,17 @@ import org.apache.james.imap.decode.ImapRequestLineReader; import org.apache.james.imap.decode.base.AbstractImapCommandParser; import org.apache.james.imap.message.request.AppendRequest; +import com.google.common.annotations.VisibleForTesting; + /** * Parses APPEND command */ public class AppendCommandParser extends AbstractImapCommandParser { -public AppendCommandParser(StatusResponseFactory statusResponseFactory) { +private final Clock clock; + +public AppendCommandParser(StatusResponseFactory statusResponseFactory, Clock clock) { super(ImapConstants.APPEND_COMMAND, statusResponseFactory); +this.clock = clock; } /** @@ -59,12 +65,13 @@ public class AppendCommandParser extends AbstractImapCommandParser { * If the next character in the request is a '"', tries to read a DateTime * argument. If not, returns now. */ -private LocalDateTime parseDateTime(ImapRequestLineReader request) throws DecodingException { +@VisibleForTesting +LocalDateTime parseDateTime(ImapRequestLineReader request) throws DecodingException { char next = request.nextWordChar(); if (next == '"') { return request.dateTime(); } -return LocalDateTime.now(); +return LocalDateTime.now(clock); } @Override diff --git a/protocols/imap/src/main/java/org/apache/james/imap/decode/parser/ImapParserFactory.java b/protocols/imap/src/main/java/org/apache/james/imap/decode/parser/ImapParserFactory.java index 23e6a75..e65ae8a 100644 --- a/protocols/imap/src/main/java/org/apache/james/imap/decode/parser/ImapParserFactory.java +++ b/protocols/imap/src/main/java/org/apache/james/imap/decode/parser/ImapParserFactory.java @@ -19,6 +19,7 @@ package org.apache.james.imap.decode.parser; +import java.time.Clock; import java.util.Locale; import java.util.Map; import java.util.function.Function; @@ -65,7 +66,7 @@ public class ImapParserFactory implements ImapCommandParserFactory { new XListCommandParser(statusResponseFactory), new LsubCommandParser(statusResponseFactory), new StatusCommandParser(statusResponseFactory), -new AppendCommandParser(statusResponseFactory), +new AppendCommandParser(statusResponseFactory, Clock.systemDefaultZone()), // RFC2342 NAMESPACE new NamespaceCommandParser(statusResponseFactory), diff --git a/protocols/imap/src/test/java/org/apache/james/imap/decode/parser/AppendCommandParserTest.java b/protocols/imap/src/test/java/org/apache/james/imap/decode/parser/AppendCommandParserTest.java new file mode 100644 index 000..ae8cb2f --- /dev/null +++ b/protocols/imap/src/test/java/org/apache/james/imap/decode/parser/AppendCommandParserTest.java @@ -0,0 +1,87 @@ +/ + * 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
[james-project] 06/21: JAMES-3032 allow user to send an email with a from address containing one of her alias
This is an automated email from the ASF dual-hosted git repository. rcordier pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/james-project.git commit fafe4ee1d7d0eed289a20d70d3a51a0ab4439bb6 Author: Rémi KOWALSKI AuthorDate: Thu Jan 30 15:12:20 2020 +0100 JAMES-3032 allow user to send an email with a from address containing one of her alias Currently James checks that the user connected matches the user is the From header of a mail being sent. Instead, James should allow that the From header contains any alias of the connected user. This also matches the current JMAP specification security considerations: https://jmap.io/spec-mail.html#permission-to-send-from-an-address --- .../james/rrt/api/RecipientRewriteTable.java | 10 +- .../rrt/lib/AbstractRecipientRewriteTable.java | 30 ++--- .../methods/integration/SetMessagesMethodTest.java | 128 - server/protocols/jmap-draft/pom.xml| 5 + .../methods/SetMessagesCreationProcessor.java | 33 +++--- .../methods/SetMessagesCreationProcessorTest.java | 120 ++- .../apache/james/jmap/JMAPTestingConstants.java| 1 + 7 files changed, 293 insertions(+), 34 deletions(-) diff --git a/server/data/data-api/src/main/java/org/apache/james/rrt/api/RecipientRewriteTable.java b/server/data/data-api/src/main/java/org/apache/james/rrt/api/RecipientRewriteTable.java index 3f9b339..e3ea519 100644 --- a/server/data/data-api/src/main/java/org/apache/james/rrt/api/RecipientRewriteTable.java +++ b/server/data/data-api/src/main/java/org/apache/james/rrt/api/RecipientRewriteTable.java @@ -94,7 +94,15 @@ public interface RecipientRewriteTable { * @throws ErrorMappingException * get thrown if an error mapping was found */ -Mappings getResolvedMappings(String user, Domain domain) throws ErrorMappingException, RecipientRewriteTableException; +default Mappings getResolvedMappings(String user, Domain domain) throws ErrorMappingException, RecipientRewriteTableException { +return getResolvedMappings(user, domain, EnumSet.allOf(Mapping.Type.class)); +} + +/** + * Return the Mappings for the given source, only the mapping with the given mapping types are considered during the resolution. + * Return empty object if no matched mapping was found + */ +Mappings getResolvedMappings(String user, Domain domain, EnumSet mappingTypes) throws ErrorMappingException, RecipientRewriteTableException; /** * Return the explicit mapping stored for the given user and domain. Return empty object diff --git a/server/data/data-library/src/main/java/org/apache/james/rrt/lib/AbstractRecipientRewriteTable.java b/server/data/data-library/src/main/java/org/apache/james/rrt/lib/AbstractRecipientRewriteTable.java index a43900f..260d5f6 100644 --- a/server/data/data-library/src/main/java/org/apache/james/rrt/lib/AbstractRecipientRewriteTable.java +++ b/server/data/data-library/src/main/java/org/apache/james/rrt/lib/AbstractRecipientRewriteTable.java @@ -18,6 +18,7 @@ / package org.apache.james.rrt.lib; +import java.util.EnumSet; import java.util.Map; import java.util.Optional; import java.util.function.Function; @@ -101,11 +102,12 @@ public abstract class AbstractRecipientRewriteTable implements RecipientRewriteT } @Override -public Mappings getResolvedMappings(String user, Domain domain) throws ErrorMappingException, RecipientRewriteTableException { -return getMappings(Username.fromLocalPartWithDomain(user, domain), mappingLimit); +public Mappings getResolvedMappings(String user, Domain domain, EnumSet mappingTypes) throws ErrorMappingException, RecipientRewriteTableException { + +return getMappings(Username.fromLocalPartWithDomain(user, domain), mappingLimit, mappingTypes); } -private Mappings getMappings(Username username, int mappingLimit) throws ErrorMappingException, RecipientRewriteTableException { +private Mappings getMappings(Username username, int mappingLimit, EnumSet mappingTypes) throws ErrorMappingException, RecipientRewriteTableException { // We have to much mappings throw ErrorMappingException to avoid // infinity loop @@ -113,23 +115,25 @@ public abstract class AbstractRecipientRewriteTable implements RecipientRewriteT throw new TooManyMappingException("554 Too many mappings to process"); } -Mappings targetMappings = mapAddress(username.getLocalPart(), username.getDomainPart().get()); - +Domain domain = username.getDomainPart().get(); +String localPart = username.getLocalPart(); +Stream targetMappings = mapAddress(localPart, domain).asStream() +.filter(mapping -> mappingTypes.contains(mapping.getType())); try {
[james-project] 01/21: JAMES-2917 Avoid specifying an unbounded count of routing keys
This is an automated email from the ASF dual-hosted git repository. rcordier pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/james-project.git commit a8765e445e7510a585ebe2b83ce0ef62c0c8259a Author: Benoit Tellier AuthorDate: Tue Feb 11 13:18:08 2020 +0700 JAMES-2917 Avoid specifying an unbounded count of routing keys Specifying too much routing keys can create ridiculously long URL for ElasticSearch requests that will eventually get rejected. 414 Request-URI Too Large Mitigation: omitting routing keys for searches on more than X mailboxes, X being a code defined constant. This will result in a search involving all shards by default. --- .../search/ElasticSearchSearcher.java | 23 ++- .../search/ElasticSearchSearcherTest.java | 171 + 2 files changed, 186 insertions(+), 8 deletions(-) diff --git a/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/search/ElasticSearchSearcher.java b/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/search/ElasticSearchSearcher.java index bd3e629..dc84cf9 100644 --- a/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/search/ElasticSearchSearcher.java +++ b/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/search/ElasticSearchSearcher.java @@ -53,6 +53,7 @@ public class ElasticSearchSearcher { private static final TimeValue TIMEOUT = TimeValue.timeValueMinutes(1); private static final ImmutableList STORED_FIELDS = ImmutableList.of(JsonMessageConstants.MAILBOX_ID, JsonMessageConstants.UID, JsonMessageConstants.MESSAGE_ID); +private static final int MAX_ROUTING_KEY = 5; private final RestHighLevelClient client; private final QueryConverter queryConverter; @@ -96,18 +97,24 @@ public class ElasticSearchSearcher { .map(SortConverter::convertSort) .forEach(searchSourceBuilder::sort); -return new SearchRequest(aliasName.getValue()) +SearchRequest request = new SearchRequest(aliasName.getValue()) .types(NodeMappingFactory.DEFAULT_MAPPING_NAME) .scroll(TIMEOUT) -.source(searchSourceBuilder) -.routing(toRoutingKeys(mailboxIds)); +.source(searchSourceBuilder); + +return toRoutingKey(mailboxIds) +.map(request::routing) +.orElse(request); } -private String[] toRoutingKeys(Collection mailboxIds) { -return mailboxIds.stream() -.map(routingKeyFactory::from) -.map(RoutingKey::asString) -.toArray(String[]::new); +private Optional toRoutingKey(Collection mailboxIds) { +if (mailboxIds.size() < MAX_ROUTING_KEY) { +return Optional.of(mailboxIds.stream() +.map(routingKeyFactory::from) +.map(RoutingKey::asString) +.toArray(String[]::new)); +} +return Optional.empty(); } private int computeRequiredSize(Optional limit) { diff --git a/mailbox/elasticsearch/src/test/java/org/apache/james/mailbox/elasticsearch/search/ElasticSearchSearcherTest.java b/mailbox/elasticsearch/src/test/java/org/apache/james/mailbox/elasticsearch/search/ElasticSearchSearcherTest.java new file mode 100644 index 000..f8be9a0 --- /dev/null +++ b/mailbox/elasticsearch/src/test/java/org/apache/james/mailbox/elasticsearch/search/ElasticSearchSearcherTest.java @@ -0,0 +1,171 @@ +/** + * * + * 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. * + ***/ + +package org.apache.james.mailbox.elasticsearch.search; + +import static org.assertj.core.api.Assertions.assertThat; + +import java.io.IOException; +import java.nio.charset.StandardCharsets; +import
[james-project] 02/21: JAMES-3032 add method to add/remove user alias with DataProbe
This is an automated email from the ASF dual-hosted git repository. rcordier pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/james-project.git commit 8e3954093649435f6925b0476962af9351cc4cb5 Author: Rémi KOWALSKI AuthorDate: Mon Feb 3 14:41:03 2020 +0100 JAMES-3032 add method to add/remove user alias with DataProbe --- .../src/main/java/org/apache/james/utils/DataProbeImpl.java | 6 ++ .../data-api/src/main/java/org/apache/james/probe/DataProbe.java| 2 ++ .../apache/james/rrt/api/RecipientRewriteTableManagementMBean.java | 5 + 3 files changed, 13 insertions(+) diff --git a/server/container/guice/guice-common/src/main/java/org/apache/james/utils/DataProbeImpl.java b/server/container/guice/guice-common/src/main/java/org/apache/james/utils/DataProbeImpl.java index 7fe0ccf..82f300f 100644 --- a/server/container/guice/guice-common/src/main/java/org/apache/james/utils/DataProbeImpl.java +++ b/server/container/guice/guice-common/src/main/java/org/apache/james/utils/DataProbeImpl.java @@ -112,6 +112,12 @@ public class DataProbeImpl implements GuiceProbe, DataProbe { } @Override +public void addUserAliasMapping(String fromUser, String fromDomain, String toAddress) throws Exception { +MappingSource source = MappingSource.fromUser(fromUser, fromDomain); +recipientRewriteTable.addAliasMapping(source, toAddress); +} + +@Override public void addDomainAliasMapping(String aliasDomain, String deliveryDomain) throws Exception { recipientRewriteTable.addAliasDomainMapping(MappingSource.fromDomain(Domain.of(aliasDomain)), Domain.of(deliveryDomain)); } diff --git a/server/data/data-api/src/main/java/org/apache/james/probe/DataProbe.java b/server/data/data-api/src/main/java/org/apache/james/probe/DataProbe.java index f680340..042baa8 100644 --- a/server/data/data-api/src/main/java/org/apache/james/probe/DataProbe.java +++ b/server/data/data-api/src/main/java/org/apache/james/probe/DataProbe.java @@ -73,5 +73,7 @@ public interface DataProbe { void addAddressMapping(String fromUser, String fromDomain, String toAddress) throws Exception; +void addUserAliasMapping(String fromUser, String fromDomain, String toAddress) throws Exception; + void addDomainAliasMapping(String aliasDomain, String deliveryDomain) throws Exception; } \ No newline at end of file diff --git a/server/data/data-api/src/main/java/org/apache/james/rrt/api/RecipientRewriteTableManagementMBean.java b/server/data/data-api/src/main/java/org/apache/james/rrt/api/RecipientRewriteTableManagementMBean.java index e49a162..a4b2462 100644 --- a/server/data/data-api/src/main/java/org/apache/james/rrt/api/RecipientRewriteTableManagementMBean.java +++ b/server/data/data-api/src/main/java/org/apache/james/rrt/api/RecipientRewriteTableManagementMBean.java @@ -59,6 +59,9 @@ public interface RecipientRewriteTableManagementMBean { /*** * Add address mapping that, for a user from@fromDomain would redirect * mails to toAddress + * + * Prefer using the specific methods addUserAliasMapping, addDomainMapping... + * which create an alias with a more specific Mapping.Type * * @param fromUser *the username. Null if no username should be used @@ -66,6 +69,7 @@ public interface RecipientRewriteTableManagementMBean { *the domain. Null if no domain should be used * @param toAddress *the address. + * */ void addAddressMapping(String fromUser, String fromDomain, String toAddress) throws Exception; @@ -77,6 +81,7 @@ public interface RecipientRewriteTableManagementMBean { * @param fromDomain *the domain. Null if no domain should be used * @param toAddress + * */ void removeAddressMapping(String fromUser, String fromDomain, String toAddress) throws Exception; - To unsubscribe, e-mail: server-dev-unsubscr...@james.apache.org For additional commands, e-mail: server-dev-h...@james.apache.org
[james-project] 09/21: [Refactoring] Improve Append command parser readability
This is an automated email from the ASF dual-hosted git repository. rcordier pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/james-project.git commit ace778f57448ca34458e00382fbf0ecc3b7192d3 Author: Benoit Tellier AuthorDate: Fri Dec 13 07:40:49 2019 +0100 [Refactoring] Improve Append command parser readability --- .../imap/decode/parser/AppendCommandParser.java| 24 -- 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/protocols/imap/src/main/java/org/apache/james/imap/decode/parser/AppendCommandParser.java b/protocols/imap/src/main/java/org/apache/james/imap/decode/parser/AppendCommandParser.java index a64259c..239fa80 100644 --- a/protocols/imap/src/main/java/org/apache/james/imap/decode/parser/AppendCommandParser.java +++ b/protocols/imap/src/main/java/org/apache/james/imap/decode/parser/AppendCommandParser.java @@ -44,42 +44,34 @@ public class AppendCommandParser extends AbstractImapCommandParser { /** * If the next character in the request is a '(', tries to read a - * "flag_list" argument from the request. If not, returns a MessageFlags + * "flag_list" argument from the request. If not, returns a Flags * with no flags set. */ -public Flags optionalAppendFlags(ImapRequestLineReader request) throws DecodingException { +private Flags parseFlags(ImapRequestLineReader request) throws DecodingException { char next = request.nextWordChar(); if (next == '(') { return request.flagList(); -} else { -return null; } +return new Flags(); } /** * If the next character in the request is a '"', tries to read a DateTime - * argument. If not, returns null. + * argument. If not, returns now. */ -public LocalDateTime optionalDateTime(ImapRequestLineReader request) throws DecodingException { +private LocalDateTime parseDateTime(ImapRequestLineReader request) throws DecodingException { char next = request.nextWordChar(); if (next == '"') { return request.dateTime(); -} else { -return null; } +return LocalDateTime.now(); } @Override protected ImapMessage decode(ImapRequestLineReader request, Tag tag, ImapSession session) throws DecodingException { String mailboxName = request.mailbox(); -Flags flags = optionalAppendFlags(request); -if (flags == null) { -flags = new Flags(); -} -LocalDateTime datetime = optionalDateTime(request); -if (datetime == null) { -datetime = LocalDateTime.now(); -} +Flags flags = parseFlags(request); +LocalDateTime datetime = parseDateTime(request); request.nextWordChar(); return new AppendRequest(mailboxName, flags, Date.from(datetime.atZone(ZoneId.systemDefault()).toInstant()), request.consumeLiteral(true), tag); - To unsubscribe, e-mail: server-dev-unsubscr...@james.apache.org For additional commands, e-mail: server-dev-h...@james.apache.org
[james-project] 20/21: [REFACTORING] s/StringValidator/StringMatcherCharacterValidator/
This is an automated email from the ASF dual-hosted git repository. rcordier pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/james-project.git commit aaf61a9f0c328e74715844b14be183335f06bfd0 Author: Benoit Tellier AuthorDate: Thu Jan 16 14:19:25 2020 +0700 [REFACTORING] s/StringValidator/StringMatcherCharacterValidator/ --- .../james/imap/decode/ImapRequestLineReader.java| 21 +++-- .../parser/AbstractSelectionCommandParser.java | 6 +++--- .../imap/decode/parser/FetchCommandParser.java | 6 +++--- .../imap/decode/parser/StoreCommandParser.java | 4 ++-- ...ava => StringMatcherCharacterValidatorTest.java} | 16 5 files changed, 27 insertions(+), 26 deletions(-) diff --git a/protocols/imap/src/main/java/org/apache/james/imap/decode/ImapRequestLineReader.java b/protocols/imap/src/main/java/org/apache/james/imap/decode/ImapRequestLineReader.java index 79f5a1b..ac0e7d9 100644 --- a/protocols/imap/src/main/java/org/apache/james/imap/decode/ImapRequestLineReader.java +++ b/protocols/imap/src/main/java/org/apache/james/imap/decode/ImapRequestLineReader.java @@ -31,7 +31,6 @@ import java.nio.charset.CodingErrorAction; import java.time.LocalDateTime; import java.util.ArrayList; import java.util.List; -import java.util.function.BiPredicate; import javax.mail.Flags; @@ -818,31 +817,33 @@ public abstract class ImapRequestLineReader { /** * Verifies subsequent characters match a specified string */ -public static class StringValidator implements CharacterValidator { -public static StringValidator caseIncentive(String expectedString) { -return new StringValidator(expectedString, -(c1, c2) -> isaBoolean(c1, c2)); +public static class StringMatcherCharacterValidator implements CharacterValidator { +public static StringMatcherCharacterValidator ignoreCase(String expectedString) { +return new StringMatcherCharacterValidator(expectedString); } -public static boolean isaBoolean(Character c1, Character c2) { +static boolean asciiEqualsIgnoringCase(Character c1, Character c2) { return Character.toUpperCase(c1) == Character.toUpperCase(c2); } private final String expectedString; -private final BiPredicate equalityTester; private int position = 0; -private StringValidator(String expectedString, BiPredicate equalityTester) { +private StringMatcherCharacterValidator(String expectedString) { this.expectedString = expectedString; -this.equalityTester = equalityTester; } +/** + * Verifies whether the next character is valid or not. + * + * This call will mutate StringValidator internal state, making it progress to following character validation. + */ @Override public boolean isValid(char chr) { if (position >= expectedString.length()) { return false; } else { -return equalityTester.test(chr, expectedString.charAt(position++)); +return asciiEqualsIgnoringCase(chr, expectedString.charAt(position++)); } } } diff --git a/protocols/imap/src/main/java/org/apache/james/imap/decode/parser/AbstractSelectionCommandParser.java b/protocols/imap/src/main/java/org/apache/james/imap/decode/parser/AbstractSelectionCommandParser.java index 758cb8b..3933c5e 100644 --- a/protocols/imap/src/main/java/org/apache/james/imap/decode/parser/AbstractSelectionCommandParser.java +++ b/protocols/imap/src/main/java/org/apache/james/imap/decode/parser/AbstractSelectionCommandParser.java @@ -29,7 +29,7 @@ import org.apache.james.imap.api.message.response.StatusResponseFactory; import org.apache.james.imap.api.process.ImapSession; import org.apache.james.imap.decode.DecodingException; import org.apache.james.imap.decode.ImapRequestLineReader; -import org.apache.james.imap.decode.ImapRequestLineReader.StringValidator; +import org.apache.james.imap.decode.ImapRequestLineReader.StringMatcherCharacterValidator; import org.apache.james.imap.decode.base.AbstractImapCommandParser; import org.apache.james.imap.message.request.AbstractMailboxSelectionRequest; import org.apache.james.mailbox.MessageUid; @@ -67,12 +67,12 @@ public abstract class AbstractSelectionCommandParser extends AbstractImapCommand switch (n) { case 'C': // It starts with C so it should be CONDSTORE -request.consumeWord(StringValidator.caseIncentive(CONDSTORE)); + request.consumeWord(StringMatcherCharacterValidator.ignoreCase(CONDSTORE)); condstore = true; break; case 'Q': // It starts with Q so it should be QRESYNC -
[james-project] 14/21: [Refactoring] Improve StringValidator
This is an automated email from the ASF dual-hosted git repository. rcordier pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/james-project.git commit 9c4c26d5a0f0039150786f78f40102b296d231e1 Author: Benoit Tellier AuthorDate: Thu Dec 19 14:35:58 2019 +0700 [Refactoring] Improve StringValidator --- .../james/imap/decode/ImapRequestLineReader.java | 26 --- .../parser/AbstractSelectionCommandParser.java | 4 +- .../imap/decode/parser/FetchCommandParser.java | 4 +- .../imap/decode/parser/StoreCommandParser.java | 2 +- .../james/imap/decode/StringValidatorTest.java | 54 ++ 5 files changed, 79 insertions(+), 11 deletions(-) diff --git a/protocols/imap/src/main/java/org/apache/james/imap/decode/ImapRequestLineReader.java b/protocols/imap/src/main/java/org/apache/james/imap/decode/ImapRequestLineReader.java index 1501634..79f5a1b 100644 --- a/protocols/imap/src/main/java/org/apache/james/imap/decode/ImapRequestLineReader.java +++ b/protocols/imap/src/main/java/org/apache/james/imap/decode/ImapRequestLineReader.java @@ -28,10 +28,10 @@ import java.nio.charset.Charset; import java.nio.charset.CharsetDecoder; import java.nio.charset.CoderResult; import java.nio.charset.CodingErrorAction; -import java.nio.charset.StandardCharsets; import java.time.LocalDateTime; import java.util.ArrayList; import java.util.List; +import java.util.function.BiPredicate; import javax.mail.Flags; @@ -815,20 +815,34 @@ public abstract class ImapRequestLineReader { boolean isValid(char chr); } +/** + * Verifies subsequent characters match a specified string + */ public static class StringValidator implements CharacterValidator { -private final byte[] expectedStringAsBytes; +public static StringValidator caseIncentive(String expectedString) { +return new StringValidator(expectedString, +(c1, c2) -> isaBoolean(c1, c2)); +} + +public static boolean isaBoolean(Character c1, Character c2) { +return Character.toUpperCase(c1) == Character.toUpperCase(c2); +} + +private final String expectedString; +private final BiPredicate equalityTester; private int position = 0; -public StringValidator(String expectedString) { -this.expectedStringAsBytes = expectedString.getBytes(StandardCharsets.US_ASCII); +private StringValidator(String expectedString, BiPredicate equalityTester) { +this.expectedString = expectedString; +this.equalityTester = equalityTester; } @Override public boolean isValid(char chr) { -if (position >= expectedStringAsBytes.length) { +if (position >= expectedString.length()) { return false; } else { -return ImapRequestLineReader.cap(chr) == expectedStringAsBytes[position++]; +return equalityTester.test(chr, expectedString.charAt(position++)); } } } diff --git a/protocols/imap/src/main/java/org/apache/james/imap/decode/parser/AbstractSelectionCommandParser.java b/protocols/imap/src/main/java/org/apache/james/imap/decode/parser/AbstractSelectionCommandParser.java index 812cdfc..758cb8b 100644 --- a/protocols/imap/src/main/java/org/apache/james/imap/decode/parser/AbstractSelectionCommandParser.java +++ b/protocols/imap/src/main/java/org/apache/james/imap/decode/parser/AbstractSelectionCommandParser.java @@ -67,12 +67,12 @@ public abstract class AbstractSelectionCommandParser extends AbstractImapCommand switch (n) { case 'C': // It starts with C so it should be CONDSTORE -request.consumeWord(new StringValidator(CONDSTORE)); +request.consumeWord(StringValidator.caseIncentive(CONDSTORE)); condstore = true; break; case 'Q': // It starts with Q so it should be QRESYNC -request.consumeWord(new StringValidator(QRESYNC)); +request.consumeWord(StringValidator.caseIncentive(QRESYNC)); // Consume the SP request.consumeChar(' '); diff --git a/protocols/imap/src/main/java/org/apache/james/imap/decode/parser/FetchCommandParser.java b/protocols/imap/src/main/java/org/apache/james/imap/decode/parser/FetchCommandParser.java index 1fc1412..6844374 100644 --- a/protocols/imap/src/main/java/org/apache/james/imap/decode/parser/FetchCommandParser.java +++ b/protocols/imap/src/main/java/org/apache/james/imap/decode/parser/FetchCommandParser.java @@ -89,12 +89,12 @@ public class FetchCommandParser extends AbstractUidCommandParser { switch (next) { case 'C': // Now check for the CHANGEDSINCE option which is part of CONDSTORE -
[james-project] 05/21: JAMES-3032 bind class to used to know if a user can send from a given adress
This is an automated email from the ASF dual-hosted git repository. rcordier pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/james-project.git commit 90dfded56f60e28408b381760590fbf8b4c68fcf Author: Rémi KOWALSKI AuthorDate: Tue Feb 4 17:00:31 2020 +0100 JAMES-3032 bind class to used to know if a user can send from a given adress --- .../src/main/java/org/apache/james/jmap/draft/JMAPCommonModule.java | 4 1 file changed, 4 insertions(+) diff --git a/server/container/guice/protocols/jmap-draft/src/main/java/org/apache/james/jmap/draft/JMAPCommonModule.java b/server/container/guice/protocols/jmap-draft/src/main/java/org/apache/james/jmap/draft/JMAPCommonModule.java index 34184a7..e53b9cd 100644 --- a/server/container/guice/protocols/jmap-draft/src/main/java/org/apache/james/jmap/draft/JMAPCommonModule.java +++ b/server/container/guice/protocols/jmap-draft/src/main/java/org/apache/james/jmap/draft/JMAPCommonModule.java @@ -43,6 +43,8 @@ import org.apache.james.jmap.draft.utils.HeadersAuthenticationExtractor; import org.apache.james.jmap.event.ComputeMessageFastViewProjectionListener; import org.apache.james.lifecycle.api.StartUpCheck; import org.apache.james.mailbox.events.MailboxListener; +import org.apache.james.rrt.api.CanSendFrom; +import org.apache.james.rrt.lib.CanSendFromImpl; import org.apache.james.util.date.DefaultZonedDateTimeProvider; import org.apache.james.util.date.ZonedDateTimeProvider; import org.apache.james.util.mime.MessageContentExtractor; @@ -78,6 +80,8 @@ public class JMAPCommonModule extends AbstractModule { bind(MessageHeaderViewFactory.class).in(Scopes.SINGLETON); bind(MessageFastViewFactory.class).in(Scopes.SINGLETON); +bind(CanSendFrom.class).to(CanSendFromImpl.class).in(Scopes.SINGLETON); + bind(MessageContentExtractor.class).in(Scopes.SINGLETON); bind(HeadersAuthenticationExtractor.class).in(Scopes.SINGLETON); bind(SecurityKeyLoader.class).in(Scopes.SINGLETON); - To unsubscribe, e-mail: server-dev-unsubscr...@james.apache.org For additional commands, e-mail: server-dev-h...@james.apache.org
[james-project] 12/21: [Refactoring] (slightly) Improve Fetch command parser readability
This is an automated email from the ASF dual-hosted git repository. rcordier pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/james-project.git commit 91d95874c9fc23e48a42e55f849eecb9ab065376 Author: Benoit Tellier AuthorDate: Fri Dec 13 07:43:34 2019 +0100 [Refactoring] (slightly) Improve Fetch command parser readability --- .../imap/decode/parser/FetchCommandParser.java | 41 +- 1 file changed, 8 insertions(+), 33 deletions(-) diff --git a/protocols/imap/src/main/java/org/apache/james/imap/decode/parser/FetchCommandParser.java b/protocols/imap/src/main/java/org/apache/james/imap/decode/parser/FetchCommandParser.java index c51ca96..1fc1412 100644 --- a/protocols/imap/src/main/java/org/apache/james/imap/decode/parser/FetchCommandParser.java +++ b/protocols/imap/src/main/java/org/apache/james/imap/decode/parser/FetchCommandParser.java @@ -42,15 +42,15 @@ import org.apache.james.imap.api.process.ImapSession; import org.apache.james.imap.decode.DecodingException; import org.apache.james.imap.decode.FetchPartPathDecoder; import org.apache.james.imap.decode.ImapRequestLineReader; -import org.apache.james.imap.decode.ImapRequestLineReader.CharacterValidator; +import org.apache.james.imap.decode.ImapRequestLineReader.StringValidator; import org.apache.james.imap.message.request.FetchRequest; /** * Parse FETCH commands */ public class FetchCommandParser extends AbstractUidCommandParser { -private static final byte[] CHANGEDSINCE = "CHANGEDSINCE".getBytes(); -private static final byte[] VANISHED = "VANISHED".getBytes(); +private static final String CHANGEDSINCE = "CHANGEDSINCE"; +private static final String VANISHED = "VANISHED"; public FetchCommandParser(StatusResponseFactory statusResponseFactory) { super(ImapConstants.FETCH_COMMAND, statusResponseFactory); @@ -89,34 +89,12 @@ public class FetchCommandParser extends AbstractUidCommandParser { switch (next) { case 'C': // Now check for the CHANGEDSINCE option which is part of CONDSTORE -request.consumeWord(new CharacterValidator() { -int pos = 0; -@Override -public boolean isValid(char chr) { -if (pos > CHANGEDSINCE.length) { -return false; -} else { -return CHANGEDSINCE[pos++] == ImapRequestLineReader.cap(chr); -} -} -}); +request.consumeWord(new StringValidator(CHANGEDSINCE)); fetch.changedSince(request.number(true)); - break; - case 'V': // Check for the VANISHED option which is part of QRESYNC -request.consumeWord(new CharacterValidator() { -int pos = 0; -@Override -public boolean isValid(char chr) { -if (pos > VANISHED.length) { -return false; -} else { -return VANISHED[pos++] == ImapRequestLineReader.cap(chr); -} -} -}); +request.consumeWord(new StringValidator(VANISHED)); fetch.vanished(true); break; default: @@ -203,15 +181,12 @@ public class FetchCommandParser extends AbstractUidCommandParser { } private boolean isPeek(String name) throws DecodingException { -final boolean isPeek; if ("BODY".equalsIgnoreCase(name)) { -isPeek = false; +return false; } else if ("BODY.PEEK".equalsIgnoreCase(name)) { -isPeek = true; -} else { -throw new DecodingException(HumanReadableText.ILLEGAL_ARGUMENTS, "Invalid fetch attibute: " + name + "[]"); +return true; } -return isPeek; +throw new DecodingException(HumanReadableText.ILLEGAL_ARGUMENTS, "Invalid fetch attibute: " + name + "[]"); } private BodyFetchElement createBodyElement(String parameter, Long firstOctet, Long numberOfOctets) throws DecodingException { - To unsubscribe, e-mail: server-dev-unsubscr...@james.apache.org For additional commands, e-mail: server-dev-h...@james.apache.org
[james-project] branch master updated (d8bcd44 -> 1176599)
This is an automated email from the ASF dual-hosted git repository. rcordier pushed a change to branch master in repository https://gitbox.apache.org/repos/asf/james-project.git. from d8bcd44 JAMES-3043 IMAP selected mailbox checks should rely on mailboxId new a8765e4 JAMES-2917 Avoid specifying an unbounded count of routing keys new 8e39540 JAMES-3032 add method to add/remove user alias with DataProbe new 47597b8 JAMES-3032 add the possibility to add a group alias in DataProbe new 03cfc8d JAMES-3032 add a class to check if a user can senda a mail from a given address new 90dfded JAMES-3032 bind class to used to know if a user can send from a given adress new fafe4ee JAMES-3032 allow user to send an email with a from address containing one of her alias new 441d729 JAMES-3032 allow user to send a mail from an alias, allow alias in SetMessageUpdateProcessor new 4c8009d [Refactoring] Add a StringValidator new ace778f [Refactoring] Improve Append command parser readability new ad63013 [Refactoring] Improve Expunge command parser readability new 24c3d04 [Refactoring] Improve Store command parser readability new 91d9587 [Refactoring] (slightly) Improve Fetch command parser readability new ba43a3e [Refactoring] (slightly) Improve Select command parser readability new 9c4c26d [Refactoring] Improve StringValidator new 1b160ba [Refactoring] StoreCommandParser should not use final variables new 30d00ac [Refactoring] Tests for StoreCommandParser::parseDateTime new fbca73d [REFACTORING] Use switch instead of chained 'if' within FetchCommandParser new 06038c8 [REFACTORING] Remove final variable in FetchCommandParser new 4dd7fbe [REFACTORING] Use switch instead of chained 'if' within StoreCommandParser new aaf61a9 [REFACTORING] s/StringValidator/StringMatcherCharacterValidator/ new 1176599 JAMES-3039: Provision a LinShare technical user within James The 21 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "add" were already present in the repository and have only been added to this reference. Summary of changes: .../search/ElasticSearchSearcher.java | 23 ++- .../search/ElasticSearchSearcherTest.java | 171 + .../james/imap/decode/ImapRequestLineReader.java | 34 .../parser/AbstractSelectionCommandParser.java | 26 +-- .../imap/decode/parser/AppendCommandParser.java| 33 ++-- .../imap/decode/parser/ExpungeCommandParser.java | 11 +- .../imap/decode/parser/FetchCommandParser.java | 132 ++--- .../imap/decode/parser/ImapParserFactory.java | 3 +- .../imap/decode/parser/StoreCommandParser.java | 77 .../StringMatcherCharacterValidatorTest.java | 44 ++--- .../decode/parser/AppendCommandParserTest.java | 87 + .../java/org/apache/james/utils/DataProbeImpl.java | 12 ++ .../apache/james/jmap/draft/JMAPCommonModule.java | 4 + .../java/org/apache/james/probe/DataProbe.java | 4 + .../java/org/apache/james/rrt/api/CanSendFrom.java | 16 +- .../james/rrt/api/RecipientRewriteTable.java | 10 +- .../api/RecipientRewriteTableManagementMBean.java | 5 + .../apache/james/rrt/lib/CanSendFromContract.java | 96 ++ .../rrt/lib/AbstractRecipientRewriteTable.java | 30 +-- .../org/apache/james/rrt/lib/CanSendFromImpl.java | 63 ++ server/data/data-memory/pom.xml| 5 + .../apache/james/rrt/lib/CanSendFromImplTest.java | 72 +++ .../methods/integration/SetMessagesMethodTest.java | 182 +- server/protocols/jmap-draft/pom.xml| 5 + .../methods/SetMessagesCreationProcessor.java | 33 ++-- .../draft/methods/SetMessagesUpdateProcessor.java | 23 ++- .../methods/SetMessagesCreationProcessorTest.java | 120 +++- .../methods/SetMessagesUpdateProcessorTest.java| 211 +++-- .../apache/james/jmap/JMAPTestingConstants.java| 1 + .../apache/james/linshare/LinshareExtension.java | 36 +++- .../org/apache/james/linshare/LinshareFixture.java | 7 + .../org/apache/james/linshare/LinshareTest.java| 19 ++ .../client/TechnicalAccountCreationRequest.java| 67 +++ .../TechnicalAccountGrantPermissionsRequest.java | 65 +++ .../linshare/client/TechnicalAccountResponse.java | 57 +++--- 35 files changed, 1425 insertions(+), 359 deletions(-) create mode 100644 mailbox/elasticsearch/src/test/java/org/apache/james/mailbox/elasticsearch/search/ElasticSearchSearcherTest.java copy server/data/data-api/src/test/java/org/apache/james/rrt/lib/ReplaceRewriterTest.java => protocols/imap/src/test/java/org/apache/james/imap/decode/StringMatcherCharacterValidatorTest.java (54%) create mode 100644
[james-project] 17/21: [REFACTORING] Use switch instead of chained 'if' within FetchCommandParser
This is an automated email from the ASF dual-hosted git repository. rcordier pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/james-project.git commit fbca73d58310ed69fd093c47b352d45b1e7bc961 Author: Benoit Tellier AuthorDate: Tue Jan 14 09:48:47 2020 +0700 [REFACTORING] Use switch instead of chained 'if' within FetchCommandParser --- .../imap/decode/parser/FetchCommandParser.java | 81 -- 1 file changed, 45 insertions(+), 36 deletions(-) diff --git a/protocols/imap/src/main/java/org/apache/james/imap/decode/parser/FetchCommandParser.java b/protocols/imap/src/main/java/org/apache/james/imap/decode/parser/FetchCommandParser.java index 6844374..864ffa3 100644 --- a/protocols/imap/src/main/java/org/apache/james/imap/decode/parser/FetchCommandParser.java +++ b/protocols/imap/src/main/java/org/apache/james/imap/decode/parser/FetchCommandParser.java @@ -28,6 +28,7 @@ import static org.apache.james.imap.api.message.FetchData.Item.SIZE; import static org.apache.james.imap.api.message.FetchData.Item.UID; import java.util.List; +import java.util.Locale; import org.apache.james.imap.api.ImapConstants; import org.apache.james.imap.api.ImapMessage; @@ -119,37 +120,7 @@ public class FetchCommandParser extends AbstractUidCommandParser { char next = reader.nextChar(); // Simple elements with no '[]' parameters. if (next != '[') { -if ("FAST".equalsIgnoreCase(name)) { -fetch.fetch(FLAGS, INTERNAL_DATE, SIZE); -} else if ("FULL".equalsIgnoreCase(name)) { -fetch.fetch(FLAGS, INTERNAL_DATE, SIZE, ENVELOPE, BODY); -} else if ("ALL".equalsIgnoreCase(name)) { -fetch.fetch(FLAGS, INTERNAL_DATE, SIZE, ENVELOPE); -} else if ("FLAGS".equalsIgnoreCase(name)) { -fetch.fetch(FLAGS); -} else if ("RFC822.SIZE".equalsIgnoreCase(name)) { -fetch.fetch(SIZE); -} else if ("ENVELOPE".equalsIgnoreCase(name)) { -fetch.fetch(ENVELOPE); -} else if ("INTERNALDATE".equalsIgnoreCase(name)) { -fetch.fetch(INTERNAL_DATE); -} else if ("BODY".equalsIgnoreCase(name)) { -fetch.fetch(BODY); -} else if ("BODYSTRUCTURE".equalsIgnoreCase(name)) { -fetch.fetch(BODY_STRUCTURE); -} else if ("UID".equalsIgnoreCase(name)) { -fetch.fetch(UID); -} else if ("RFC822".equalsIgnoreCase(name)) { -fetch.add(BodyFetchElement.createRFC822(), false); -} else if ("RFC822.HEADER".equalsIgnoreCase(name)) { -fetch.add(BodyFetchElement.createRFC822Header(), true); -} else if ("RFC822.TEXT".equalsIgnoreCase(name)) { -fetch.add(BodyFetchElement.createRFC822Text(), false); -} else if ("MODSEQ".equalsIgnoreCase(name)) { -fetch.fetch(MODSEQ); -} else { -throw new DecodingException(HumanReadableText.ILLEGAL_ARGUMENTS, "Invalid fetch attribute: " + name); -} +addNextName(fetch, name); } else { reader.consumeChar('['); @@ -180,13 +151,51 @@ public class FetchCommandParser extends AbstractUidCommandParser { } } +private FetchData.Builder addNextName(FetchData.Builder fetch, String name) throws DecodingException { +String capitalizedName = name.toUpperCase(Locale.US); +switch (capitalizedName) { +case "FAST": +return fetch.fetch(FLAGS, INTERNAL_DATE, SIZE); +case "FULL": +return fetch.fetch(FLAGS, INTERNAL_DATE, SIZE, ENVELOPE, BODY); +case "ALL": +return fetch.fetch(FLAGS, INTERNAL_DATE, SIZE, ENVELOPE); +case "FLAGS": +return fetch.fetch(FLAGS); +case "RFC822.SIZE": +return fetch.fetch(SIZE); +case "ENVELOPE": +return fetch.fetch(ENVELOPE); +case "INTERNALDATE": +return fetch.fetch(INTERNAL_DATE); +case "BODY": +return fetch.fetch(BODY); +case "BODYSTRUCTURE": +return fetch.fetch(BODY_STRUCTURE); +case "UID": +return fetch.fetch(UID); +case "RFC822": +return fetch.add(BodyFetchElement.createRFC822(), false); +case "RFC822.HEADER": +return fetch.add(BodyFetchElement.createRFC822Header(), true); +case "RFC822.TEXT": +return fetch.add(BodyFetchElement.createRFC822Text(), false); +case "MODSEQ": +return fetch.fetch(MODSEQ); +default: +throw new DecodingException(HumanReadableText.ILLEGAL_ARGUMENTS, "Invalid fetch attribute: " + name); +} +} + private
[james-project] 15/21: [Refactoring] StoreCommandParser should not use final variables
This is an automated email from the ASF dual-hosted git repository. rcordier pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/james-project.git commit 1b160ba3d77bf0c465eaaf2a5fc31d042d1cdf07 Author: Benoit Tellier AuthorDate: Thu Dec 19 14:37:48 2019 +0700 [Refactoring] StoreCommandParser should not use final variables --- .../org/apache/james/imap/decode/parser/StoreCommandParser.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/protocols/imap/src/main/java/org/apache/james/imap/decode/parser/StoreCommandParser.java b/protocols/imap/src/main/java/org/apache/james/imap/decode/parser/StoreCommandParser.java index c8fce8e..a00df86 100644 --- a/protocols/imap/src/main/java/org/apache/james/imap/decode/parser/StoreCommandParser.java +++ b/protocols/imap/src/main/java/org/apache/james/imap/decode/parser/StoreCommandParser.java @@ -46,7 +46,7 @@ public class StoreCommandParser extends AbstractUidCommandParser { @Override protected ImapMessage decode(ImapRequestLineReader request, Tag tag, boolean useUids, ImapSession session) throws DecodingException { -final IdRange[] idSet = request.parseIdRange(session); +IdRange[] idSet = request.parseIdRange(session); long unchangedSince = -1; char next = request.nextWordChar(); if (next == '(') { @@ -63,7 +63,7 @@ public class StoreCommandParser extends AbstractUidCommandParser { MessageManager.FlagsUpdateMode flagsUpdateMode = parseFlagsUpdateMode(request, next); String directive = request.consumeWord(new ImapRequestLineReader.NoopCharValidator()); boolean silent = parseSilent(directive); -final Flags flags = parseFlags(request); +Flags flags = parseFlags(request); request.eol(); return new StoreRequest(idSet, silent, flags, useUids, tag, flagsUpdateMode, unchangedSince); @@ -72,7 +72,7 @@ public class StoreCommandParser extends AbstractUidCommandParser { private Flags parseFlags(ImapRequestLineReader request) throws DecodingException { // Handle all kind of "store-att-flags" // See IMAP-281 -final Flags flags = new Flags(); +Flags flags = new Flags(); if (request.nextWordChar() == '(') { flags.add(request.flagList()); } else { - To unsubscribe, e-mail: server-dev-unsubscr...@james.apache.org For additional commands, e-mail: server-dev-h...@james.apache.org
[james-project] 11/21: [Refactoring] Improve Store command parser readability
This is an automated email from the ASF dual-hosted git repository. rcordier pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/james-project.git commit 24c3d046177d51e2fd4a13cc267333a91d181532 Author: Benoit Tellier AuthorDate: Fri Dec 13 07:41:29 2019 +0100 [Refactoring] Improve Store command parser readability --- .../imap/decode/parser/StoreCommandParser.java | 70 +++--- 1 file changed, 35 insertions(+), 35 deletions(-) diff --git a/protocols/imap/src/main/java/org/apache/james/imap/decode/parser/StoreCommandParser.java b/protocols/imap/src/main/java/org/apache/james/imap/decode/parser/StoreCommandParser.java index 807385c..60c03d3 100644 --- a/protocols/imap/src/main/java/org/apache/james/imap/decode/parser/StoreCommandParser.java +++ b/protocols/imap/src/main/java/org/apache/james/imap/decode/parser/StoreCommandParser.java @@ -29,7 +29,7 @@ import org.apache.james.imap.api.message.response.StatusResponseFactory; import org.apache.james.imap.api.process.ImapSession; import org.apache.james.imap.decode.DecodingException; import org.apache.james.imap.decode.ImapRequestLineReader; -import org.apache.james.imap.decode.ImapRequestLineReader.CharacterValidator; +import org.apache.james.imap.decode.ImapRequestLineReader.StringValidator; import org.apache.james.imap.message.request.StoreRequest; import org.apache.james.mailbox.MessageManager; @@ -38,7 +38,7 @@ import org.apache.james.mailbox.MessageManager; */ public class StoreCommandParser extends AbstractUidCommandParser { -private static final byte[] UNCHANGEDSINCE = "UNCHANGEDSINCE".getBytes(); +private static final String UNCHANGEDSINCE = "UNCHANGEDSINCE"; public StoreCommandParser(StatusResponseFactory statusResponseFactory) { super(ImapConstants.STORE_COMMAND, statusResponseFactory); @@ -47,50 +47,29 @@ public class StoreCommandParser extends AbstractUidCommandParser { @Override protected ImapMessage decode(ImapRequestLineReader request, Tag tag, boolean useUids, ImapSession session) throws DecodingException { final IdRange[] idSet = request.parseIdRange(session); -boolean silent = false; long unchangedSince = -1; char next = request.nextWordChar(); if (next == '(') { // Seems like we have a CONDSTORE parameter request.consume(); - -request.consumeWord(new CharacterValidator() { -private int pos = 0; -@Override -public boolean isValid(char chr) { -if (pos >= UNCHANGEDSINCE.length) { -return false; -} else { -return ImapRequestLineReader.cap(chr) == UNCHANGEDSINCE[pos++]; -} -} -}); + +request.consumeWord(new StringValidator(UNCHANGEDSINCE)); request.consumeChar(' '); unchangedSince = request.number(true); request.consumeChar(')'); next = request.nextWordChar(); } -final MessageManager.FlagsUpdateMode flagsUpdateMode; -if (next == '+') { -flagsUpdateMode = MessageManager.FlagsUpdateMode.ADD; -request.consume(); -} else if (next == '-') { -flagsUpdateMode = MessageManager.FlagsUpdateMode.REMOVE; -request.consume(); -} else { -flagsUpdateMode = MessageManager.FlagsUpdateMode.REPLACE; -} - +MessageManager.FlagsUpdateMode flagsUpdateMode = parseFlagsUpdateMode(request, next); String directive = request.consumeWord(new ImapRequestLineReader.NoopCharValidator()); -if ("FLAGS".equalsIgnoreCase(directive)) { -silent = false; -} else if ("FLAGS.SILENT".equalsIgnoreCase(directive)) { -silent = true; -} else { -throw new DecodingException(HumanReadableText.ILLEGAL_ARGUMENTS, "Invalid Store Directive: '" + directive + "'"); -} +boolean silent = parseSilent(directive); +final Flags flags = parseFlags(request); +request.eol(); +return new StoreRequest(idSet, silent, flags, useUids, tag, flagsUpdateMode, unchangedSince); +} + +private Flags parseFlags(ImapRequestLineReader request) throws DecodingException { // Handle all kind of "store-att-flags" // See IMAP-281 final Flags flags = new Flags(); @@ -108,8 +87,29 @@ public class StoreCommandParser extends AbstractUidCommandParser { } } } +return flags; +} -request.eol(); -return new StoreRequest(idSet, silent, flags, useUids, tag, flagsUpdateMode, unchangedSince); +private boolean parseSilent(String directive) throws DecodingException { +if ("FLAGS".equalsIgnoreCase(directive)) { +return false; +
[james-project] 03/21: JAMES-3032 add the possibility to add a group alias in DataProbe
This is an automated email from the ASF dual-hosted git repository. rcordier pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/james-project.git commit 47597b827788d31729932bce02c24536a9643e70 Author: Rémi KOWALSKI AuthorDate: Mon Feb 3 15:30:27 2020 +0100 JAMES-3032 add the possibility to add a group alias in DataProbe --- .../src/main/java/org/apache/james/utils/DataProbeImpl.java | 6 ++ .../data-api/src/main/java/org/apache/james/probe/DataProbe.java| 2 ++ 2 files changed, 8 insertions(+) diff --git a/server/container/guice/guice-common/src/main/java/org/apache/james/utils/DataProbeImpl.java b/server/container/guice/guice-common/src/main/java/org/apache/james/utils/DataProbeImpl.java index 82f300f..8381e0b 100644 --- a/server/container/guice/guice-common/src/main/java/org/apache/james/utils/DataProbeImpl.java +++ b/server/container/guice/guice-common/src/main/java/org/apache/james/utils/DataProbeImpl.java @@ -25,6 +25,7 @@ import java.util.Map; import javax.inject.Inject; import org.apache.james.core.Domain; +import org.apache.james.core.MailAddress; import org.apache.james.core.Username; import org.apache.james.domainlist.api.DomainList; import org.apache.james.probe.DataProbe; @@ -121,4 +122,9 @@ public class DataProbeImpl implements GuiceProbe, DataProbe { public void addDomainAliasMapping(String aliasDomain, String deliveryDomain) throws Exception { recipientRewriteTable.addAliasDomainMapping(MappingSource.fromDomain(Domain.of(aliasDomain)), Domain.of(deliveryDomain)); } + +@Override +public void addGroupAliasMapping(String fromGroup, String toAddress) throws Exception { + recipientRewriteTable.addGroupMapping(MappingSource.fromMailAddress(new MailAddress(fromGroup)), toAddress); +} } \ No newline at end of file diff --git a/server/data/data-api/src/main/java/org/apache/james/probe/DataProbe.java b/server/data/data-api/src/main/java/org/apache/james/probe/DataProbe.java index 042baa8..3b79c98 100644 --- a/server/data/data-api/src/main/java/org/apache/james/probe/DataProbe.java +++ b/server/data/data-api/src/main/java/org/apache/james/probe/DataProbe.java @@ -76,4 +76,6 @@ public interface DataProbe { void addUserAliasMapping(String fromUser, String fromDomain, String toAddress) throws Exception; void addDomainAliasMapping(String aliasDomain, String deliveryDomain) throws Exception; + +void addGroupAliasMapping(String fromGroup, String toAddress) throws Exception; } \ No newline at end of file - To unsubscribe, e-mail: server-dev-unsubscr...@james.apache.org For additional commands, e-mail: server-dev-h...@james.apache.org
[GitHub] [james-hupa] dongxuwang commented on issue #1: [SECURITY] Use HTTPS to resolve dependencies in Maven Build
dongxuwang commented on issue #1: [SECURITY] Use HTTPS to resolve dependencies in Maven Build URL: https://github.com/apache/james-hupa/pull/1#issuecomment-585513582 Thanks @JLLeitschuh This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services - To unsubscribe, e-mail: server-dev-unsubscr...@james.apache.org For additional commands, e-mail: server-dev-h...@james.apache.org
[james-hupa] branch trunk updated: Use HTTPS instead of HTTP to resolve dependencies
This is an automated email from the ASF dual-hosted git repository. dongxu pushed a commit to branch trunk in repository https://gitbox.apache.org/repos/asf/james-hupa.git The following commit(s) were added to refs/heads/trunk by this push: new 1c0a2eb Use HTTPS instead of HTTP to resolve dependencies new 6d93850 Merge pull request #1 from JLLeitschuh/fix/JLL/use_https_to_resolve_dependencies 1c0a2eb is described below commit 1c0a2ebeaeb2c39e743940d8465349f8f6148365 Author: Jonathan Leitschuh AuthorDate: Mon Feb 10 19:05:34 2020 -0500 Use HTTPS instead of HTTP to resolve dependencies This fixes a security vulnerability in this project where the `pom.xml` files were configuring Maven to resolve dependencies over HTTP instead of HTTPS. Signed-off-by: Jonathan Leitschuh --- pom.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index a65ece7..d932e3b 100644 --- a/pom.xml +++ b/pom.xml @@ -335,15 +335,15 @@ repo1 -http://repo1.maven.org/maven2/ +https://repo1.maven.org/maven2/ JBoss repository -http://repository.jboss.org/nexus/content/groups/public/ + https://repository.jboss.org/nexus/content/groups/public/ sonatype - http://oss.sonatype.org/content/repositories/snapshots + https://oss.sonatype.org/content/repositories/snapshots true false - To unsubscribe, e-mail: server-dev-unsubscr...@james.apache.org For additional commands, e-mail: server-dev-h...@james.apache.org
[GitHub] [james-hupa] dongxuwang merged pull request #1: [SECURITY] Use HTTPS to resolve dependencies in Maven Build
dongxuwang merged pull request #1: [SECURITY] Use HTTPS to resolve dependencies in Maven Build URL: https://github.com/apache/james-hupa/pull/1 This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services - To unsubscribe, e-mail: server-dev-unsubscr...@james.apache.org For additional commands, e-mail: server-dev-h...@james.apache.org
Re: Ops experience: monitoring [mail processing - mailbox event processing] for distributed James product
+1 Le mer. 12 févr. 2020 à 12:01, Tellier Benoit a écrit : > Then an admin might miss the original log, if out of it's browsing window. > > However I agree the log could be done at a lower pace: > - Check every minute, log directly upon status change > - Otherwise re-log current status every 30 minutes > > On 12/02/2020 17:48, Antoine Duprat wrote: > > Shouldn't it be more logic to log only status changes ? > > > > I mean, if you are in a degraded state, you will log the same thing each > > minute else if you have fixed the issue. > > > > Le mer. 12 févr. 2020 à 11:43, Tellier Benoit a > > écrit : > > > >> +1 > >> > >> We should make this happen. > >> > >> On 12/02/2020 17:29, Matthieu Baechler wrote: > >>> On Wed, 2020-02-12 at 16:27 +0700, Tellier Benoit wrote: > >>> > - Through grafana, the admin will have the information directly > available. Nowaday, health-checks requires her to execute the > healthcheck via webadmin. More actions is generally the best way of > having none of them taken. > > >>> > >>> I just want to add, on that matter, that I already proposed to have a > >>> timer that logs health state to WARN when status is `degraded` and > >>> ERROR when status is `down` on a sensible time interval (like once a > >>> minute) and that would be enabled in our default configuration. > >>> > >>> That way the logs, which are the first and most basic tool any admin is > >>> looking at, would give you that very important information. > >>> > >>> Cheers, > >>> > >> > >> - > >> To unsubscribe, e-mail: server-dev-unsubscr...@james.apache.org > >> For additional commands, e-mail: server-dev-h...@james.apache.org > >> > >> > > > > - > To unsubscribe, e-mail: server-dev-unsubscr...@james.apache.org > For additional commands, e-mail: server-dev-h...@james.apache.org > >
Re: Ops experience: monitoring [mail processing - mailbox event processing] for distributed James product
Then an admin might miss the original log, if out of it's browsing window. However I agree the log could be done at a lower pace: - Check every minute, log directly upon status change - Otherwise re-log current status every 30 minutes On 12/02/2020 17:48, Antoine Duprat wrote: > Shouldn't it be more logic to log only status changes ? > > I mean, if you are in a degraded state, you will log the same thing each > minute else if you have fixed the issue. > > Le mer. 12 févr. 2020 à 11:43, Tellier Benoit a > écrit : > >> +1 >> >> We should make this happen. >> >> On 12/02/2020 17:29, Matthieu Baechler wrote: >>> On Wed, 2020-02-12 at 16:27 +0700, Tellier Benoit wrote: >>> - Through grafana, the admin will have the information directly available. Nowaday, health-checks requires her to execute the healthcheck via webadmin. More actions is generally the best way of having none of them taken. >>> >>> I just want to add, on that matter, that I already proposed to have a >>> timer that logs health state to WARN when status is `degraded` and >>> ERROR when status is `down` on a sensible time interval (like once a >>> minute) and that would be enabled in our default configuration. >>> >>> That way the logs, which are the first and most basic tool any admin is >>> looking at, would give you that very important information. >>> >>> Cheers, >>> >> >> - >> To unsubscribe, e-mail: server-dev-unsubscr...@james.apache.org >> For additional commands, e-mail: server-dev-h...@james.apache.org >> >> > - To unsubscribe, e-mail: server-dev-unsubscr...@james.apache.org For additional commands, e-mail: server-dev-h...@james.apache.org
[jira] [Created] (JAMES-3065) API projects should not make use of Reactor types
Matthieu Baechler created JAMES-3065: Summary: API projects should not make use of Reactor types Key: JAMES-3065 URL: https://issues.apache.org/jira/browse/JAMES-3065 Project: James Server Issue Type: Improvement Reporter: Matthieu Baechler James being built using Hexagonal Architecture, we usually don't use types from implementation libraries into our API projects. We should make sure we use {{Publisher}} instead of {{Mono}}/{{Flux}} -- This message was sent by Atlassian Jira (v8.3.4#803005) - To unsubscribe, e-mail: server-dev-unsubscr...@james.apache.org For additional commands, e-mail: server-dev-h...@james.apache.org
Re: Ops experience: monitoring [mail processing - mailbox event processing] for distributed James product
Shouldn't it be more logic to log only status changes ? I mean, if you are in a degraded state, you will log the same thing each minute else if you have fixed the issue. Le mer. 12 févr. 2020 à 11:43, Tellier Benoit a écrit : > +1 > > We should make this happen. > > On 12/02/2020 17:29, Matthieu Baechler wrote: > > On Wed, 2020-02-12 at 16:27 +0700, Tellier Benoit wrote: > > > >> - Through grafana, the admin will have the information directly > >> available. Nowaday, health-checks requires her to execute the > >> healthcheck via webadmin. More actions is generally the best way of > >> having none of them taken. > >> > > > > I just want to add, on that matter, that I already proposed to have a > > timer that logs health state to WARN when status is `degraded` and > > ERROR when status is `down` on a sensible time interval (like once a > > minute) and that would be enabled in our default configuration. > > > > That way the logs, which are the first and most basic tool any admin is > > looking at, would give you that very important information. > > > > Cheers, > > > > - > To unsubscribe, e-mail: server-dev-unsubscr...@james.apache.org > For additional commands, e-mail: server-dev-h...@james.apache.org > >
Re: Ops experience: monitoring [mail processing - mailbox event processing] for distributed James product
+1 We should make this happen. On 12/02/2020 17:29, Matthieu Baechler wrote: > On Wed, 2020-02-12 at 16:27 +0700, Tellier Benoit wrote: > >> - Through grafana, the admin will have the information directly >> available. Nowaday, health-checks requires her to execute the >> healthcheck via webadmin. More actions is generally the best way of >> having none of them taken. >> > > I just want to add, on that matter, that I already proposed to have a > timer that logs health state to WARN when status is `degraded` and > ERROR when status is `down` on a sensible time interval (like once a > minute) and that would be enabled in our default configuration. > > That way the logs, which are the first and most basic tool any admin is > looking at, would give you that very important information. > > Cheers, > - To unsubscribe, e-mail: server-dev-unsubscr...@james.apache.org For additional commands, e-mail: server-dev-h...@james.apache.org
Re: Ops experience: monitoring [mail processing - mailbox event processing] for distributed James product
On Wed, 2020-02-12 at 16:27 +0700, Tellier Benoit wrote: > - Through grafana, the admin will have the information directly > available. Nowaday, health-checks requires her to execute the > healthcheck via webadmin. More actions is generally the best way of > having none of them taken. > I just want to add, on that matter, that I already proposed to have a timer that logs health state to WARN when status is `degraded` and ERROR when status is `down` on a sensible time interval (like once a minute) and that would be enabled in our default configuration. That way the logs, which are the first and most basic tool any admin is looking at, would give you that very important information. Cheers, -- Matthieu Baechler - To unsubscribe, e-mail: server-dev-unsubscr...@james.apache.org For additional commands, e-mail: server-dev-h...@james.apache.org
Ops experience: monitoring [mail processing - mailbox event processing] for distributed James product
Hello all, Recently, as part of our work documenting Administration Procedures for the Distributed Guice James product, we are having some reflections regarding the way to conduct monitoring, which undertook some nice discussions. Currently, monitoring of `mailbox event processing` and `mail processing` can be achieved via logs (ie ERROR log review, etc..) However, logs requires correct kibana configuration which means also good information. But: - It makes retries/final-try non trivial to distinguish - Admin generally monotor logs using a time-window. Events older than this time window are ignored. We can think of several mechanisms to enhance this matter of fact: - Having for instance a health check, like MailboxEventProcessingHealthCheck ensuring that dead-letter is empty, or returning "degraded" otherwize - Having a metric displayed in a board. For the dead-letter exemple, a boolean text field can be enough. While interesting, the health check options received the following critics so far: - A perfectly behaving James server might report some failed processing entries (for example on some border line EML parsing), leading to a degraded status of an overwize perfectly working James server (for both the mail processing and mailbox processing case) - Through grafana, the admin will have the information directly available. Nowaday, health-checks requires her to execute the healthcheck via webadmin. More actions is generally the best way of having none of them taken. We would be very interested by feedback on this topic, in order to get a friendlyer admin experience. Best regards, Benoit - To unsubscribe, e-mail: server-dev-unsubscr...@james.apache.org For additional commands, e-mail: server-dev-h...@james.apache.org