Search in sources :

Example 6 with SCryptPasswordEncoder

use of org.springframework.security.crypto.scrypt.SCryptPasswordEncoder in project tutorials by eugenp.

the class PasswordStorageWebSecurityConfigurer method passwordEncoder.

@Bean
public PasswordEncoder passwordEncoder() {
    // set up the list of supported encoders and their prefixes
    PasswordEncoder defaultEncoder = new StandardPasswordEncoder();
    Map<String, PasswordEncoder> encoders = new HashMap<>();
    encoders.put("bcrypt", new BCryptPasswordEncoder());
    encoders.put("scrypt", new SCryptPasswordEncoder());
    encoders.put("noop", NoOpPasswordEncoder.getInstance());
    DelegatingPasswordEncoder passwordEncoder = new DelegatingPasswordEncoder("bcrypt", encoders);
    passwordEncoder.setDefaultPasswordEncoderForMatches(defaultEncoder);
    return passwordEncoder;
}
Also used : StandardPasswordEncoder(org.springframework.security.crypto.password.StandardPasswordEncoder) BCryptPasswordEncoder(org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder) DelegatingPasswordEncoder(org.springframework.security.crypto.password.DelegatingPasswordEncoder) StandardPasswordEncoder(org.springframework.security.crypto.password.StandardPasswordEncoder) PasswordEncoder(org.springframework.security.crypto.password.PasswordEncoder) NoOpPasswordEncoder(org.springframework.security.crypto.password.NoOpPasswordEncoder) 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) BCryptPasswordEncoder(org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder) Bean(org.springframework.context.annotation.Bean)

Example 7 with SCryptPasswordEncoder

use of org.springframework.security.crypto.scrypt.SCryptPasswordEncoder in project cas by apereo.

the class CouchbaseAuthenticationHandlerTests method verifyBadEncoding.

@Test
public void verifyBadEncoding() {
    val props = casProperties.getAuthn().getCouchbase();
    val factory = new DefaultCouchbaseClientFactory(props);
    val handler = new CouchbaseAuthenticationHandler(mock(ServicesManager.class), PrincipalFactoryUtils.newPrincipalFactory(), factory, props);
    handler.setPasswordEncoder(new SCryptPasswordEncoder());
    val c = CoreAuthenticationTestUtils.getCredentialsWithDifferentUsernameAndPassword("casuser", "Mellon");
    assertThrows(FailedLoginException.class, () -> handler.authenticate(c));
}
Also used : lombok.val(lombok.val) DefaultCouchbaseClientFactory(org.apereo.cas.couchbase.core.DefaultCouchbaseClientFactory) ServicesManager(org.apereo.cas.services.ServicesManager) SCryptPasswordEncoder(org.springframework.security.crypto.scrypt.SCryptPasswordEncoder) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Aggregations

SCryptPasswordEncoder (org.springframework.security.crypto.scrypt.SCryptPasswordEncoder)7 BCryptPasswordEncoder (org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder)5 PasswordEncoder (org.springframework.security.crypto.password.PasswordEncoder)4 Pbkdf2PasswordEncoder (org.springframework.security.crypto.password.Pbkdf2PasswordEncoder)4 StandardPasswordEncoder (org.springframework.security.crypto.password.StandardPasswordEncoder)4 lombok.val (lombok.val)3 NoOpPasswordEncoder (org.springframework.security.crypto.password.NoOpPasswordEncoder)3 HashMap (java.util.HashMap)2 DefaultCouchbaseClientFactory (org.apereo.cas.couchbase.core.DefaultCouchbaseClientFactory)2 ServicesManager (org.apereo.cas.services.ServicesManager)2 DefaultPasswordEncoder (org.apereo.cas.util.crypto.DefaultPasswordEncoder)2 Test (org.junit.jupiter.api.Test)2 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)2 DelegatingPasswordEncoder (org.springframework.security.crypto.password.DelegatingPasswordEncoder)2 SecureRandom (java.security.SecureRandom)1 UtilityClass (lombok.experimental.UtilityClass)1 PasswordEncoderProperties (org.apereo.cas.configuration.model.core.authentication.PasswordEncoderProperties)1 GlibcCryptPasswordEncoder (org.apereo.cas.util.crypto.GlibcCryptPasswordEncoder)1 SpringSecurityPasswordEncoder (org.pac4j.core.credentials.password.SpringSecurityPasswordEncoder)1 TechnicalException (org.pac4j.core.exception.TechnicalException)1