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;
}
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));
}
Aggregations