Search in sources :

Example 61 with UserDTO

use of org.wso2.carbon.apimgt.rest.api.store.dto.UserDTO in project identity-governance by wso2-extensions.

the class Utils method getUser.

public static User getUser(SelfRegistrationUserDTO userDTO) {
    User user = new User();
    user.setTenantDomain(userDTO.getTenantDomain());
    user.setUserStoreDomain(userDTO.getRealm());
    user.setUserName(userDTO.getUsername());
    return user;
}
Also used : User(org.wso2.carbon.identity.application.common.model.User)

Example 62 with UserDTO

use of org.wso2.carbon.apimgt.rest.api.store.dto.UserDTO in project identity-governance by wso2-extensions.

the class UtilsTest method buildUserDTO.

private UserDTO buildUserDTO() {
    UserDTO userDTO = new UserDTO();
    userDTO.setUsername("testUser");
    userDTO.setRealm("testRealm");
    return userDTO;
}
Also used : SelfRegistrationUserDTO(org.wso2.carbon.identity.user.endpoint.dto.SelfRegistrationUserDTO) UserDTO(org.wso2.carbon.identity.user.endpoint.dto.UserDTO)

Example 63 with UserDTO

use of org.wso2.carbon.apimgt.rest.api.store.dto.UserDTO in project identity-governance by wso2-extensions.

the class RecoveryUtil method getUser.

public static User getUser(UserDTO userDTO) {
    User user = new User();
    user.setTenantDomain(userDTO.getTenantDomain());
    if (StringUtils.isNotBlank(userDTO.getRealm())) {
        user.setUserStoreDomain(userDTO.getRealm());
    }
    user.setUserName(userDTO.getUsername());
    return user;
}
Also used : User(org.wso2.carbon.identity.application.common.model.User)

Example 64 with UserDTO

use of org.wso2.carbon.apimgt.rest.api.store.dto.UserDTO in project identity-governance by wso2-extensions.

the class RecoverPasswordApiServiceImpl method recoverPasswordPost.

@Override
public Response recoverPasswordPost(RecoveryInitiatingRequestDTO recoveryInitiatingRequest, String type, Boolean notify) {
    String tenantDomainFromContext = (String) IdentityUtil.threadLocalProperties.get().get(Constants.TENANT_NAME_FROM_CONTEXT);
    if (StringUtils.isNotBlank(tenantDomainFromContext)) {
        recoveryInitiatingRequest.getUser().setTenantDomain(tenantDomainFromContext);
    } else {
        recoveryInitiatingRequest.getUser().setTenantDomain(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME);
    }
    UserDTO user = recoveryInitiatingRequest.getUser();
    int tenantIdFromContext = IdentityTenantUtil.getTenantId(user.getTenantDomain());
    ResolvedUserResult resolvedUserResult = FrameworkUtils.processMultiAttributeLoginIdentification(user.getUsername(), user.getTenantDomain());
    if (resolvedUserResult != null && ResolvedUserResult.UserResolvedStatus.SUCCESS.equals(resolvedUserResult.getResolvedStatus())) {
        user.setUsername(resolvedUserResult.getUser().getUsername());
        UserDTO userDTO = recoveryInitiatingRequest.getUser();
        userDTO.setUsername(user.getUsername());
        recoveryInitiatingRequest.setUser(userDTO);
    }
    NotificationPasswordRecoveryManager notificationPasswordRecoveryManager = RecoveryUtil.getNotificationBasedPwdRecoveryManager();
    NotificationResponseBean notificationResponseBean = null;
    try {
        notificationResponseBean = notificationPasswordRecoveryManager.sendRecoveryNotification(RecoveryUtil.getUser(recoveryInitiatingRequest.getUser()), type, notify, RecoveryUtil.getProperties(recoveryInitiatingRequest.getProperties()));
    } catch (IdentityRecoveryClientException e) {
        if (LOG.isDebugEnabled()) {
            LOG.debug("Client Error while sending recovery notification ", e);
        }
        RecoveryUtil.handleBadRequest(e.getMessage(), e.getErrorCode());
    } catch (IdentityRecoveryException e) {
        RecoveryUtil.handleInternalServerError(Constants.SERVER_ERROR, e.getErrorCode(), LOG, e);
    } catch (Throwable throwable) {
        if (throwable != null && StringUtils.equals(Constants.ERROR_MESSAGE_EMAIL_NOT_FOUND, throwable.getMessage())) {
            LOG.error(throwable.getMessage(), throwable);
            RecoveryUtil.handleBadRequest(throwable.getMessage(), Constants.ERROR_CODE_EMAIL_NOT_FOUND);
        }
        RecoveryUtil.handleInternalServerError(Constants.SERVER_ERROR, IdentityRecoveryConstants.ErrorMessages.ERROR_CODE_UNEXPECTED.getCode(), LOG, throwable);
    }
    if (StringUtils.isBlank(notificationResponseBean.getKey())) {
        return Response.accepted().build();
    }
    return Response.accepted(notificationResponseBean.getKey()).build();
}
Also used : NotificationPasswordRecoveryManager(org.wso2.carbon.identity.recovery.password.NotificationPasswordRecoveryManager) NotificationResponseBean(org.wso2.carbon.identity.recovery.bean.NotificationResponseBean) ResolvedUserResult(org.wso2.carbon.identity.multi.attribute.login.mgt.ResolvedUserResult) IdentityRecoveryException(org.wso2.carbon.identity.recovery.IdentityRecoveryException) org.wso2.carbon.identity.recovery.endpoint(org.wso2.carbon.identity.recovery.endpoint) IdentityRecoveryClientException(org.wso2.carbon.identity.recovery.IdentityRecoveryClientException)

