karaf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gno...@apache.org
Subject karaf git commit: KARAF-4659 - Ability to disable ldap listeners
Date Mon, 22 Aug 2016 15:39:33 GMT
Repository: karaf
Updated Branches:
  refs/heads/karaf-4.0.x 020d255ca -> 35f1acc1c


KARAF-4659 - Ability to disable ldap listeners 

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

Branch: refs/heads/karaf-4.0.x
Commit: 35f1acc1c5fda6d88429bec0fbcb5c7a13b1b5e7
Parents: 020d255
Author: Guillaume Nodet <gnodet@apache.org>
Authored: Mon Aug 22 16:42:23 2016 +0200
Committer: Guillaume Nodet <gnodet@apache.org>
Committed: Mon Aug 22 17:39:24 2016 +0200

----------------------------------------------------------------------
 .../karaf/jaas/modules/ldap/LDAPCache.java      | 30 +++++++++++---------
 .../karaf/jaas/modules/ldap/LDAPOptions.java    |  6 ++++
 2 files changed, 23 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/karaf/blob/35f1acc1/jaas/modules/src/main/java/org/apache/karaf/jaas/modules/ldap/LDAPCache.java
----------------------------------------------------------------------
diff --git a/jaas/modules/src/main/java/org/apache/karaf/jaas/modules/ldap/LDAPCache.java
b/jaas/modules/src/main/java/org/apache/karaf/jaas/modules/ldap/LDAPCache.java
index 00dafac..203eb66 100644
--- a/jaas/modules/src/main/java/org/apache/karaf/jaas/modules/ldap/LDAPCache.java
+++ b/jaas/modules/src/main/java/org/apache/karaf/jaas/modules/ldap/LDAPCache.java
@@ -117,17 +117,19 @@ public class LDAPCache implements Closeable, NamespaceChangeListener,
ObjectChan
         final SearchControls constraints = new SearchControls();
         constraints.setSearchScope(SearchControls.SUBTREE_SCOPE);
 
-        String filter = options.getUserFilter();
-        filter = filter.replaceAll(Pattern.quote("%u"), Matcher.quoteReplacement("*"));
-        filter = filter.replace("\\", "\\\\");
-        eventContext.addNamingListener(options.getUserBaseDn(), filter, constraints, this);
-
-        filter = options.getRoleFilter();
-        filter = filter.replaceAll(Pattern.quote("%u"), Matcher.quoteReplacement("*"));
-        filter = filter.replaceAll(Pattern.quote("%dn"), Matcher.quoteReplacement("*"));
-        filter = filter.replaceAll(Pattern.quote("%fqdn"), Matcher.quoteReplacement("*"));
-        filter = filter.replace("\\", "\\\\");
-        eventContext.addNamingListener(options.getRoleBaseDn(), filter, constraints, this);
+        if (!options.getDisableCache()) {
+            String filter = options.getUserFilter();
+            filter = filter.replaceAll(Pattern.quote("%u"), Matcher.quoteReplacement("*"));
+            filter = filter.replace("\\", "\\\\");
+            eventContext.addNamingListener(options.getUserBaseDn(), filter, constraints,
this);
+
+            filter = options.getRoleFilter();
+            filter = filter.replaceAll(Pattern.quote("%u"), Matcher.quoteReplacement("*"));
+            filter = filter.replaceAll(Pattern.quote("%dn"), Matcher.quoteReplacement("*"));
+            filter = filter.replaceAll(Pattern.quote("%fqdn"), Matcher.quoteReplacement("*"));
+            filter = filter.replace("\\", "\\\\");
+            eventContext.addNamingListener(options.getRoleBaseDn(), filter, constraints,
this);
+        }
 
         return context;
     }
@@ -136,7 +138,7 @@ public class LDAPCache implements Closeable, NamespaceChangeListener,
ObjectChan
         String[] result = userDnAndNamespace.get(user);
         if (result == null) {
             result = doGetUserDnAndNamespace(user);
-            if (result != null) {
+            if (result != null && !options.getDisableCache()) {
                 userDnAndNamespace.put(user, result);
             }
         }
@@ -201,7 +203,9 @@ public class LDAPCache implements Closeable, NamespaceChangeListener,
ObjectChan
         String[] result = userRoles.get(userDn);
         if (result == null) {
             result = doGetUserRoles(user, userDn, userDnNamespace);
-            userRoles.put(userDn, result);
+            if (!options.getDisableCache()) {
+                userRoles.put(userDn, result);
+            }
         }
         return result;
     }

http://git-wip-us.apache.org/repos/asf/karaf/blob/35f1acc1/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 912ce2f..5ddc7ad 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
@@ -45,6 +45,7 @@ public class LDAPOptions {
     public static final String ROLE_MAPPING = "role.mapping";
     public static final String AUTHENTICATION = "authentication";
     public static final String ALLOW_EMPTY_PASSWORDS = "allowEmptyPasswords";
+    public static final String DISABLE_CACHE = "disableCache";
     public static final String INITIAL_CONTEXT_FACTORY = "initial.context.factory";
     public static final String CONTEXT_PREFIX = "context.";
     public static final String SSL = "ssl";
@@ -263,4 +264,9 @@ public class LDAPOptions {
     public boolean getAllowEmptyPasswords() {
         return Boolean.parseBoolean((String) options.get(ALLOW_EMPTY_PASSWORDS));
     }
+
+    public boolean getDisableCache() {
+        return Boolean.parseBoolean((String) options.get(DISABLE_CACHE));
+    }
+
 }


Mime
View raw message