use of org.wso2.carbon.user.api.ClaimManager in project carbon-apimgt by wso2.
the class APIUtil method getClaims.
/**
* Returns the user claims for the given user.
*
* @param endUserName name of the user whose claims needs to be returned
* @param tenantId tenant id of the user
* @param dialectURI claim dialect URI
* @return claims map
* @throws APIManagementException
*/
public static SortedMap<String, String> getClaims(String endUserName, int tenantId, String dialectURI) throws APIManagementException {
SortedMap<String, String> claimValues;
try {
ClaimManager claimManager = ServiceReferenceHolder.getInstance().getRealmService().getTenantUserRealm(tenantId).getClaimManager();
ClaimMapping[] claims = claimManager.getAllClaimMappings(dialectURI);
String[] claimURIs = claimMappingtoClaimURIString(claims);
UserStoreManager userStoreManager = ServiceReferenceHolder.getInstance().getRealmService().getTenantUserRealm(tenantId).getUserStoreManager();
String tenantAwareUserName = MultitenantUtils.getTenantAwareUsername(endUserName);
claimValues = new TreeMap(userStoreManager.getUserClaimValues(tenantAwareUserName, claimURIs, null));
return claimValues;
} catch (UserStoreException e) {
throw new APIManagementException("Error while retrieving user claim values from user store", e);
}
}
use of org.wso2.carbon.user.api.ClaimManager in project carbon-apimgt by wso2.
the class APIUtil method getClaimDisplayName.
/**
* Returns the display name of the given claim URI.
*
* @param claimURI
* @param subscriber
* @return display name of the claim
* @throws APIManagementException
*/
public static String getClaimDisplayName(String claimURI, String subscriber) throws APIManagementException {
String tenantDomain = MultitenantUtils.getTenantDomain(subscriber);
int tenantId;
String displayName;
try {
tenantId = getTenantId(tenantDomain);
ClaimManager claimManager = ServiceReferenceHolder.getInstance().getRealmService().getTenantUserRealm(tenantId).getClaimManager();
displayName = claimManager.getClaim(claimURI).getDisplayTag();
} catch (UserStoreException e) {
throw new APIManagementException("Error while retrieving claim values from user store", e);
}
return displayName;
}
Aggregations