use of org.wso2.carbon.identity.recovery.confirmation.ResendConfirmationManager in project identity-governance by wso2-extensions.
the class MeApiServiceImpl method doResendConfirmationCode.
private NotificationResponseBean doResendConfirmationCode(String recoveryScenario, NotificationResponseBean notificationResponseBean, ResendCodeRequestDTO resendCodeRequestDTO) {
UserRecoveryData userRecoveryData = null;
// Currently this me/resend-code API supports resend code during mobile verification scenario only.
if (RecoveryScenarios.MOBILE_VERIFICATION_ON_UPDATE.toString().equals(recoveryScenario)) {
userRecoveryData = Utils.getUserRecoveryData(resendCodeRequestDTO, recoveryScenario);
}
if (userRecoveryData == null) {
return notificationResponseBean;
}
ResendConfirmationManager resendConfirmationManager = Utils.getResendConfirmationManager();
if (RecoveryScenarios.MOBILE_VERIFICATION_ON_UPDATE.toString().equals(recoveryScenario) && RecoveryScenarios.MOBILE_VERIFICATION_ON_UPDATE.equals(userRecoveryData.getRecoveryScenario()) && RecoverySteps.VERIFY_MOBILE_NUMBER.equals(userRecoveryData.getRecoveryStep())) {
notificationResponseBean = setNotificationResponseBean(resendConfirmationManager, RecoveryScenarios.MOBILE_VERIFICATION_ON_UPDATE.toString(), RecoverySteps.VERIFY_MOBILE_NUMBER.toString(), IdentityRecoveryConstants.NOTIFICATION_TYPE_VERIFY_MOBILE_ON_UPDATE, resendCodeRequestDTO);
}
return notificationResponseBean;
}
use of org.wso2.carbon.identity.recovery.confirmation.ResendConfirmationManager in project identity-governance by wso2-extensions.
the class MeApiServiceImplTest method testMeResendCodePost.
@Test
public void testMeResendCodePost() throws IdentityRecoveryException {
try {
String carbonHome = Paths.get(System.getProperty("user.dir"), "src", "test", "resources").toString();
System.setProperty(CarbonBaseConstants.CARBON_HOME, carbonHome);
PrivilegedCarbonContext.startTenantFlow();
PrivilegedCarbonContext.getThreadLocalCarbonContext().setUsername(USERNAME);
PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantId(-1234);
Mockito.when(resendConfirmationManager.resendConfirmationCode(isNull(), anyString(), anyString(), anyString(), isNull())).thenReturn(notificationResponseBean);
mockedUtils.when(() -> Utils.getUserRecoveryData(any(ResendCodeRequestDTO.class), anyString())).thenReturn(userRecoveryData);
mockedUtils.when(Utils::getResendConfirmationManager).thenReturn(resendConfirmationManager);
Mockito.when(userRecoveryData.getRecoveryScenario()).thenReturn(RecoveryScenarios.getRecoveryScenario("MOBILE_VERIFICATION_ON_UPDATE"));
Mockito.when(userRecoveryData.getRecoveryStep()).thenReturn(RecoverySteps.getRecoveryStep("VERIFY_MOBILE_NUMBER"));
assertEquals(meApiService.meResendCodePost(meResendCodeRequestDTO()).getStatus(), 201);
assertEquals(meApiService.meResendCodePost(meResendCodeRequestDTOWithInvalidScenarioProperty()).getStatus(), 400);
mockedUtils.when(() -> Utils.getUserRecoveryData(any(ResendCodeRequestDTO.class), anyString())).thenReturn(null);
assertEquals(meApiService.meResendCodePost(meResendCodeRequestDTO()).getStatus(), 400);
Mockito.when(userRecoveryData.getRecoveryScenario()).thenReturn(RecoveryScenarios.getRecoveryScenario("ASK_PASSWORD"));
assertEquals(meApiService.meResendCodePost(meResendCodeRequestDTO()).getStatus(), 400);
} finally {
PrivilegedCarbonContext.endTenantFlow();
}
}
use of org.wso2.carbon.identity.recovery.confirmation.ResendConfirmationManager in project identity-governance by wso2-extensions.
the class UserSelfRegistrationManager method resendConfirmationCode.
/**
* This method is deprecated.
*
* @since 1.3.51
* @deprecated New APIs have been provided.
* Use
* {@link org.wso2.carbon.identity.recovery.confirmation.ResendConfirmationManager#resendConfirmationCode(User, String, String, String, Property[])}
* method.
*/
@Deprecated
public NotificationResponseBean resendConfirmationCode(User user, Property[] properties) throws IdentityRecoveryException {
if (StringUtils.isBlank(user.getTenantDomain())) {
String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain();
if (StringUtils.isBlank(tenantDomain)) {
tenantDomain = MultitenantConstants.SUPER_TENANT_DOMAIN_NAME;
}
user.setTenantDomain(tenantDomain);
log.info("confirmUserSelfRegistration :Tenant domain is not in the request. set to default for " + "user : " + user.getUserName());
}
if (StringUtils.isBlank(user.getUserStoreDomain())) {
user.setUserStoreDomain(IdentityUtil.getPrimaryDomainName());
log.info("confirmUserSelfRegistration :User store domain is not in the request. set to default " + "for user : " + user.getUserName());
}
boolean selfRegistrationEnabled = Boolean.parseBoolean(Utils.getSignUpConfigs(IdentityRecoveryConstants.ConnectorConfig.ENABLE_SELF_SIGNUP, user.getTenantDomain()));
if (!selfRegistrationEnabled) {
throw Utils.handleClientException(IdentityRecoveryConstants.ErrorMessages.ERROR_CODE_DISABLE_SELF_SIGN_UP, user.getUserName());
}
ResendConfirmationManager resendConfirmationManager = ResendConfirmationManager.getInstance();
NotificationResponseBean notificationResponseBean = resendConfirmationManager.resendConfirmationCode(user, RecoveryScenarios.SELF_SIGN_UP.toString(), RecoverySteps.CONFIRM_SIGN_UP.toString(), IdentityRecoveryConstants.NOTIFICATION_TYPE_RESEND_ACCOUNT_CONFIRM, properties);
notificationResponseBean.setCode(IdentityRecoveryConstants.SuccessEvents.SUCCESS_STATUS_CODE_RESEND_CONFIRMATION_CODE.getCode());
notificationResponseBean.setMessage(IdentityRecoveryConstants.SuccessEvents.SUCCESS_STATUS_CODE_RESEND_CONFIRMATION_CODE.getMessage());
return notificationResponseBean;
}
use of org.wso2.carbon.identity.recovery.confirmation.ResendConfirmationManager in project identity-governance by wso2-extensions.
the class ResendCodeApiServiceImpl method doResendConfirmationCode.
private NotificationResponseBean doResendConfirmationCode(String recoveryScenario, NotificationResponseBean notificationResponseBean, ResendCodeRequestDTO resendCodeRequestDTO) {
UserRecoveryData userRecoveryData = Utils.getUserRecoveryData(resendCodeRequestDTO, recoveryScenario);
if (userRecoveryData == null) {
return notificationResponseBean;
}
ResendConfirmationManager resendConfirmationManager = Utils.getResendConfirmationManager();
if (RecoveryScenarios.ASK_PASSWORD.toString().equals(recoveryScenario) && RecoveryScenarios.ASK_PASSWORD.equals(userRecoveryData.getRecoveryScenario()) && RecoverySteps.UPDATE_PASSWORD.equals(userRecoveryData.getRecoveryStep())) {
notificationResponseBean = setNotificationResponseBean(resendConfirmationManager, RecoveryScenarios.ASK_PASSWORD.toString(), RecoverySteps.UPDATE_PASSWORD.toString(), IdentityRecoveryConstants.NOTIFICATION_TYPE_RESEND_ASK_PASSWORD, resendCodeRequestDTO);
} else if (RecoveryScenarios.NOTIFICATION_BASED_PW_RECOVERY.toString().equals(recoveryScenario) && RecoveryScenarios.NOTIFICATION_BASED_PW_RECOVERY.equals(userRecoveryData.getRecoveryScenario()) && RecoverySteps.UPDATE_PASSWORD.equals(userRecoveryData.getRecoveryStep())) {
notificationResponseBean = setNotificationResponseBean(resendConfirmationManager, RecoveryScenarios.NOTIFICATION_BASED_PW_RECOVERY.toString(), RecoverySteps.UPDATE_PASSWORD.toString(), IdentityRecoveryConstants.NOTIFICATION_TYPE_RESEND_PASSWORD_RESET, resendCodeRequestDTO);
} else if (RecoveryScenarios.SELF_SIGN_UP.toString().equals(recoveryScenario) && RecoveryScenarios.SELF_SIGN_UP.equals(userRecoveryData.getRecoveryScenario()) && RecoverySteps.CONFIRM_SIGN_UP.equals(userRecoveryData.getRecoveryStep())) {
notificationResponseBean = setNotificationResponseBean(resendConfirmationManager, RecoveryScenarios.SELF_SIGN_UP.toString(), RecoverySteps.CONFIRM_SIGN_UP.toString(), IdentityRecoveryConstants.NOTIFICATION_TYPE_RESEND_ACCOUNT_CONFIRM, resendCodeRequestDTO);
} else if (RecoveryScenarios.ADMIN_FORCED_PASSWORD_RESET_VIA_EMAIL_LINK.toString().equals(recoveryScenario) && RecoveryScenarios.ADMIN_FORCED_PASSWORD_RESET_VIA_EMAIL_LINK.equals(userRecoveryData.getRecoveryScenario()) && RecoverySteps.UPDATE_PASSWORD.equals(userRecoveryData.getRecoveryStep())) {
notificationResponseBean = setNotificationResponseBean(resendConfirmationManager, RecoveryScenarios.ADMIN_FORCED_PASSWORD_RESET_VIA_EMAIL_LINK.toString(), RecoverySteps.UPDATE_PASSWORD.toString(), IdentityRecoveryConstants.NOTIFICATION_TYPE_RESEND_ADMIN_FORCED_PASSWORD_RESET, resendCodeRequestDTO);
} else if (RecoveryScenarios.ADMIN_FORCED_PASSWORD_RESET_VIA_OTP.toString().equals(recoveryScenario) && RecoveryScenarios.ADMIN_FORCED_PASSWORD_RESET_VIA_OTP.equals(userRecoveryData.getRecoveryScenario()) && RecoverySteps.UPDATE_PASSWORD.equals(userRecoveryData.getRecoveryStep())) {
notificationResponseBean = setNotificationResponseBean(resendConfirmationManager, RecoveryScenarios.ADMIN_FORCED_PASSWORD_RESET_VIA_OTP.toString(), RecoverySteps.UPDATE_PASSWORD.toString(), IdentityRecoveryConstants.NOTIFICATION_TYPE_RESEND_ADMIN_FORCED_PASSWORD_RESET_WITH_OTP, resendCodeRequestDTO);
} else if (RecoveryScenarios.TENANT_ADMIN_ASK_PASSWORD.toString().equals(recoveryScenario) && RecoveryScenarios.TENANT_ADMIN_ASK_PASSWORD.equals(userRecoveryData.getRecoveryScenario()) && RecoverySteps.UPDATE_PASSWORD.equals(userRecoveryData.getRecoveryStep())) {
notificationResponseBean = setNotificationResponseBean(resendConfirmationManager, RecoveryScenarios.TENANT_ADMIN_ASK_PASSWORD.toString(), RecoverySteps.UPDATE_PASSWORD.toString(), IdentityRecoveryConstants.NOTIFICATION_TYPE_TENANT_REGISTRATION_CONFIRMATION, resendCodeRequestDTO);
} else if (RecoveryScenarios.LITE_SIGN_UP.toString().equals(recoveryScenario) && RecoveryScenarios.LITE_SIGN_UP.equals(userRecoveryData.getRecoveryScenario()) && RecoverySteps.CONFIRM_LITE_SIGN_UP.equals(userRecoveryData.getRecoveryStep())) {
notificationResponseBean = setNotificationResponseBean(resendConfirmationManager, RecoveryScenarios.LITE_SIGN_UP.toString(), RecoverySteps.CONFIRM_LITE_SIGN_UP.toString(), IdentityRecoveryConstants.NOTIFICATION_TYPE_RESEND_LITE_USER_EMAIL_CONFIRM, resendCodeRequestDTO);
} else if (RecoveryScenarios.EMAIL_VERIFICATION_ON_UPDATE.toString().equals(recoveryScenario) && RecoveryScenarios.EMAIL_VERIFICATION_ON_UPDATE.equals(userRecoveryData.getRecoveryScenario()) && RecoverySteps.VERIFY_EMAIL.equals(userRecoveryData.getRecoveryStep())) {
notificationResponseBean = setNotificationResponseBean(resendConfirmationManager, RecoveryScenarios.EMAIL_VERIFICATION_ON_UPDATE.toString(), RecoverySteps.VERIFY_EMAIL.toString(), IdentityRecoveryConstants.NOTIFICATION_TYPE_RESEND_VERIFY_EMAIL_ON_UPDATE, resendCodeRequestDTO);
}
return notificationResponseBean;
}
use of org.wso2.carbon.identity.recovery.confirmation.ResendConfirmationManager in project identity-governance by wso2-extensions.
the class PasswordRecoveryManagerImpl method resend.
/**
* Resend the password recovery information to the user via user specified channel.
*
* @param tenantDomain Tenant Domain
* @param resendCode Resend code
* @param properties Meta properties
* @return ResendConfirmationDTO {@link ResendConfirmationDTO} which wraps the information for a successful
* recovery information resend
* @throws IdentityRecoveryException Error while sending recovery information
*/
@Override
public ResendConfirmationDTO resend(String tenantDomain, String resendCode, Map<String, String> properties) throws IdentityRecoveryException {
validateTenantDomain(tenantDomain);
Property[] metaProperties = buildPropertyList(null, properties);
ResendConfirmationManager resendConfirmationManager = ResendConfirmationManager.getInstance();
try {
return resendConfirmationManager.resendConfirmation(tenantDomain, resendCode, RecoveryScenarios.NOTIFICATION_BASED_PW_RECOVERY.name(), RecoverySteps.UPDATE_PASSWORD.name(), IdentityRecoveryConstants.NOTIFICATION_TYPE_RESEND_PASSWORD_RESET, metaProperties);
} catch (IdentityRecoveryException e) {
e.setErrorCode(Utils.prependOperationScenarioToErrorCode(e.getErrorCode(), IdentityRecoveryConstants.PASSWORD_RECOVERY_SCENARIO));
throw e;
}
}
Aggregations