Search in sources :

Example 1 with ClaimsList

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;
}
Also used : KeyManagerClientException(org.wso2.carbon.apimgt.impl.kmclient.KeyManagerClientException) HashMap(java.util.HashMap) ClaimsList(org.wso2.carbon.apimgt.impl.kmclient.model.ClaimsList) UserInfoDTO(org.wso2.carbon.apimgt.impl.dto.UserInfoDTO) Claim(org.wso2.carbon.apimgt.impl.kmclient.model.Claim)

Aggregations

HashMap (java.util.HashMap)1 UserInfoDTO (org.wso2.carbon.apimgt.impl.dto.UserInfoDTO)1 KeyManagerClientException (org.wso2.carbon.apimgt.impl.kmclient.KeyManagerClientException)1 Claim (org.wso2.carbon.apimgt.impl.kmclient.model.Claim)1 ClaimsList (org.wso2.carbon.apimgt.impl.kmclient.model.ClaimsList)1