Search in sources :

Example 21 with DelegatingPasswordEncoder

use of org.springframework.security.crypto.password.DelegatingPasswordEncoder in project best-cloud by shanzhaozhen.

the class PasswordEncoderConfig method passwordEncoder.

@Bean
public PasswordEncoder passwordEncoder() {
    PasswordEncoder passwordEncoder = PasswordEncoderFactories.createDelegatingPasswordEncoder();
    // 增加默认编码器
    ((DelegatingPasswordEncoder) passwordEncoder).setDefaultPasswordEncoderForMatches(new BCryptPasswordEncoder());
    return passwordEncoder;
}
Also used : BCryptPasswordEncoder(org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder) PasswordEncoder(org.springframework.security.crypto.password.PasswordEncoder) DelegatingPasswordEncoder(org.springframework.security.crypto.password.DelegatingPasswordEncoder) DelegatingPasswordEncoder(org.springframework.security.crypto.password.DelegatingPasswordEncoder) BCryptPasswordEncoder(org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder) Bean(org.springframework.context.annotation.Bean)

Example 22 with DelegatingPasswordEncoder

use of org.springframework.security.crypto.password.DelegatingPasswordEncoder in project jpsonic by tesshucom.

the class GlobalSecurityConfig method delegatingPasswordEncoder.

@Bean
public PasswordEncoder delegatingPasswordEncoder() {
    // Spring Security 5 require storing the encoder id alongside the encoded password
    // (e.g. "{md5}hash" for an MD5-encoded password hash), which differs from previous
    // versions.
    // 
    // Airsonic unfortunately stores passwords in plain-text, which is why we are setting
    // the "no-op" (plain-text) password encoder as a default here. This default will be
    // used when no encoder id is present.
    // 
    // This means that legacy Airsonic passwords (stored simply as "password" in the db)
    // will be matched like "{noop}password" and will be recognized successfully. In the
    // future password encoding updates will be done here.
    PasswordEncoder defaultEncoder = NoOpPasswordEncoder.getInstance();
    String defaultIdForEncode = "noop";
    Map<String, PasswordEncoder> encoders = LegacyMap.of(defaultIdForEncode, defaultEncoder);
    DelegatingPasswordEncoder passworEncoder = new DelegatingPasswordEncoder(defaultIdForEncode, encoders);
    passworEncoder.setDefaultPasswordEncoderForMatches(defaultEncoder);
    return passworEncoder;
}
Also used : DelegatingPasswordEncoder(org.springframework.security.crypto.password.DelegatingPasswordEncoder) PasswordEncoder(org.springframework.security.crypto.password.PasswordEncoder) NoOpPasswordEncoder(org.springframework.security.crypto.password.NoOpPasswordEncoder) DelegatingPasswordEncoder(org.springframework.security.crypto.password.DelegatingPasswordEncoder) Bean(org.springframework.context.annotation.Bean)

Example 23 with DelegatingPasswordEncoder

use of org.springframework.security.crypto.password.DelegatingPasswordEncoder in project Spring-5.0-Projects by PacktPublishing.

the class WebSecurityConfig method passwordEncoder.

@Bean
public PasswordEncoder passwordEncoder() {
    Map<String, PasswordEncoder> encoders = new HashMap<>();
    encoders.put(PwdEncodingAlgo.BCrypt.getStatus(), new BCryptPasswordEncoder());
    encoders.put(PwdEncodingAlgo.Pbkf2.getStatus(), new Pbkdf2PasswordEncoder());
    encoders.put(PwdEncodingAlgo.SCrypt.getStatus(), new SCryptPasswordEncoder());
    return new DelegatingPasswordEncoder(PwdEncodingAlgo.BCrypt.getStatus(), encoders);
}
Also used : BCryptPasswordEncoder(org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder) DelegatingPasswordEncoder(org.springframework.security.crypto.password.DelegatingPasswordEncoder) LdapShaPasswordEncoder(org.springframework.security.crypto.password.LdapShaPasswordEncoder) PasswordEncoder(org.springframework.security.crypto.password.PasswordEncoder) Pbkdf2PasswordEncoder(org.springframework.security.crypto.password.Pbkdf2PasswordEncoder) SCryptPasswordEncoder(org.springframework.security.crypto.scrypt.SCryptPasswordEncoder) HashMap(java.util.HashMap) SCryptPasswordEncoder(org.springframework.security.crypto.scrypt.SCryptPasswordEncoder) DelegatingPasswordEncoder(org.springframework.security.crypto.password.DelegatingPasswordEncoder) Pbkdf2PasswordEncoder(org.springframework.security.crypto.password.Pbkdf2PasswordEncoder) BCryptPasswordEncoder(org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder) Bean(org.springframework.context.annotation.Bean)

Aggregations

DelegatingPasswordEncoder (org.springframework.security.crypto.password.DelegatingPasswordEncoder)23 BCryptPasswordEncoder (org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder)20 PasswordEncoder (org.springframework.security.crypto.password.PasswordEncoder)20 HashMap (java.util.HashMap)17 Bean (org.springframework.context.annotation.Bean)13 Pbkdf2PasswordEncoder (org.springframework.security.crypto.password.Pbkdf2PasswordEncoder)11 SCryptPasswordEncoder (org.springframework.security.crypto.scrypt.SCryptPasswordEncoder)11 Argon2PasswordEncoder (org.springframework.security.crypto.argon2.Argon2PasswordEncoder)6 StandardPasswordEncoder (org.springframework.security.crypto.password.StandardPasswordEncoder)5 PlaceholderPasswordEncoder (com.ctrip.framework.apollo.portal.spi.oidc.PlaceholderPasswordEncoder)2 Before (org.junit.Before)2 NoOpPasswordEncoder (org.springframework.security.crypto.password.NoOpPasswordEncoder)2 CustomerRepository (org.terasoluna.tourreservation.domain.repository.customer.CustomerRepository)2 Test (org.junit.Test)1 Test (org.junit.jupiter.api.Test)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