当前位置: 首页>>代码示例>>Java>>正文


Java MultitenantUtils.getTenantDomain方法代码示例

本文整理汇总了Java中org.wso2.carbon.utils.multitenancy.MultitenantUtils.getTenantDomain方法的典型用法代码示例。如果您正苦于以下问题:Java MultitenantUtils.getTenantDomain方法的具体用法?Java MultitenantUtils.getTenantDomain怎么用?Java MultitenantUtils.getTenantDomain使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.wso2.carbon.utils.multitenancy.MultitenantUtils的用法示例。


在下文中一共展示了MultitenantUtils.getTenantDomain方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getUser

import org.wso2.carbon.utils.multitenancy.MultitenantUtils; //导入方法依赖的package包/类
/**
 * Build user object from complete username
 * @param userName
 * @return
 */
public static UserDTO getUser(String userName) {

    if (userName == null) {
        return null;
    }

    String userStoreDomain = IdentityUtil.extractDomainFromName(userName);
    String tenantDomain = MultitenantUtils.getTenantDomain(userName);
    String userNameWithoutTenantDomainAndUserStoreDomain = MultitenantUtils
            .getTenantAwareUsername(UserCoreUtil.removeDomainFromName(userName));

    UserDTO user = new UserDTO();
    user.setUsername(userNameWithoutTenantDomainAndUserStoreDomain);
    user.setRealm(userStoreDomain);
    user.setTenantDomain(tenantDomain);

    return user;
}
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:24,代码来源:AuthenticationEndpointUtil.java

示例2: getUserFromUserName

import org.wso2.carbon.utils.multitenancy.MultitenantUtils; //导入方法依赖的package包/类
/**
 * Returns a User object constructed from fully qualified username
 *
 * @param username Fully qualified username
 * @return User object
 * @throws IllegalArgumentException
 */
public static User getUserFromUserName(String username) {

    User user = new User();
    if (StringUtils.isNotBlank(username)) {
        String tenantDomain = MultitenantUtils.getTenantDomain(username);
        String tenantAwareUsername = MultitenantUtils.getTenantAwareUsername(username);
        String tenantAwareUsernameWithNoUserDomain = UserCoreUtil.removeDomainFromName(tenantAwareUsername);
        String userStoreDomain = IdentityUtil.extractDomainFromName(username).toUpperCase();
        user.setUserName(tenantAwareUsernameWithNoUserDomain);
        if (StringUtils.isNotEmpty(tenantDomain)) {
            user.setTenantDomain(tenantDomain);
        } else {
            user.setTenantDomain(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME);
        }
        if (StringUtils.isNotEmpty(userStoreDomain)) {
            user.setUserStoreDomain(userStoreDomain);
        } else {
            user.setTenantDomain(UserCoreConstants.PRIMARY_DEFAULT_DOMAIN_NAME);
        }
    }
    return user;
}
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:30,代码来源:User.java

示例3: isUserStoreInUsernameCaseSensitive

import org.wso2.carbon.utils.multitenancy.MultitenantUtils; //导入方法依赖的package包/类
/**
 * Check the case sensitivity of the user store in which the user is in.
 *
 * @param username Full qualified username
 * @return
 */
public static boolean isUserStoreInUsernameCaseSensitive(String username) {

    boolean isUsernameCaseSensitive = true;
    try {
        String tenantDomain = MultitenantUtils.getTenantDomain(username);
        int tenantId = IdentityTenantUtil.getRealmService().getTenantManager().getTenantId(tenantDomain);
        return isUserStoreInUsernameCaseSensitive(username, tenantId);
    } catch (UserStoreException e) {
        if (log.isDebugEnabled()) {
            log.debug("Error while reading user store property CaseInsensitiveUsername. Considering as case " +
                    "sensitive.");
        }
    }
    return isUsernameCaseSensitive;
}
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:22,代码来源:IdentityUtil.java

