Search in sources :

Example 1 with UserClaim

use of org.wso2.carbon.identity.recovery.model.UserClaim in project identity-governance by wso2-extensions.

the class RecoveryUtil method getUserClaims.

public static UserClaim[] getUserClaims(List<UserClaimDTO> claimDTOs) {
    UserClaim[] userClaims = new UserClaim[claimDTOs.size()];
    for (int i = 0; i < claimDTOs.size(); i++) {
        UserClaim userClaim = new UserClaim(claimDTOs.get(i).getUri(), claimDTOs.get(i).getValue());
        userClaims[i] = userClaim;
    }
    return userClaims;
}
Also used : UserClaim(org.wso2.carbon.identity.recovery.model.UserClaim)

Example 2 with UserClaim

use of org.wso2.carbon.identity.recovery.model.UserClaim in project identity-governance by wso2-extensions.

the class NotificationUsernameRecoveryManager method verifyUsername.

/**
 * Recovery username of the user who matches the given set of claims.
 *
 * @param claims       User claims
 * @param tenantDomain Tenant domain
 * @param notify       Notify user existence
 * @return Username if notifications are externally managed
 * @throws IdentityRecoveryException Error while recovering the username
 */
public String verifyUsername(UserClaim[] claims, String tenantDomain, Boolean notify) throws IdentityRecoveryException {
    // Resolve Tenant domain.
    if (StringUtils.isBlank(tenantDomain)) {
        tenantDomain = MultitenantConstants.SUPER_TENANT_DOMAIN_NAME;
    }
    // Resolve notification internally managed status.
    boolean isNotificationInternallyManaged = isNotificationsInternallyManaged(tenantDomain, notify);
    HashMap<String, String> userClaims = buildUserClaimsMap(claims);
    // Validate the claims.
    if (claims.length < 1) {
        throw Utils.handleClientException(IdentityRecoveryConstants.ErrorMessages.ERROR_CODE_NO_FIELD_FOUND_FOR_USER_RECOVERY, null);
    }
    RecoveryInformationDTO recoveryInformationDTO = initiateUsernameRecovery(userClaims, tenantDomain, isNotificationInternallyManaged);
    /*
        recoveryChannelInfoDTO will be NULL for successful username recovery or when notify user existence in not
        enabled and no user is matched to the given claims.
         */
    if (recoveryInformationDTO == null) {
        return null;
    } else {
        return recoveryInformationDTO.getUsername();
    }
}
Also used : RecoveryInformationDTO(org.wso2.carbon.identity.recovery.dto.RecoveryInformationDTO)

Aggregations

RecoveryInformationDTO (org.wso2.carbon.identity.recovery.dto.RecoveryInformationDTO)1 UserClaim (org.wso2.carbon.identity.recovery.model.UserClaim)1