You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by rc...@apache.org on 2020/06/08 03:12:27 UTC
[james-project] 06/16: JAMES-3196 MailetContainer: Log correlation
for sender aliases
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 07a3f487c0092c13e0acad040efdb8ee6cd52558
Author: Benoit Tellier <bt...@linagora.com>
AuthorDate: Fri May 29 09:06:42 2020 +0700
JAMES-3196 MailetContainer: Log correlation for sender aliases
Debugging can be hard when sender relies on aliases: we can not easily
link them to their main address within the mailet-container. As a result,
it is easy to miss user-related emails upon audit.
This log ensures the sender alias could be correlated with the main user
address.
---
.../org/apache/james/mailetcontainer/impl/LocalResources.java | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/server/mailet/mailetcontainer-camel/src/main/java/org/apache/james/mailetcontainer/impl/LocalResources.java b/server/mailet/mailetcontainer-camel/src/main/java/org/apache/james/mailetcontainer/impl/LocalResources.java
index bd41f84..a883a75 100644
--- a/server/mailet/mailetcontainer-camel/src/main/java/org/apache/james/mailetcontainer/impl/LocalResources.java
+++ b/server/mailet/mailetcontainer-camel/src/main/java/org/apache/james/mailetcontainer/impl/LocalResources.java
@@ -37,12 +37,15 @@ import org.apache.james.rrt.api.RecipientRewriteTableException;
import org.apache.james.rrt.lib.Mapping;
import org.apache.james.user.api.UsersRepository;
import org.apache.james.user.api.UsersRepositoryException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import com.github.fge.lambdas.Throwing;
import com.github.steveash.guavate.Guavate;
class LocalResources {
private static final EnumSet<Mapping.Type> ALIAS_TYPES = EnumSet.of(Mapping.Type.Alias, Mapping.Type.DomainAlias);
+ public static final Logger LOGGER = LoggerFactory.getLogger(LocalResources.class);
private final UsersRepository localUsers;
private final DomainList domains;
@@ -130,6 +133,9 @@ class LocalResources {
.asStream()
.map(mapping -> mapping.asMailAddress()
.orElseThrow(() -> new IllegalStateException(String.format("Can not compute address for mapping %s", mapping.asString()))))
- .anyMatch(Throwing.predicate(this::isLocaluser).sneakyThrow());
+ .filter(Throwing.predicate(this::isLocaluser).sneakyThrow())
+ .peek(ownerAddress -> LOGGER.debug("{} belongs to {} local user", mailAddress.asString(), ownerAddress.asString()))
+ .findFirst()
+ .isPresent();
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org