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


Java UserStoreManager.getUserClaimValues方法代码示例

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


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

示例1: getUser

import org.wso2.carbon.user.api.UserStoreManager; //导入方法依赖的package包/类
@Override public User getUser(String username, int tenantId) throws UserManagementException {
    UserStoreManager userStoreManager;
    User user;
    try {
        userStoreManager = DeviceMgtUserDataHolder.getInstance().getRealmService().getTenantUserRealm(tenantId)
                                                  .getUserStoreManager();
        user = new User(username);

        Claim[] claims = userStoreManager.getUserClaimValues(username, null);
        Map<String,String> claimMap = new HashMap<String, String>();
        for(Claim claim:claims){
            String claimURI = claim.getClaimUri();
            String value = claim.getValue();
            claimMap.put(claimURI, value);
        }

        setUserClaims(user, claimMap);
    } catch (UserStoreException userStoreEx) {
        String errorMsg = "User store error in fetching user " + username;
        log.error(errorMsg, userStoreEx);
        throw new UserManagementException(errorMsg, userStoreEx);
    }
    return user;
}
 
开发者ID:wso2-incubator,项目名称:iot-server-appliances,代码行数:25,代码来源:UserManagerImpl.java

示例2: getClaims

import org.wso2.carbon.user.api.UserStoreManager; //导入方法依赖的package包/类
@Override
public SortedMap<String, String> getClaims(String endUserName, String[] requestedClaims) throws IdentityOAuth2Exception {

    SortedMap<String, String> claimValues;
    int tenantId = MultitenantConstants.SUPER_TENANT_ID;
    try {
        tenantId = OAuth2Util.getTenantIdFromUserName(endUserName);
        String tenantAwareUsername = MultitenantUtils.getTenantAwareUsername(endUserName);
        UserStoreManager userStoreManager = OAuthComponentServiceHolder.getRealmService().
                getTenantUserRealm(tenantId).getUserStoreManager();
        claimValues = new TreeMap(userStoreManager.getUserClaimValues(tenantAwareUsername, requestedClaims, null));
    } catch (UserStoreException e) {
        throw new IdentityOAuth2Exception("Error while reading claims for user : " + endUserName, e);
    }
    return claimValues;
}
 
开发者ID:wso2-attic,项目名称:carbon-identity,代码行数:17,代码来源:DefaultClaimsRetriever.java

示例3: getAllUserIdentityClaims

import org.wso2.carbon.user.api.UserStoreManager; //导入方法依赖的package包/类
/**
 * Returns all user claims
 *
 * @param userName
 * @return
 * @throws IdentityMgtServiceException
 */
public static UserIdentityClaimDTO[] getAllUserIdentityClaims(String userName)
        throws IdentityMgtServiceException {
    int tenantId = 0;
    try {
        tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
        UserStoreManager userStoreManager =
                IdentityMgtServiceComponent.getRealmService()
                        .getTenantUserRealm(tenantId)
                        .getUserStoreManager();
        // read all claims and convert them to UserIdentityClaimDTO
        Claim[] claims = userStoreManager.getUserClaimValues(userName, null);
        List<UserIdentityClaimDTO> allDefaultClaims = new ArrayList<UserIdentityClaimDTO>();
        for (Claim claim : claims) {
            if (claim.getClaimUri().contains(UserCoreConstants.DEFAULT_CARBON_DIALECT)) {
                UserIdentityClaimDTO claimDTO = new UserIdentityClaimDTO();
                claimDTO.setClaimUri(claim.getClaimUri());
                claimDTO.setClaimValue(claim.getValue());
                allDefaultClaims.add(claimDTO);
            }
        }
        UserIdentityClaimDTO[] claimDTOs = new UserIdentityClaimDTO[allDefaultClaims.size()];
        return allDefaultClaims.toArray(claimDTOs);
    } catch (UserStoreException e) {
        throw new IdentityMgtServiceException("Error while getting user identity claims", e);
    }
}
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:34,代码来源:UserIdentityManagementUtil.java

示例4: getUsersForTenantAndRole

