You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@james.apache.org by rc...@apache.org on 2024/08/01 04:39:49 UTC
(james-project) 02/02: JAMES-4044 Support multi-valued attributes
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 69f786fc231f19d2a862d575a4b11a337b83a811
Author: Benoit TELLIER <bt...@linagora.com>
AuthorDate: Sat Jul 27 08:45:18 2024 +0200
JAMES-4044 Support multi-valued attributes
---
.../org/apache/james/transport/matchers/HasLDAPAttribute.java | 9 +++++----
.../apache/james/transport/matchers/SenderHasLDAPAttribute.java | 9 +++++----
2 files changed, 10 insertions(+), 8 deletions(-)
diff --git a/server/mailet/ldap/src/main/java/org/apache/james/transport/matchers/HasLDAPAttribute.java b/server/mailet/ldap/src/main/java/org/apache/james/transport/matchers/HasLDAPAttribute.java
index 79c0a748c3..6a87287974 100644
--- a/server/mailet/ldap/src/main/java/org/apache/james/transport/matchers/HasLDAPAttribute.java
+++ b/server/mailet/ldap/src/main/java/org/apache/james/transport/matchers/HasLDAPAttribute.java
@@ -19,8 +19,10 @@
package org.apache.james.transport.matchers;
+import java.util.Arrays;
import java.util.Collection;
import java.util.Optional;
+import java.util.stream.Stream;
import jakarta.inject.Inject;
import jakarta.mail.MessagingException;
@@ -36,7 +38,6 @@ import com.github.fge.lambdas.Throwing;
import com.google.common.cache.Cache;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
-import com.unboundid.ldap.sdk.Attribute;
import com.unboundid.ldap.sdk.Filter;
import com.unboundid.ldap.sdk.LDAPConnectionPool;
import com.unboundid.ldap.sdk.LDAPException;
@@ -167,9 +168,9 @@ public class HasLDAPAttribute extends GenericMatcher {
private boolean hasAttribute(SearchResultEntry entry) {
return attributeValue.map(value -> Optional.ofNullable(entry.getAttribute(attributeName))
- .map(Attribute::getValue)
- .map(value::equals)
- .orElse(false))
+ .map(attribute -> Arrays.stream(attribute.getValues()))
+ .orElse(Stream.empty())
+ .anyMatch(value::equals))
.orElseGet(() -> entry.hasAttribute(attributeName));
}
diff --git a/server/mailet/ldap/src/main/java/org/apache/james/transport/matchers/SenderHasLDAPAttribute.java b/server/mailet/ldap/src/main/java/org/apache/james/transport/matchers/SenderHasLDAPAttribute.java
index 4058723224..fbec891107 100644
--- a/server/mailet/ldap/src/main/java/org/apache/james/transport/matchers/SenderHasLDAPAttribute.java
+++ b/server/mailet/ldap/src/main/java/org/apache/james/transport/matchers/SenderHasLDAPAttribute.java
@@ -19,8 +19,10 @@
package org.apache.james.transport.matchers;
+import java.util.Arrays;
import java.util.Collection;
import java.util.Optional;
+import java.util.stream.Stream;
import jakarta.inject.Inject;
import jakarta.mail.MessagingException;
@@ -36,7 +38,6 @@ import com.github.fge.lambdas.Throwing;
import com.google.common.cache.Cache;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
-import com.unboundid.ldap.sdk.Attribute;
import com.unboundid.ldap.sdk.Filter;
import com.unboundid.ldap.sdk.LDAPConnectionPool;
import com.unboundid.ldap.sdk.LDAPException;
@@ -172,9 +173,9 @@ public class SenderHasLDAPAttribute extends GenericMatcher {
private boolean hasAttribute(SearchResultEntry entry) {
return attributeValue.map(value -> Optional.ofNullable(entry.getAttribute(attributeName))
- .map(Attribute::getValue)
- .map(value::equals)
- .orElse(false))
+ .map(attribute -> Arrays.stream(attribute.getValues()))
+ .orElse(Stream.empty())
+ .anyMatch(value::equals))
.orElseGet(() -> entry.hasAttribute(attributeName));
}
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For additional commands, e-mail: notifications-help@james.apache.org