本文整理汇总了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;
}
示例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;
}
示例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);
}
}
示例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;
}
示例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;
}
示例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;
}