}
@Override
protected CharArrayPasswordEncoder createCharEncoder() {
return new CharArrayPasswordEncoder() {
StandardByteDigester digester = new StandardByteDigester();
{
digester.setAlgorithm("SHA-256");
digester.setIterations(100000);
digester.setSaltSizeBytes(16);
digester.initialize();
}
@Override
public String encodePassword(char[] rawPass, Object salt) {
return new String(Base64.encodeBase64(digester.digest(toBytes(rawPass))));
}
@Override
public boolean isPasswordValid(String encPass, char[] rawPass, Object salt) {
return digester.matches(toBytes(rawPass), Base64.decodeBase64(encPass.getBytes()));
}
};
}