Search in sources :

Example 1 with LdapShaPasswordEncoder

use of org.maxkey.crypto.password.LdapShaPasswordEncoder in project MaxKey by dromara.

the class ApplicationAutoConfiguration method passwordEncoder.

/**
 * Authentication Password Encoder .
 * @return
 */
@Bean(name = "passwordEncoder")
public PasswordEncoder passwordEncoder() {
    String idForEncode = "bcrypt";
    Map<String, PasswordEncoder> encoders = new HashMap<String, PasswordEncoder>();
    encoders.put(idForEncode, new BCryptPasswordEncoder());
    encoders.put("plain", NoOpPasswordEncoder.getInstance());
    encoders.put("pbkdf2", new Pbkdf2PasswordEncoder());
    encoders.put("scrypt", new SCryptPasswordEncoder());
    // md
    encoders.put("md4", new Md4PasswordEncoder());
    encoders.put("md5", new MessageDigestPasswordEncoder("MD5"));
    // sha
    encoders.put("sha1", new StandardPasswordEncoder("SHA-1", ""));
    encoders.put("sha256", new StandardPasswordEncoder());
    encoders.put("sha384", new StandardPasswordEncoder("SHA-384", ""));
    encoders.put("sha512", new StandardPasswordEncoder("SHA-512", ""));
    encoders.put("sm3", new SM3PasswordEncoder());
    encoders.put("ldap", new LdapShaPasswordEncoder());
    // idForEncode is default for encoder
    PasswordEncoder passwordEncoder = new DelegatingPasswordEncoder(idForEncode, encoders);
    if (_logger.isTraceEnabled()) {
        _logger.trace("Password Encoders :");
        for (String key : encoders.keySet()) {
            _logger.trace("{}= {}", String.format("%-10s", key), encoders.get(key).getClass().getName());
        }
    }
    _logger.debug("{} is default encoder", idForEncode);
    return passwordEncoder;
}
Also used : StandardPasswordEncoder(org.maxkey.crypto.password.StandardPasswordEncoder) Md4PasswordEncoder(org.maxkey.crypto.password.Md4PasswordEncoder) NoOpPasswordEncoder(org.maxkey.crypto.password.NoOpPasswordEncoder) BCryptPasswordEncoder(org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder) LdapShaPasswordEncoder(org.maxkey.crypto.password.LdapShaPasswordEncoder) SM3PasswordEncoder(org.maxkey.crypto.password.SM3PasswordEncoder) SCryptPasswordEncoder(org.springframework.security.crypto.scrypt.SCryptPasswordEncoder) Md4PasswordEncoder(org.maxkey.crypto.password.Md4PasswordEncoder) MessageDigestPasswordEncoder(org.maxkey.crypto.password.MessageDigestPasswordEncoder) DelegatingPasswordEncoder(org.springframework.security.crypto.password.DelegatingPasswordEncoder) StandardPasswordEncoder(org.maxkey.crypto.password.StandardPasswordEncoder) PasswordEncoder(org.springframework.security.crypto.password.PasswordEncoder) Pbkdf2PasswordEncoder(org.springframework.security.crypto.password.Pbkdf2PasswordEncoder) HashMap(java.util.HashMap) DelegatingPasswordEncoder(org.springframework.security.crypto.password.DelegatingPasswordEncoder) Pbkdf2PasswordEncoder(org.springframework.security.crypto.password.Pbkdf2PasswordEncoder) MessageDigestPasswordEncoder(org.maxkey.crypto.password.MessageDigestPasswordEncoder) SCryptPasswordEncoder(org.springframework.security.crypto.scrypt.SCryptPasswordEncoder) LdapShaPasswordEncoder(org.maxkey.crypto.password.LdapShaPasswordEncoder) BCryptPasswordEncoder(org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder) SM3PasswordEncoder(org.maxkey.crypto.password.SM3PasswordEncoder) InitializingBean(org.springframework.beans.factory.InitializingBean) Bean(org.springframework.context.annotation.Bean)

Aggregations

HashMap (java.util.HashMap)1 LdapShaPasswordEncoder (org.maxkey.crypto.password.LdapShaPasswordEncoder)1 Md4PasswordEncoder (org.maxkey.crypto.password.Md4PasswordEncoder)1 MessageDigestPasswordEncoder (org.maxkey.crypto.password.MessageDigestPasswordEncoder)1 NoOpPasswordEncoder (org.maxkey.crypto.password.NoOpPasswordEncoder)1 SM3PasswordEncoder (org.maxkey.crypto.password.SM3PasswordEncoder)1 StandardPasswordEncoder (org.maxkey.crypto.password.StandardPasswordEncoder)1 InitializingBean (org.springframework.beans.factory.InitializingBean)1 Bean (org.springframework.context.annotation.Bean)1 BCryptPasswordEncoder (org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder)1 DelegatingPasswordEncoder (org.springframework.security.crypto.password.DelegatingPasswordEncoder)1 PasswordEncoder (org.springframework.security.crypto.password.PasswordEncoder)1 Pbkdf2PasswordEncoder (org.springframework.security.crypto.password.Pbkdf2PasswordEncoder)1 SCryptPasswordEncoder (org.springframework.security.crypto.scrypt.SCryptPasswordEncoder)1