}
if (credential instanceof DigestCredential) {
((DigestHashCallback) current).setHexHash(((DigestCredential) credential).getHash());
} else if (credential instanceof PasswordCredential) {
UsernamePasswordHashUtil hashUtil = getHashUtil();
String hash;
synchronized (hashUtil) {
hash = hashUtil.generateHashedHexURP(userName, realmName,
((PasswordCredential) credential).getPassword());
}
((DigestHashCallback) current).setHexHash(hash);
} else {
throw new UnsupportedCallbackException(current);
}
} else if (current instanceof VerifyPasswordCallback) {
if (credential == null) {
throw new UserNotFoundException(userName);
}
VerifyPasswordCallback vpc = (VerifyPasswordCallback) current;
if (credential instanceof PasswordCredential) {
vpc.setVerified(Arrays.equals(((PasswordCredential) credential).getPassword(), vpc.getPassword()
.toCharArray()));
} else if (credential instanceof DigestCredential) {
UsernamePasswordHashUtil hashUtil = getHashUtil();
String hash;
synchronized (hashUtil) {
hash = hashUtil.generateHashedHexURP(userName, realmName, vpc.getPassword().toCharArray());
}
String expected = ((DigestCredential) credential).getHash();
vpc.setVerified(expected.equals(hash));
} else if (credential instanceof ValidatePasswordCredential) {
vpc.setVerified(((ValidatePasswordCredential) credential).validatePassword(vpc.getPassword()