use of org.wso2.carbon.identity.rest.api.user.recovery.v1.model.AccountRecoveryType in project identity-api-user by wso2.
the class PasswordRecoveryService method buildAccountRecoveryType.
/**
* Build recovery information for recover with notifications.
*
* @param recoveryType Recovery type
* @param recoveryChannelInformation RecoveryChannelInformation which wraps recovery channel information
* @param apiCallsArrayList Available API calls
* @return AccountRecoveryType which wraps recovery options available for the user
*/
private AccountRecoveryType buildAccountRecoveryType(String recoveryType, RecoveryChannelInformation recoveryChannelInformation, ArrayList<APICall> apiCallsArrayList) {
AccountRecoveryType accountRecoveryType = new AccountRecoveryType();
accountRecoveryType.setMode(recoveryType);
accountRecoveryType.setChannelInfo(recoveryChannelInformation);
accountRecoveryType.setLinks(apiCallsArrayList);
return accountRecoveryType;
}
use of org.wso2.carbon.identity.rest.api.user.recovery.v1.model.AccountRecoveryType in project identity-api-user by wso2.
the class PasswordRecoveryService method buildPasswordRecoveryInitResponse.
/**
* Build a list of account recovery options available for a successful password recovery.
*
* @param tenantDomain Tenant domain
* @param recoveryInformationDTO RecoveryInformationDTO which wraps the password recovery information
* @return List of {@link AccountRecoveryType}
*/
private List<AccountRecoveryType> buildPasswordRecoveryInitResponse(String tenantDomain, RecoveryInformationDTO recoveryInformationDTO) {
ArrayList<AccountRecoveryType> accountRecoveryTypes = new ArrayList<>();
boolean isNotificationBasedRecoveryEnabled = recoveryInformationDTO.isNotificationBasedRecoveryEnabled();
boolean isQuestionBasedRecoveryAllowedForUser = recoveryInformationDTO.isQuestionBasedRecoveryAllowedForUser();
if (isNotificationBasedRecoveryEnabled) {
// Build next API calls list.
ArrayList<APICall> apiCallsArrayList = new ArrayList<>();
apiCallsArrayList.add(RecoveryUtil.buildApiCall(Constants.APICall.RECOVER_PASSWORD_API.getType(), Constants.RelationStates.NEXT_REL, RecoveryUtil.buildURIForBody(tenantDomain, Constants.APICall.RECOVER_PASSWORD_API.getApiUrl(), Constants.ACCOUNT_RECOVERY_ENDPOINT_BASEPATH), null));
RecoveryChannelInformation recoveryChannelInformation = buildRecoveryChannelInformation(recoveryInformationDTO);
// Build recovery information for recover with notifications.
AccountRecoveryType accountRecoveryType = buildAccountRecoveryType(Constants.RECOVERY_WITH_NOTIFICATIONS, recoveryChannelInformation, apiCallsArrayList);
accountRecoveryTypes.add(accountRecoveryType);
}
if (isQuestionBasedRecoveryAllowedForUser) {
// Build next API calls list.
ArrayList<APICall> apiCallsArrayList = new ArrayList<>();
apiCallsArrayList.add(RecoveryUtil.buildApiCall(Constants.APICall.RECOVER_WITH_SECURITY_QUESTIONS_API.getType(), Constants.RelationStates.NEXT_REL, RecoveryUtil.buildURIForBody(tenantDomain, Constants.APICall.RECOVER_WITH_SECURITY_QUESTIONS_API.getApiUrl(), Constants.CHALLENGE_QUESTIONS_ENDPOINT_BASEPATH), recoveryInformationDTO.getUsername()));
// Build recovery information for recover with security questions.
AccountRecoveryType accountRecoveryType = buildAccountRecoveryType(Constants.RECOVER_WITH_CHALLENGE_QUESTIONS, null, apiCallsArrayList);
accountRecoveryTypes.add(accountRecoveryType);
}
return accountRecoveryTypes;
}
use of org.wso2.carbon.identity.rest.api.user.recovery.v1.model.AccountRecoveryType in project identity-api-user by wso2.
the class UsernameRecoveryService method buildUsernameRecoveryInitResponse.
/**
* Build a list of account recovery options available for successful user identification and channel retrieval.
*
* @param recoveryInformationDTO User recovery information object {@link RecoveryInformationDTO}
* @param tenantDomain Tenant domain
* @return List of {@link AccountRecoveryType}
*/
private List<AccountRecoveryType> buildUsernameRecoveryInitResponse(RecoveryInformationDTO recoveryInformationDTO, String tenantDomain) {
RecoveryChannelInfoDTO recoveryChannelInfoDTO = recoveryInformationDTO.getRecoveryChannelInfoDTO();
List<RecoveryChannel> channels = RecoveryUtil.buildRecoveryChannelInformation(recoveryChannelInfoDTO.getNotificationChannelDTOs());
// Build Recovery Channel Information.
RecoveryChannelInformation recoveryChannelInformation = new RecoveryChannelInformation();
recoveryChannelInformation.setRecoveryCode(recoveryChannelInfoDTO.getRecoveryCode());
recoveryChannelInformation.setChannels(channels);
// Build next API calls.
ArrayList<APICall> apiCallsArrayList = new ArrayList<>();
apiCallsArrayList.add(RecoveryUtil.buildApiCall(Constants.APICall.RECOVER_USERNAME_API.getType(), Constants.RelationStates.NEXT_REL, RecoveryUtil.buildURIForBody(tenantDomain, Constants.APICall.RECOVER_USERNAME_API.getApiUrl(), Constants.ACCOUNT_RECOVERY_ENDPOINT_BASEPATH), null));
// Build recovery type information.
AccountRecoveryType accountRecoveryType = new AccountRecoveryType();
accountRecoveryType.setMode(Constants.RECOVERY_WITH_NOTIFICATIONS);
accountRecoveryType.setChannelInfo(recoveryChannelInformation);
accountRecoveryType.setLinks(apiCallsArrayList);
ArrayList<AccountRecoveryType> recoveryTypeDTOS = new ArrayList<>();
recoveryTypeDTOS.add(accountRecoveryType);
return recoveryTypeDTOS;
}
Aggregations