use of org.wso2.carbon.identity.recovery.password.NotificationPasswordRecoveryManager in project identity-governance by wso2-extensions.
the class NotificationPasswordRecoveryManager method updateNewPassword.
/**
* Update the new password of the user.
*
* @param user User
* @param password New password
* @param domainQualifiedName Domain qualified name
* @param userRecoveryData User recovery data
* @param isNotificationInternallyManaged Whether the notifications are internally managed.
* @throws IdentityRecoveryException Error while checking for account state claim
* @throws IdentityRecoveryException Error while updating the password
*/
private void updateNewPassword(User user, String password, String domainQualifiedName, UserRecoveryData userRecoveryData, boolean isNotificationInternallyManaged) throws IdentityEventException, IdentityRecoveryException {
try {
int tenantId = IdentityTenantUtil.getTenantId(userRecoveryData.getUser().getTenantDomain());
UserStoreManager userStoreManager = IdentityRecoveryServiceDataHolder.getInstance().getRealmService().getTenantUserRealm(tenantId).getUserStoreManager();
userStoreManager.updateCredentialByAdmin(domainQualifiedName, password);
// Get the claims that related to a password reset.
HashMap<String, String> userClaims = getAccountStateClaims(userRecoveryData, isNotificationInternallyManaged);
if (MapUtils.isNotEmpty(userClaims)) {
// Update the retrieved claims set.
userStoreManager.setUserClaimValues(domainQualifiedName, userClaims, null);
}
} catch (UserStoreException e) {
checkPasswordValidity(e, user);
if (log.isDebugEnabled()) {
log.debug("NotificationPasswordRecoveryManager: Unexpected Error occurred while updating password " + "for the user: " + domainQualifiedName, e);
}
throw Utils.handleServerException(IdentityRecoveryConstants.ErrorMessages.ERROR_CODE_UNEXPECTED, null, e);
}
}
Aggregations