Fix regression
authorMathieu Baudier <mbaudier@argeo.org>
Wed, 8 Nov 2017 16:38:57 +0000 (17:38 +0100)
committerMathieu Baudier <mbaudier@argeo.org>
Wed, 8 Nov 2017 16:38:57 +0000 (17:38 +0100)
org.argeo.enterprise/src/org/argeo/naming/AuthPassword.java

index f9cfc69c8370d5f53441faff88573630e2acc1ad..4a5004eefc8cb2c7b8a69196b3af00276beda3e9 100644 (file)
@@ -103,20 +103,22 @@ public class AuthPassword implements CallbackHandler {
        public static AuthPassword matchAuthValue(Attributes attributes, char[] value) {
                try {
                        Attribute authPassword = attributes.get(LdapAttrs.authPassword.name());
-                       NamingEnumeration<?> values = authPassword.getAll();
-                       while (values.hasMore()) {
-                               Object val = values.next();
-                               AuthPassword token = new AuthPassword(val.toString());
-                               String auth;
-                               if (Arrays.binarySearch(value, '$') >= 0) {
-                                       auth = token.authInfo + '$' + token.authValue;
-                               } else {
-                                       auth = token.authValue;
+                       if (authPassword != null) {
+                               NamingEnumeration<?> values = authPassword.getAll();
+                               while (values.hasMore()) {
+                                       Object val = values.next();
+                                       AuthPassword token = new AuthPassword(val.toString());
+                                       String auth;
+                                       if (Arrays.binarySearch(value, '$') >= 0) {
+                                               auth = token.authInfo + '$' + token.authValue;
+                                       } else {
+                                               auth = token.authValue;
+                                       }
+                                       if (Arrays.equals(auth.toCharArray(), value))
+                                               return token;
+                                       // if (token.matchAuthValue(value))
+                                       // return token;
                                }
-                               if (Arrays.equals(auth.toCharArray(), value))
-                                       return token;
-                               // if (token.matchAuthValue(value))
-                               // return token;
                        }
                        return null;
                } catch (NamingException e) {