示例4: getTenantIdOfUser

import org.wso2.carbon.utils.multitenancy.MultitenantUtils; //导入方法依赖的package包/类
/**
 * Get the tenant id of the given user.
 *
 * @param username Username
 * @return Tenant Id of domain user belongs to.
 * @throws IdentityRuntimeException Error when getting the tenant Id from tenant domain
 */
public static int getTenantIdOfUser(String username) throws IdentityRuntimeException {

    int tenantId = MultitenantConstants.INVALID_TENANT_ID;
    String domainName = MultitenantUtils.getTenantDomain(username);
    if (domainName != null) {
        try {
            TenantManager tenantManager = IdentityTenantUtil.getRealmService().getTenantManager();
            tenantId = tenantManager.getTenantId(domainName);
        } catch (UserStoreException e) {
            String errorMsg = "Error when getting the tenant id from the tenant domain : " + domainName;
            throw IdentityRuntimeException.error(errorMsg, e);
        }
    }
    if(tenantId == MultitenantConstants.INVALID_TENANT_ID){
        throw IdentityRuntimeException.error("Invalid tenant domain of user " + username);
    } else {
        return tenantId;
    }
}
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:27,代码来源:IdentityTenantUtil.java

示例5: getUser

import org.wso2.carbon.utils.multitenancy.MultitenantUtils; //导入方法依赖的package包/类
/**
 * Build user object from complete username
 * @param userName
 * @return
 */
public User getUser(String userName) {

    if (userName == null) {
        return null;
    }

    String userStoreDomain = extractDomainFromName(userName);
    String tenantDomain = MultitenantUtils.getTenantDomain(userName);
    String userNameWithoutTenantDomainAndUserStoreDomain = MultitenantUtils
            .getTenantAwareUsername(UserCoreUtil.removeDomainFromName(userName));

    User user = new User();
    user.setUsername(userNameWithoutTenantDomainAndUserStoreDomain);
    user.setRealm(userStoreDomain);
    user.setTenantDomain(tenantDomain);

    return user;
}
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:24,代码来源:IdentityManagementServiceUtil.java

示例6: addUser

import org.wso2.carbon.utils.multitenancy.MultitenantUtils; //导入方法依赖的package包/类
public void addUser(UserDTO user) throws Exception {
    UserFieldDTO[] userFieldDTOs = null;
    Map<String, String> userClaims = null;

    userFieldDTOs = user.getUserFields();
    userClaims = new HashMap<String, String>();

    if (userFieldDTOs != null) {
        for (UserFieldDTO userFieldDTO : userFieldDTOs) {
            userClaims.put(userFieldDTO.getClaimUri(), userFieldDTO.getFieldValue());
        }
    }

    UserRealm realm = null;
    String tenantAwareUserName = MultitenantUtils.getTenantAwareUsername(user.getUserName());
    String tenantName = MultitenantUtils.getTenantDomain(user.getUserName());
    realm = IdentityTenantUtil.getRealm(tenantName, null);
    addUser(tenantAwareUserName, user.getPassword(), userClaims, null, realm);
}
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:20,代码来源:UserRegistrationService.java

示例7: getMobileNumberForUsername

import org.wso2.carbon.utils.multitenancy.MultitenantUtils; //导入方法依赖的package包/类
/**
 * Get the mobile number for Username.
 *
 * @param username the username
 * @return mobile number
 * @throws SMSOTPException
 */
public static String getMobileNumberForUsername(String username) throws SMSOTPException,
        AuthenticationFailedException {
    UserRealm userRealm;
    String mobile;
    try {
        String tenantDomain = MultitenantUtils.getTenantDomain(username);
        String tenantAwareUsername = MultitenantUtils.getTenantAwareUsername(username);
        userRealm = getUserRealm(tenantDomain);
        if (userRealm != null) {
            mobile = userRealm.getUserStoreManager()
                    .getUserClaimValue(tenantAwareUsername, SMSOTPConstants.MOBILE_CLAIM, null);
        } else {
            throw new SMSOTPException("Cannot find the user realm for the given tenant domain : " + tenantDomain);
        }
    } catch (UserStoreException e) {
        throw new SMSOTPException("Cannot find the user " + username + " to get the mobile number ", e);
    }
    return mobile;
}
 
