use of org.wso2.carbon.identity.test.integration.service.stub.UserDTO in project carbon-identity-framework by wso2.
the class UserIdentityManagementAdminService method unlockUserAccount.
/**
* Admin unlocks the user account.
*
* @param userName
* @throws IdentityMgtServiceException
*/
public void unlockUserAccount(String userName, String notificationType) throws IdentityMgtServiceException {
try {
UserStoreManager userStoreManager = getUserStore(userName);
String userNameWithoutDomain = UserCoreUtil.removeDomainFromName(userName);
UserIdentityManagementUtil.unlockUserAccount(userNameWithoutDomain, userStoreManager);
int tenantID = userStoreManager.getTenantId();
String tenantDomain = IdentityMgtServiceComponent.getRealmService().getTenantManager().getDomain(tenantID);
boolean isNotificationSending = IdentityMgtConfig.getInstance().isNotificationSending();
if (notificationType != null && isNotificationSending) {
UserRecoveryDTO dto;
if (MultitenantConstants.SUPER_TENANT_DOMAIN_NAME.equals(tenantDomain)) {
dto = new UserRecoveryDTO(userName);
} else {
UserDTO userDTO = new UserDTO(UserCoreUtil.addTenantDomainToEntry(userName, tenantDomain));
userDTO.setTenantId(tenantID);
dto = new UserRecoveryDTO(userDTO);
}
dto.setNotification(IdentityMgtConstants.Notification.ACCOUNT_UNLOCK);
dto.setNotificationType(notificationType);
IdentityMgtServiceComponent.getRecoveryProcessor().recoverWithNotification(dto);
}
log.info("Account unlocked for: " + userName);
} catch (UserStoreException | IdentityException e) {
String message = "Error occurred while unlocking account for: " + userName;
log.error(message, e);
throw new IdentityMgtServiceException(message, e);
}
}
use of org.wso2.carbon.identity.test.integration.service.stub.UserDTO in project carbon-identity-framework by wso2.
the class UserIdentityManagementAdminService method disableUserAccount.
/**
* Admin disables the user account. Only the admin can enable the account using
* the {@literal enableUserAccount} method.
*
* @param userName
* @throws IdentityMgtServiceException
*/
public void disableUserAccount(String userName, String notificationType) throws IdentityMgtServiceException {
try {
UserStoreManager userStoreManager = getUserStore(userName);
String userNameWithoutDomain = UserCoreUtil.removeDomainFromName(userName);
UserIdentityManagementUtil.disableUserAccount(userNameWithoutDomain, userStoreManager);
audit.info(String.format(AUDIT_MESSAGE, getUser(), "Disable user account", userName, "Notification type :" + notificationType, SUCCESS));
int tenantID = userStoreManager.getTenantId();
String tenantDomain = IdentityMgtServiceComponent.getRealmService().getTenantManager().getDomain(tenantID);
boolean isNotificationSending = IdentityMgtConfig.getInstance().isAccountDisableNotificationSending();
if (notificationType != null && isNotificationSending) {
UserRecoveryDTO dto;
if (MultitenantConstants.SUPER_TENANT_DOMAIN_NAME.equals(tenantDomain)) {
dto = new UserRecoveryDTO(userName);
} else {
UserDTO userDTO = new UserDTO(UserCoreUtil.addTenantDomainToEntry(userName, tenantDomain));
userDTO.setTenantId(tenantID);
dto = new UserRecoveryDTO(userDTO);
}
dto.setNotification(IdentityMgtConstants.Notification.ACCOUNT_DISABLE);
dto.setNotificationType(notificationType);
IdentityMgtServiceComponent.getRecoveryProcessor().recoverWithNotification(dto);
if (log.isDebugEnabled()) {
log.debug("Account enabled notification is sent in " + notificationType);
}
}
} catch (UserStoreException | IdentityException e) {
log.error("Error occurred while trying to disable the account " + userName, e);
throw new IdentityMgtServiceException("Error occurred while trying to disable the account " + userName, e);
}
}
use of org.wso2.carbon.identity.test.integration.service.stub.UserDTO in project carbon-identity-framework by wso2.
the class UserIdentityManagementService method updateCredential.
/**
* proceed updating credentials of user
*
* @param captchaInfoBean bean class that contains captcha information
* @return True, if successful in verifying and hence updating the credentials.
*/
public VerificationBean updateCredential(String userName, String confirmation, String password, CaptchaInfoBean captchaInfoBean) {
RecoveryProcessor recoveryProcessor = IdentityMgtServiceComponent.getRecoveryProcessor();
if (IdentityMgtConfig.getInstance().isCaptchaVerificationInternallyManaged()) {
try {
CaptchaUtil.processCaptchaInfoBean(captchaInfoBean);
} catch (Exception e) {
log.error("Error while processing captcha bean.", e);
return new VerificationBean(VerificationBean.ERROR_CODE_INVALID_CAPTCHA);
}
}
try {
UserDTO userDTO = Utils.processUserId(userName);
if (recoveryProcessor.verifyConfirmationKey(confirmation).isVerified()) {
Utils.updatePassword(userDTO.getUserId(), userDTO.getTenantId(), password);
log.info("Credential is updated for user : " + userDTO.getUserId() + " and tenant domain : " + userDTO.getTenantDomain());
return new VerificationBean(true);
} else {
log.warn("Invalid user tried to update credential with user Id : " + userDTO.getUserId() + " and tenant domain : " + userDTO.getTenantDomain());
}
} catch (Exception e) {
log.error("Error while updating credential for user : " + userName, e);
}
return new VerificationBean(VerificationBean.ERROR_CODE_UNEXPECTED);
}
use of org.wso2.carbon.identity.test.integration.service.stub.UserDTO in project carbon-identity-framework by wso2.
the class IdentityMgtEventListener method sendEmail.
private void sendEmail(String userName, int tenantId, String notification) {
UserRecoveryDTO dto;
String tenantDomain = IdentityTenantUtil.getTenantDomain(tenantId);
if (MultitenantConstants.SUPER_TENANT_DOMAIN_NAME.equals(tenantDomain)) {
dto = new UserRecoveryDTO(userName);
} else {
UserDTO userDTO = new UserDTO(UserCoreUtil.addTenantDomainToEntry(userName, tenantDomain));
userDTO.setTenantId(tenantId);
dto = new UserRecoveryDTO(userDTO);
}
dto.setNotification(notification);
dto.setNotificationType(EMAIL_NOTIFICATION_TYPE);
try {
IdentityMgtServiceComponent.getRecoveryProcessor().recoverWithNotification(dto);
} catch (IdentityException e) {
// proceed with the rest of the flow even if the email is not sent
log.error("Email notification sending failed for user:" + userName + " for " + notification);
}
}
use of org.wso2.carbon.identity.test.integration.service.stub.UserDTO in project carbon-identity-framework by wso2.
the class RecoveryProcessor method createConfirmationCode.
public void createConfirmationCode(UserDTO userDTO, String code) throws IdentityException {
String key = UUID.randomUUID().toString();
UserRecoveryDataDO dataDO = new UserRecoveryDataDO(userDTO.getUserId(), userDTO.getTenantId(), key, code);
dataStore.invalidate(userDTO.getUserId(), userDTO.getTenantId());
dataStore.store(dataDO);
}
Aggregations