Example 65 with UserDTO

use of org.wso2.carbon.apimgt.rest.api.store.dto.UserDTO in project identity-governance by wso2-extensions.

the class ResendCodeApiServiceImplTest method buildUserDTO.

private UserDTO buildUserDTO() {
    UserDTO userDTO = new UserDTO();
    userDTO.setUsername("TestUser");
    userDTO.setTenantDomain("TestTenantDomain");
    userDTO.setRealm("TestRealm");
    return userDTO;
}
Also used : UserDTO(org.wso2.carbon.identity.user.endpoint.dto.UserDTO)

Aggregations

IdentityException (org.wso2.carbon.identity.base.IdentityException)23 UserDTO (org.wso2.carbon.identity.mgt.dto.UserDTO)22 VerificationBean (org.wso2.carbon.identity.mgt.beans.VerificationBean)19 RecoveryProcessor (org.wso2.carbon.identity.mgt.RecoveryProcessor)17 UserStoreException (org.wso2.carbon.user.api.UserStoreException)17 IdentityMgtServiceException (org.wso2.carbon.identity.mgt.IdentityMgtServiceException)14 PrivilegedCarbonContext (org.wso2.carbon.context.PrivilegedCarbonContext)12 Test (org.testng.annotations.Test)10 UserDTO (org.wso2.carbon.identity.user.rename.core.dto.UserDTO)10 UserRecoveryDTO (org.wso2.carbon.identity.mgt.dto.UserRecoveryDTO)9 UserStoreManager (org.wso2.carbon.user.api.UserStoreManager)9 RealmService (org.wso2.carbon.user.core.service.RealmService)9 TenantManager (org.wso2.carbon.user.core.tenant.TenantManager)8 UserDTO (org.wso2.carbon.identity.test.integration.service.stub.UserDTO)7 UserDTO (org.wso2.carbon.identity.user.endpoint.dto.UserDTO)6 NotificationDataDTO (org.wso2.carbon.identity.mgt.dto.NotificationDataDTO)5 UserChallengesDTO (org.wso2.carbon.identity.mgt.dto.UserChallengesDTO)4 User (org.wso2.carbon.apimgt.core.models.User)3 User (org.wso2.carbon.identity.application.common.model.User)3 ChallengeQuestionProcessor (org.wso2.carbon.identity.mgt.ChallengeQuestionProcessor)3