moresandeep commented on code in PR #1353:
URL: https://github.com/apache/knox/pull/1353#discussion_r3830659185


##########
gateway-provider-security-shiro/src/main/java/org/apache/knox/gateway/shirorealm/KnoxLdapRealm.java:
##########
@@ -744,16 +752,15 @@ protected String getUserDn( final String principal ) 
throws IllegalArgumentExcep
 
     @Override
     protected AuthenticationInfo createAuthenticationInfo(AuthenticationToken 
token, Object ldapPrincipal, Object ldapCredentials, LdapContext ldapContext) 
throws NamingException {
-      HashRequest.Builder builder = new HashRequest.Builder();
-      Hash credentialsHash = 
hashService.computeHash(builder.setSource(token.getCredentials()).setAlgorithmName(HASHING_ALGORITHM).build());
-      return new SimpleAuthenticationInfo(token.getPrincipal(), 
credentialsHash.toHex(), credentialsHash.getSalt(), getName());
+      final ByteSource credentialsSalt = new 
SecureRandomNumberGenerator().nextBytes();
+      final SimpleHash credentialsHash = new SimpleHash(HASHING_ALGORITHM, 
token.getCredentials(), credentialsSalt, HASHING_ITERATIONS);
+      return new SimpleAuthenticationInfo(token.getPrincipal(), 
credentialsHash.toHex(), credentialsSalt, getName());
     }
 
-  private static String expandTemplate(final String template, final Matcher 
input) {
-    return expandTemplate(template, input, false);
-  }
+  /** How a substituted template value must be escaped for its target context. 
*/
+  private enum EscapeMode { NONE, FILTER, DN }

Review Comment:
   You are right, that is clearer way. 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to