开发者ID:wso2-extensions,项目名称:identity-outbound-auth-sms-otp,代码行数:27,代码来源:SMSOTPUtils.java

示例8: getTenantIdOFUser

import org.wso2.carbon.utils.multitenancy.MultitenantUtils; //导入方法依赖的package包/类
public static int getTenantIdOFUser(String username) throws AuthenticationException {
    int tenantId = 0;
    String domainName = MultitenantUtils.getTenantDomain(username);
    if (domainName != null) {
        try {
            TenantManager tenantManager = AuthenticatorFrameworkDataHolder.getInstance().getRealmService()
                    .getTenantManager();
            tenantId = tenantManager.getTenantId(domainName);
        } catch (UserStoreException e) {
            String errorMsg = "Error when getting the tenant id from the tenant domain : " +
                    domainName;
            log.error(errorMsg, e);
            throw new AuthenticationException(errorMsg, e);
        }
    }
    return tenantId;
}
 
开发者ID:wso2,项目名称:carbon-device-mgt,代码行数:18,代码来源:Utils.java

示例9: validateToken

import org.wso2.carbon.utils.multitenancy.MultitenantUtils; //导入方法依赖的package包/类
/**
 * This method gets a string accessToken and validates it and generate the OAuth2ClientApplicationDTO
 * containing the validity and user details if valid.
 *
 * @param token which need to be validated.
 * @return OAuthValidationResponse with the validated results.
 */
public OAuthValidationResponse validateToken(String token) throws RemoteException{
    OAuth2TokenValidationRequestDTO validationRequest = new OAuth2TokenValidationRequestDTO();
    OAuth2TokenValidationRequestDTO.OAuth2AccessToken accessToken =
            validationRequest.new OAuth2AccessToken();
    accessToken.setTokenType(BEARER_TOKEN_TYPE);
    accessToken.setIdentifier(token);
    validationRequest.setAccessToken(accessToken);
    OAuth2TokenValidationResponseDTO tokenValidationResponse = OAuthAuthenticatorDataHolder.getInstance().
            getOAuth2TokenValidationService().findOAuthConsumerIfTokenIsValid(validationRequest).getAccessTokenValidationResponse();
    boolean isValid = tokenValidationResponse.isValid();
    String userName = null;
    String tenantDomain = null;
    if (isValid) {
        userName = MultitenantUtils.getTenantAwareUsername(
                tokenValidationResponse.getAuthorizedUser());
        tenantDomain =
                MultitenantUtils.getTenantDomain(tokenValidationResponse.getAuthorizedUser());
    }
    return new OAuthValidationResponse(userName, tenantDomain, isValid);
}
 
开发者ID:wso2,项目名称:carbon-device-mgt,代码行数:28,代码来源:LocalOAuthValidator.java

示例10: validateToken

import org.wso2.carbon.utils.multitenancy.MultitenantUtils; //导入方法依赖的package包/类
/**
 * This method gets a string accessToken and validates it and generate the OAuth2ClientApplicationDTO
 * containing the validity and user details if valid.
 *
 * @param token which need to be validated.
 * @return OAuthValidationResponse with the validated results.
 */
