@Override
public UUFUser authenticate(String username, char[] password, String domain) throws UserPortalUIException {
try {
Claim usernameClaim = new Claim(IdentityMgtConstants.CLAIM_ROOT_DIALECT,
IdentityMgtConstants.USERNAME_CLAIM, username);
PasswordCallback passwordCallback = new PasswordCallback("password", false);
passwordCallback.setPassword(password);
AuthenticationContext authenticationContext = getRealmService().getIdentityStore()
.authenticate(usernameClaim, new Callback[]{passwordCallback}, domain);
User identityUser = authenticationContext.getUser();
return new UUFUser(username, identityUser.getUniqueUserId(), identityUser.getDomainName());
} catch (AuthenticationFailure e) {
String error = "Invalid credentials.";
if (LOGGER.isDebugEnabled()) {
LOGGER.debug(error, e);
}
throw new UserPortalUIException("Invalid credentials.");
} catch (IdentityStoreException e) {
String error = "Failed to authenticate user.";
LOGGER.error(error, e);
throw new UserPortalUIException(error);
}
}