You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@karaf.apache.org by gn...@apache.org on 2016/04/14 15:47:15 UTC

[2/3] karaf git commit: [KARAF-4486] LDAPOptions sets Context.SECURITY_AUTHENTICATION only if username is provided

[KARAF-4486] LDAPOptions sets Context.SECURITY_AUTHENTICATION only if username is provided

Project: http://git-wip-us.apache.org/repos/asf/karaf/repo
Commit: http://git-wip-us.apache.org/repos/asf/karaf/commit/dde032a9
Tree: http://git-wip-us.apache.org/repos/asf/karaf/tree/dde032a9
Diff: http://git-wip-us.apache.org/repos/asf/karaf/diff/dde032a9

Branch: refs/heads/master
Commit: dde032a99b355c710193b83d0f7437d9caaeda8a
Parents: ac12c65
Author: Guillaume Nodet <gn...@apache.org>
Authored: Thu Apr 14 15:29:45 2016 +0200
Committer: Guillaume Nodet <gn...@apache.org>
Committed: Thu Apr 14 15:29:45 2016 +0200

----------------------------------------------------------------------
 .../apache/karaf/jaas/modules/ldap/LDAPOptions.java   | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/karaf/blob/dde032a9/jaas/modules/src/main/java/org/apache/karaf/jaas/modules/ldap/LDAPOptions.java
----------------------------------------------------------------------
diff --git a/jaas/modules/src/main/java/org/apache/karaf/jaas/modules/ldap/LDAPOptions.java b/jaas/modules/src/main/java/org/apache/karaf/jaas/modules/ldap/LDAPOptions.java
index a173b3e..3342636 100644
--- a/jaas/modules/src/main/java/org/apache/karaf/jaas/modules/ldap/LDAPOptions.java
+++ b/jaas/modules/src/main/java/org/apache/karaf/jaas/modules/ldap/LDAPOptions.java
@@ -144,9 +144,15 @@ public class LDAPOptions {
         env.put(Context.INITIAL_CONTEXT_FACTORY, getInitialContextFactory());
         env.put(Context.PROVIDER_URL, getConnectionURL());
         if (getConnectionUsername() != null && getConnectionUsername().trim().length() > 0) {
-            env.put(Context.SECURITY_AUTHENTICATION, getAuthentication());
+            String auth = getAuthentication();
+            if (auth == null) {
+                auth = DEFAULT_AUTHENTICATION;
+            }
+            env.put(Context.SECURITY_AUTHENTICATION, auth);
             env.put(Context.SECURITY_PRINCIPAL, getConnectionUsername());
             env.put(Context.SECURITY_CREDENTIALS, getConnectionPassword());
+        } else if (getAuthentication() != null) {
+            env.put(Context.SECURITY_AUTHENTICATION, getAuthentication());
         }
         if (getSsl()) {
             setupSsl(env);
@@ -202,11 +208,7 @@ public class LDAPOptions {
     }
 
     public String getAuthentication() {
-        String authentication = (String) options.get(AUTHENTICATION);
-        if (authentication == null) {
-            authentication = DEFAULT_AUTHENTICATION;
-        }
-        return authentication;
+        return (String) options.get(AUTHENTICATION);
     }
 
     public boolean getSsl() {