public OAuthValidationResponse validateToken(String token) {
    OAuth2TokenValidationRequestDTO validationRequest = new OAuth2TokenValidationRequestDTO();
    OAuth2TokenValidationRequestDTO.OAuth2AccessToken accessToken =
            validationRequest.new OAuth2AccessToken();
    accessToken.setTokenType(OauthAuthenticatorConstants.BEARER_TOKEN_TYPE);
    accessToken.setIdentifier(token);
    validationRequest.setAccessToken(accessToken);
    OAuth2TokenValidationResponseDTO tokenValidationResponse = OAuthAuthenticatorDataHolder.getInstance().
            getOAuth2TokenValidationService().findOAuthConsumerIfTokenIsValid(validationRequest).getAccessTokenValidationResponse();
    boolean isValid = tokenValidationResponse.isValid();
    String userName = null;
    String tenantDomain = null;
    if (isValid) {
        userName = MultitenantUtils.getTenantAwareUsername(
                tokenValidationResponse.getAuthorizedUser());
        tenantDomain =
                MultitenantUtils.getTenantDomain(tokenValidationResponse.getAuthorizedUser());
    }
    return new OAuthValidationResponse(userName, tenantDomain, isValid);
}
 
开发者ID:wso2,项目名称:carbon-device-mgt,代码行数:28,代码来源:LocalOAuthValidator.java

示例11: getOpenIDUserRPInfo

import org.wso2.carbon.utils.multitenancy.MultitenantUtils; //导入方法依赖的package包/类
/**
 * Returns RP DTO for the given OpenID and RP
 *
 * @param openID
 * @param rpUrl
 * @return openIDUserRPDTO
 * @throws IdentityProviderException
 */
public OpenIDUserRPDTO getOpenIDUserRPInfo(String openID, String rpUrl) throws IdentityProviderException {

    String userName = null;
    try {
        userName = OpenIDUtil.getUserName(openID);
    } catch (MalformedURLException e) {
        throw new IdentityProviderException("Failed to get username from OpenID " + openID, e);
    }
    String domainName = MultitenantUtils.getTenantDomain(userName);
    int tenantId = IdentityTenantUtil.getTenantId(domainName);

    OpenIDUserRPDO rpdo = null;
    OpenIDUserRPDAO dao = new OpenIDUserRPDAO();
    rpdo = dao.getOpenIDUserRP(userName, rpUrl, tenantId);
    if (rpdo == null) {
        return null;
    }
    return new OpenIDUserRPDTO(rpdo);
}
 
开发者ID:wso2-attic,项目名称:carbon-identity,代码行数:28,代码来源:OpenIDProviderService.java

示例12: authorizeOauthRequestToken

import org.wso2.carbon.utils.multitenancy.MultitenantUtils; //导入方法依赖的package包/类
/**
 * Authorizes the OAuth request token for the given scope. In order for the Consumer to be able
 * to exchange the Request Token for an Access Token, the Consumer MUST obtain approval from the
 * User by directing the User to the Service Provider. The Consumer constructs an HTTP GET
 * request to the Service Provider's User Authorization URL with the following parameters.
 *
 * @param params             A container for the following attributes.
 * @param params:oauth_token (required) : Request token obtained from WSO2.
 * @param params:userName    : User who authorizes the token.
 * @param params:password    : Password of the user who authorizes the token.
 * @return oauth_token, oauth_verifier
 * @throws Exception
 */
public Parameters authorizeOauthRequestToken(Parameters params) throws IdentityException, AuthenticationException {
    String tenantUser = MultitenantUtils.getTenantAwareUsername(params.getAuthorizedbyUserName());
    String domainName = MultitenantUtils.getTenantDomain(params.getAuthorizedbyUserName());
    boolean isAuthenticated = false;
    try {
        isAuthenticated = IdentityTenantUtil
                .getRealm(domainName, params.getAuthorizedbyUserName()).getUserStoreManager()
                .authenticate(tenantUser, params.getAuthorizedbyUserPassword());
    } catch (UserStoreException e) {
        log.error("Error while authenticating the user", e);
        throw IdentityException.error("Error while authenticating the user");
    }
    if (isAuthenticated) {
        OAuthConsumerDAO dao = new OAuthConsumerDAO();
        String oauthVerifier = org.wso2.carbon.identity.oauth.OAuthUtil.getRandomNumber();
        Parameters token = dao.authorizeOAuthToken(params.getOauthToken(), tenantUser,
                oauthVerifier);
        token.setOauthToken(params.getOauthToken());
        token.setOauthTokenVerifier(oauthVerifier);
        return token;
    } else {
        throw new AuthenticationException("User Authentication Failed");
    }
}
 
