use of org.wso2.carbon.identity.mgt.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;
}
use of org.wso2.carbon.identity.mgt.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;
}
use of org.wso2.carbon.identity.mgt.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;
}
use of org.wso2.carbon.identity.mgt.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();
}
use of org.wso2.carbon.identity.mgt.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;
}
Aggregations