Search in sources :

Example 1 with CodeValidateInfoResponseDTO

use of org.wso2.carbon.identity.user.endpoint.dto.CodeValidateInfoResponseDTO in project identity-governance by wso2-extensions.

the class IntrospectCodeApiServiceImpl method introspectCodePost.

@Override
public Response introspectCodePost(CodeValidationRequestDTO codeValidationRequestDTO) {
    UserSelfRegistrationManager userSelfRegistrationManager = Utils.getUserSelfRegistrationManager();
    CodeValidateInfoResponseDTO codeDetails = null;
    UserRecoveryData recoveryData = null;
    try {
        // Get the map of properties in the request.
        HashMap<String, String> propertyMap = Utils.getPropertiesMap(codeValidationRequestDTO.getProperties());
        // Get externally verified channel information.
        VerifiedChannelDTO verifiedChannelDTO = codeValidationRequestDTO.getVerifiedChannel();
        String verifiedChannelType = null;
        String verifiedChannelClaim = null;
        // Handling verified channel details not in the request.
        if (verifiedChannelDTO != null) {
            verifiedChannelClaim = verifiedChannelDTO.getClaim();
            verifiedChannelType = verifiedChannelDTO.getType();
        }
        // Confirm code.
        recoveryData = userSelfRegistrationManager.introspectUserSelfRegistration(true, codeValidationRequestDTO.getCode(), verifiedChannelType, verifiedChannelClaim, propertyMap);
        if (recoveryData != null && recoveryData.getUser() != null && recoveryData.getUser().getUserName() != null) {
            codeDetails = getCodeIntrospectResponse(recoveryData);
        } else {
            Utils.handleNotFound(IdentityRecoveryConstants.ErrorMessages.ERROR_CODE_INVALID_CODE.getMessage(), IdentityRecoveryConstants.ErrorMessages.ERROR_CODE_INVALID_CODE.getCode());
        }
    } catch (IdentityRecoveryClientException e) {
        if (LOG.isDebugEnabled()) {
            LOG.debug("Client Error while confirming sent in code", e);
        }
        Utils.handleBadRequest(e.getMessage(), e.getErrorCode());
    } catch (IdentityRecoveryException e) {
        Utils.handleInternalServerError(Constants.SERVER_ERROR, e.getErrorCode(), LOG, e);
    } catch (Throwable throwable) {
        Utils.handleInternalServerError(Constants.SERVER_ERROR, IdentityRecoveryConstants.ErrorMessages.ERROR_CODE_UNEXPECTED.getCode(), LOG, throwable);
    }
    return Response.accepted(codeDetails).build();
}
Also used : UserRecoveryData(org.wso2.carbon.identity.recovery.model.UserRecoveryData) UserSelfRegistrationManager(org.wso2.carbon.identity.recovery.signup.UserSelfRegistrationManager) CodeValidateInfoResponseDTO(org.wso2.carbon.identity.user.endpoint.dto.CodeValidateInfoResponseDTO) IdentityRecoveryException(org.wso2.carbon.identity.recovery.IdentityRecoveryException) IdentityRecoveryClientException(org.wso2.carbon.identity.recovery.IdentityRecoveryClientException)

Example 2 with CodeValidateInfoResponseDTO

use of org.wso2.carbon.identity.user.endpoint.dto.CodeValidateInfoResponseDTO in project identity-governance by wso2-extensions.

the class Utils method getCodeIntrospectResponse.

public static CodeValidateInfoResponseDTO getCodeIntrospectResponse(UserRecoveryData userRecoveryData) {
    CodeValidateInfoResponseDTO codeValidateInfoResponseDTO = new CodeValidateInfoResponseDTO();
    codeValidateInfoResponseDTO.setUser(getRecoveryUser(userRecoveryData.getUser()));
    codeValidateInfoResponseDTO.setRecoveryStep(userRecoveryData.getRecoveryStep().name());
    codeValidateInfoResponseDTO.setRecoveryScenario(userRecoveryData.getRecoveryScenario().name());
    codeValidateInfoResponseDTO.setIsExpired(userRecoveryData.isCodeExpired());
    return codeValidateInfoResponseDTO;
}
Also used : CodeValidateInfoResponseDTO(org.wso2.carbon.identity.user.endpoint.dto.CodeValidateInfoResponseDTO)

Aggregations

CodeValidateInfoResponseDTO (org.wso2.carbon.identity.user.endpoint.dto.CodeValidateInfoResponseDTO)2 IdentityRecoveryClientException (org.wso2.carbon.identity.recovery.IdentityRecoveryClientException)1 IdentityRecoveryException (org.wso2.carbon.identity.recovery.IdentityRecoveryException)1 UserRecoveryData (org.wso2.carbon.identity.recovery.model.UserRecoveryData)1 UserSelfRegistrationManager (org.wso2.carbon.identity.recovery.signup.UserSelfRegistrationManager)1