james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From btell...@apache.org
Subject [5/6] james-project git commit: JAMES-2441 Rely on Optional in ReadOnlyUsersLDAPRepository
Date Tue, 03 Jul 2018 02:48:23 GMT
JAMES-2441 Rely on Optional in ReadOnlyUsersLDAPRepository


Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/53dc38fd
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/53dc38fd
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/53dc38fd

Branch: refs/heads/master
Commit: 53dc38fdac567a8728ffef982388c6f5ade71d72
Parents: dd31a82
Author: benwa <btellier@linagora.com>
Authored: Wed Jun 27 17:33:46 2018 +0700
Committer: benwa <btellier@linagora.com>
Committed: Tue Jul 3 09:47:14 2018 +0700

----------------------------------------------------------------------
 .../apache/james/user/ldap/ReadOnlyUsersLDAPRepository.java | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/53dc38fd/server/data/data-ldap/src/main/java/org/apache/james/user/ldap/ReadOnlyUsersLDAPRepository.java
----------------------------------------------------------------------
diff --git a/server/data/data-ldap/src/main/java/org/apache/james/user/ldap/ReadOnlyUsersLDAPRepository.java
b/server/data/data-ldap/src/main/java/org/apache/james/user/ldap/ReadOnlyUsersLDAPRepository.java
index 6f6677b..61c264a 100644
--- a/server/data/data-ldap/src/main/java/org/apache/james/user/ldap/ReadOnlyUsersLDAPRepository.java
+++ b/server/data/data-ldap/src/main/java/org/apache/james/user/ldap/ReadOnlyUsersLDAPRepository.java
@@ -25,6 +25,7 @@ import java.util.HashSet;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
+import java.util.Optional;
 import java.util.Properties;
 import java.util.Set;
 
@@ -348,14 +349,16 @@ public class ReadOnlyUsersLDAPRepository implements UsersRepository,
Configurabl
     }
 
     protected Properties getContextEnvironment() {
-        final Properties props = new Properties();
+        Properties props = new Properties();
         props.put(Context.INITIAL_CONTEXT_FACTORY, INITIAL_CONTEXT_FACTORY);
-        props.put(Context.PROVIDER_URL, null == ldapConfiguration.getLdapHost() ? "" : ldapConfiguration.getLdapHost());
+        props.put(Context.PROVIDER_URL, Optional.ofNullable(ldapConfiguration.getLdapHost())
+            .orElse(""));
         if (Strings.isNullOrEmpty(ldapConfiguration.getCredentials())) {
             props.put(Context.SECURITY_AUTHENTICATION, LdapConstants.SECURITY_AUTHENTICATION_NONE);
         } else {
             props.put(Context.SECURITY_AUTHENTICATION, LdapConstants.SECURITY_AUTHENTICATION_SIMPLE);
-            props.put(Context.SECURITY_PRINCIPAL, null == ldapConfiguration.getPrincipal()
? "" : ldapConfiguration.getPrincipal());
+            props.put(Context.SECURITY_PRINCIPAL, Optional.ofNullable(ldapConfiguration.getPrincipal())
+                .orElse(""));
             props.put(Context.SECURITY_CREDENTIALS, ldapConfiguration.getCredentials());
         }
         // The following properties are specific to com.sun.jndi.ldap.LdapCtxFactory


---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org


Mime
View raw message