@Configuration public class SecurityConfiguration { private static final String PRIVATE_SALT = "ourprivatesalt"; private PasswordService passwordService; private PasswordMatcher credentialsMatcher = new PasswordAndSystemCredentialsMatcher(); private AuthenticatingSecurityManager securityManager; @Bean public PasswordService passwordService() { if (passwordService == null) { DefaultPasswordService defaultPasswordService = new DefaultPasswordService(); passwordService = defaultPasswordService; DefaultHashService defaultHashService = (DefaultHashService) defaultPasswordService.getHashService(); defaultHashService.setPrivateSalt(new SimpleByteSource(PRIVATE_SALT)); } return passwordService; } @Bean public CredentialsMatcher credentialsMatcher() { credentialsMatcher.setPasswordService(passwordService()); return credentialsMatcher; }
@Override public void activateService() throws Exception { configuration.refresh(); PasswordRealmConfiguration config = configuration.get(); String algorithm = config.hashAlgorithmName().get(); Integer iterations = config.hashIterationsCount().get(); if( algorithm != null || iterations != null ) { DefaultHashService hashService = (DefaultHashService) passwordService.getHashService(); if( algorithm != null ) { hashService.setHashAlgorithmName( algorithm ); } if( iterations != null ) { hashService.setHashIterations( iterations ); } } }
@Override public void activateService() throws Exception { configuration.refresh(); PasswordRealmConfiguration config = configuration.get(); String algorithm = config.hashAlgorithmName().get(); Integer iterations = config.hashIterationsCount().get(); if( algorithm != null || iterations != null ) { DefaultHashService hashService = (DefaultHashService) passwordService.getHashService(); if( algorithm != null ) { hashService.setHashAlgorithmName( algorithm ); } if( iterations != null ) { hashService.setHashIterations( iterations ); } } }