Java Code Examples for org.wso2.carbon.identity.application.common.model.User#setUserStoreDomain()

The following examples show how to use org.wso2.carbon.identity.application.common.model.User#setUserStoreDomain() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: UserIdtoUser.java    From identity-api-server with Apache License 2.0 5 votes vote down vote up
private User extractUser(String userId, String tenantDomain) {

        try {
            String decodedUsername = new String(Base64.getDecoder().decode(userId), StandardCharsets.UTF_8);

            if (StringUtils.isBlank(userId)) {
                throw new WebApplicationException("UserID is empty.");
            }
            String[] strComponent = decodedUsername.split("/");

            String username;
            String realm = UserStoreConfigConstants.PRIMARY;

            if (strComponent.length == 1) {
                username = strComponent[0];
            } else if (strComponent.length == 2) {
                realm = strComponent[0];
                username = strComponent[1];
            } else {
                throw new WebApplicationException("Provided UserID is " + "not in the correct format.");
            }

            User user = new User();
            user.setUserName(username);
            user.setUserStoreDomain(realm);
            user.setTenantDomain(tenantDomain);

            return user;
        } catch (Exception e) {
            throw new APIError(Response.Status.BAD_REQUEST,
                    new ErrorResponse.Builder().withCode(Constants.ErrorMessages.ERROR_CODE_INVALID_USERNAME.getCode())
                            .withMessage(Constants.ErrorMessages.ERROR_CODE_INVALID_USERNAME.getMessage())
                            .withDescription(Constants.ErrorMessages.ERROR_CODE_INVALID_USERNAME.getDescription())
                            .build(log, e, "Invalid userId: " + userId));
        }
    }
 
Example 2
Source File: DefaultProvisioningHandler.java    From carbon-identity-framework with Apache License 2.0 5 votes vote down vote up
private User getAssociatedUser(String tenantDomain, String userStoreDomain, String username) {

        User user = new User();
        user.setTenantDomain(tenantDomain);
        user.setUserStoreDomain(userStoreDomain);
        user.setUserName(MultitenantUtils.getTenantAwareUsername(username));
        return user;
    }
 
Example 3
Source File: ApplicationManagementServiceImpl.java    From carbon-identity-framework with Apache License 2.0 5 votes vote down vote up
/**
 * Create user object from user name and tenantDomain.
 *
 * @param tenantDomain tenantDomain
 * @param username     username
 * @return User
 */
private User getUser(String tenantDomain, String username) {

    User user = new User();
    user.setUserName(UserCoreUtil.removeDomainFromName(username));
    user.setUserStoreDomain(UserCoreUtil.extractDomainFromName(username));
    user.setTenantDomain(tenantDomain);
    return user;
}
 
Example 4
Source File: UserProfileAdmin.java    From carbon-identity-framework with Apache License 2.0 5 votes vote down vote up
private User getUser(String domainAwareUserName) {

        User user = new User();
        user.setTenantDomain(CarbonContext.getThreadLocalCarbonContext().getTenantDomain());
        user.setUserStoreDomain(UserCoreUtil.extractDomainFromName(domainAwareUserName));
        user.setUserName(MultitenantUtils.getTenantAwareUsername(UserCoreUtil.removeDomainFromName(domainAwareUserName)));
        return user;
    }