use of org.wso2.carbon.apimgt.impl.kmclient.model.ClaimsList in project carbon-apimgt by wso2.
the class AMDefaultKeyManagerImpl method getUserClaims.
@Override
public Map<String, String> getUserClaims(String username, Map<String, Object> properties) throws APIManagementException {
Map<String, String> map = new HashMap<String, String>();
String tenantAwareUserName = MultitenantUtils.getTenantAwareUsername(username);
UserInfoDTO userinfo = new UserInfoDTO();
userinfo.setUsername(tenantAwareUserName);
if (tenantAwareUserName.contains(CarbonConstants.DOMAIN_SEPARATOR)) {
userinfo.setDomain(tenantAwareUserName.split(CarbonConstants.DOMAIN_SEPARATOR)[0]);
}
if (properties.containsKey(APIConstants.KeyManager.ACCESS_TOKEN)) {
userinfo.setAccessToken(properties.get(APIConstants.KeyManager.ACCESS_TOKEN).toString());
}
if (properties.containsKey(APIConstants.KeyManager.CLAIM_DIALECT)) {
userinfo.setDialectURI(properties.get(APIConstants.KeyManager.CLAIM_DIALECT).toString());
}
if (properties.containsKey(APIConstants.KeyManager.BINDING_FEDERATED_USER_CLAIMS)) {
userinfo.setBindFederatedUserClaims(Boolean.valueOf(properties.get(APIConstants.KeyManager.BINDING_FEDERATED_USER_CLAIMS).toString()));
}
try {
ClaimsList claims = userClient.generateClaims(userinfo);
if (claims != null && claims.getList() != null) {
for (Claim claim : claims.getList()) {
map.put(claim.getUri(), claim.getValue());
}
}
} catch (KeyManagerClientException e) {
handleException("Error while getting user info", e);
}
return map;
}
Aggregations