import org.wso2.carbon.user.api.UserStoreManager; //导入方法依赖的package包/类
@Override
public List<User> getUsersForTenantAndRole(int tenantId, String roleName) throws UserManagementException {

    UserStoreManager userStoreManager;
    String[] userNames;
    ArrayList usersList = new ArrayList();

    try {
        userStoreManager = DeviceMgtUserDataHolder.getInstance().getRealmService().getTenantUserRealm(tenantId)
                .getUserStoreManager();

        userNames = userStoreManager.getUserListOfRole(roleName);
        User newUser;
        for (String userName : userNames) {
            newUser = new User(userName);
            Claim[] claims = userStoreManager.getUserClaimValues(userName, null);
            Map<String,String> claimMap = new HashMap<String, String>();
            for(Claim claim:claims){
                String claimURI = claim.getClaimUri();
                String value = claim.getValue();
                claimMap.put(claimURI, value);
            }
            setUserClaims(newUser, claimMap);
            usersList.add(newUser);
        }
    } catch (UserStoreException userStoreEx) {
        String errorMsg = "User store error in fetching user list for role and tenant tenant id:" + tenantId
                + " role name:" + roleName;
        log.error(errorMsg, userStoreEx);
        throw new UserManagementException(errorMsg, userStoreEx);
    }
    return usersList;
}
 
开发者ID:wso2-incubator,项目名称:iot-server-appliances,代码行数:34,代码来源:UserManagerImpl.java

示例5: getUsersForTenant

import org.wso2.carbon.user.api.UserStoreManager; //导入方法依赖的package包/类
@Override
public List<User> getUsersForTenant(int tenantId) throws UserManagementException {

    UserStoreManager userStoreManager;
    String[] userNames;
    ArrayList usersList = new ArrayList();

    try {
        userStoreManager = DeviceMgtUserDataHolder.getInstance().getRealmService().getTenantUserRealm(tenantId)
                .getUserStoreManager();

        userNames = userStoreManager.listUsers("", -1);
        User newUser;
        for (String userName : userNames) {
            newUser = new User(userName);
            Claim[] claims = userStoreManager.getUserClaimValues(userName, null);
            Map<String,String> claimMap = new HashMap<String, String>();
            for(Claim claim:claims){
                String claimURI = claim.getClaimUri();
                String value = claim.getValue();
                claimMap.put(claimURI, value);
            }
            setUserClaims(newUser, claimMap);
            usersList.add(newUser);
        }
    } catch (UserStoreException userStoreEx) {
        String errorMsg = "User store error in fetching user list for tenant id:" + tenantId;
        log.error(errorMsg, userStoreEx);
        throw new UserManagementException(errorMsg, userStoreEx);
    }

    return usersList;
}
 
开发者ID:wso2-incubator,项目名称:iot-server-appliances,代码行数:34,代码来源:UserManagerImpl.java

示例6: retrieveAllNunNullUserClaimValues

import org.wso2.carbon.user.api.UserStoreManager; //导入方法依赖的package包/类
private Map<String, String> retrieveAllNunNullUserClaimValues(AuthenticatedUser authenticatedUser,
                                                              String tenantDomain,
                                                              String tenantAwareUserName, ClaimManager claimManager,
                                                              UserStoreManager userStore)
        throws FrameworkException {

    Map<String, String> allLocalClaims = new HashMap<>();
    try {

        org.wso2.carbon.user.api.ClaimMapping[] claimMappings = claimManager
                .getAllClaimMappings(ApplicationConstants.LOCAL_IDP_DEFAULT_CLAIM_DIALECT);
        List<String> localClaimURIs = new ArrayList<>();
        for (org.wso2.carbon.user.api.ClaimMapping mapping : claimMappings) {
            String claimURI = mapping.getClaim().getClaimUri();
            localClaimURIs.add(claimURI);
        }
        allLocalClaims = userStore.getUserClaimValues(tenantAwareUserName,
                localClaimURIs.toArray(new String[localClaimURIs.size()]), null);
    } catch (UserStoreException e) {
        if (e.getMessage().contains("UserNotFound")) {
            if (log.isDebugEnabled()) {
                log.debug("User " + tenantAwareUserName + " not found in user store");
            }
        } else {
            throw new FrameworkException("Error occurred while getting all user claims for " +
                    authenticatedUser + " in " + tenantDomain, e);
        }
    }
    if (allLocalClaims == null) {
        allLocalClaims = new HashMap<>();
    }
    return allLocalClaims;
}
 
开发者ID:wso2-attic,项目名称:carbon-identity,代码行数:34,代码来源:DefaultClaimHandler.java


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