Search in sources :

Example 1 with RecoveryChannelInformation

use of org.wso2.carbon.identity.rest.api.user.recovery.v1.model.RecoveryChannelInformation in project identity-api-user by wso2.

the class PasswordRecoveryService method buildRecoveryChannelInformation.

/**
 * Method to build recovery channel information.
 *
 * @param recoveryInformationDTO RecoveryInformation with recovery information
 * @return RecoveryChannelInformation
 */
private RecoveryChannelInformation buildRecoveryChannelInformation(RecoveryInformationDTO recoveryInformationDTO) {
    RecoveryChannelInfoDTO recoveryChannelInfoDTO = recoveryInformationDTO.getRecoveryChannelInfoDTO();
    List<RecoveryChannel> channels = RecoveryUtil.buildRecoveryChannelInformation(recoveryChannelInfoDTO.getNotificationChannelDTOs());
    RecoveryChannelInformation recoveryChannelInformation = new RecoveryChannelInformation();
    recoveryChannelInformation.setRecoveryCode(recoveryChannelInfoDTO.getRecoveryCode());
    recoveryChannelInformation.setChannels(channels);
    return recoveryChannelInformation;
}
Also used : RecoveryChannel(org.wso2.carbon.identity.rest.api.user.recovery.v1.model.RecoveryChannel) RecoveryChannelInformation(org.wso2.carbon.identity.rest.api.user.recovery.v1.model.RecoveryChannelInformation) RecoveryChannelInfoDTO(org.wso2.carbon.identity.recovery.dto.RecoveryChannelInfoDTO)

Example 2 with RecoveryChannelInformation

use of org.wso2.carbon.identity.rest.api.user.recovery.v1.model.RecoveryChannelInformation 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;
}
Also used : AccountRecoveryType(org.wso2.carbon.identity.rest.api.user.recovery.v1.model.AccountRecoveryType)

Example 3 with RecoveryChannelInformation

use of org.wso2.carbon.identity.rest.api.user.recovery.v1.model.RecoveryChannelInformation 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;
}
Also used : AccountRecoveryType(org.wso2.carbon.identity.rest.api.user.recovery.v1.model.AccountRecoveryType) RecoveryChannelInformation(org.wso2.carbon.identity.rest.api.user.recovery.v1.model.RecoveryChannelInformation) APICall(org.wso2.carbon.identity.rest.api.user.recovery.v1.model.APICall) ArrayList(java.util.ArrayList)

Example 4 with RecoveryChannelInformation

use of org.wso2.carbon.identity.rest.api.user.recovery.v1.model.RecoveryChannelInformation 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;
}
Also used : AccountRecoveryType(org.wso2.carbon.identity.rest.api.user.recovery.v1.model.AccountRecoveryType) RecoveryChannel(org.wso2.carbon.identity.rest.api.user.recovery.v1.model.RecoveryChannel) RecoveryChannelInformation(org.wso2.carbon.identity.rest.api.user.recovery.v1.model.RecoveryChannelInformation) RecoveryChannelInfoDTO(org.wso2.carbon.identity.recovery.dto.RecoveryChannelInfoDTO) APICall(org.wso2.carbon.identity.rest.api.user.recovery.v1.model.APICall) ArrayList(java.util.ArrayList)

Aggregations

AccountRecoveryType (org.wso2.carbon.identity.rest.api.user.recovery.v1.model.AccountRecoveryType)3 RecoveryChannelInformation (org.wso2.carbon.identity.rest.api.user.recovery.v1.model.RecoveryChannelInformation)3 ArrayList (java.util.ArrayList)2 RecoveryChannelInfoDTO (org.wso2.carbon.identity.recovery.dto.RecoveryChannelInfoDTO)2 APICall (org.wso2.carbon.identity.rest.api.user.recovery.v1.model.APICall)2 RecoveryChannel (org.wso2.carbon.identity.rest.api.user.recovery.v1.model.RecoveryChannel)2