开发者ID:wso2-attic,项目名称:carbon-identity,代码行数:38,代码来源:OAuthService.java

示例13: addUser

import org.wso2.carbon.utils.multitenancy.MultitenantUtils; //导入方法依赖的package包/类
public void addUser(UserDTO user) throws Exception {
    UserFieldDTO[] userFieldDTOs = null;
    Map<String, String> userClaims = null;

    userFieldDTOs = user.getUserFields();
    userClaims = new HashMap<String, String>();

    if (userFieldDTOs != null) {
        for (UserFieldDTO userFieldDTO : userFieldDTOs) {
            userClaims.put(userFieldDTO.getClaimUri(), userFieldDTO.getFieldValue());
        }
    }

    UserRealm realm = null;
    String tenantAwareUserName = MultitenantUtils.getTenantAwareUsername(user.getUserName());
    String tenantName = MultitenantUtils.getTenantDomain(user.getUserName());
    realm = IdentityTenantUtil.getRealm(tenantName, null);
    Registry registry = IdentityTenantUtil.getRegistry(null, null);
    addUser(tenantAwareUserName, user.getPassword(), userClaims, null, realm);
}
 
开发者ID:wso2-attic,项目名称:carbon-identity,代码行数:21,代码来源:UserRegistrationService.java

示例14: getTenantIdOFUser

import org.wso2.carbon.utils.multitenancy.MultitenantUtils; //导入方法依赖的package包/类
private int getTenantIdOFUser(String username) throws UserStoreException {
    int tenantId = 0;
    String domainName = MultitenantUtils.getTenantDomain(username);
    if (domainName != null) {
        try {
            RealmService service = (RealmService) PrivilegedCarbonContext.getThreadLocalCarbonContext()
                    .getOSGiService(RealmService.class, null);
            TenantManager tenantManager = service.getTenantManager();
            tenantId = tenantManager.getTenantId(domainName);
        } catch (UserStoreException e) {
            String errorMsg = "Error when getting the tenant id from the tenant domain : " +
                    domainName;
            log.error(errorMsg, e);
            throw e;
        }
    }
    return tenantId;
}
 
开发者ID:wso2,项目名称:carbon-registry,代码行数:19,代码来源:RestApiRequestAuthorizationHandler.java

示例15: jsFunction_isUserAuthorized

import org.wso2.carbon.utils.multitenancy.MultitenantUtils; //导入方法依赖的package包/类
public static boolean jsFunction_isUserAuthorized(Context cx,
		Scriptable thisObj, Object[] args, Function funObj) throws Exception {
	boolean isAuthorized = false;
	int argLength = args.length;
	if (argLength != 3) {
		throw new ScriptException("Invalid arguments.");
	}
	String user = (String) args[0];
	String userName = MultitenantUtils.getTenantAwareUsername(user);
	String domainName = MultitenantUtils.getTenantDomain(user);
	RealmService service = ServiceHodler.getRealmService();
	int tenantId = service.getTenantManager().getTenantId(domainName);
	UserRealm realm = service.getTenantUserRealm(tenantId);
	isAuthorized = realm.getAuthorizationManager().isUserAuthorized(userName, (String) args[1], (String) args[2]);
	return isAuthorized;
}
 
开发者ID:wso2,项目名称:carbon-commons,代码行数:17,代码来源:CarbonUserRealmHostObject.java


注:本文中的org.wso2.carbon.utils.multitenancy.MultitenantUtils.getTenantDomain方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。