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();
}
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;
}
Aggregations