Search in sources :

Example 1 with ClaimDTO

use of org.wso2.carbon.identity.user.endpoint.dto.ClaimDTO in project carbon-apimgt by wso2.

the class SubscriptionMappingUtil method fromSubscriberClaimsToDTO.

/**
 * Convert Subscriber claims information into SubscriberInfoDTO
 *
 * @param subscriberClaims list of subscriber claims
 * @param subscriberName   subscriber name
 * @return SubscriberInfoDTO
 * @throws APIManagementException If an error occurs when getting display name of claim
 */
public static SubscriberInfoDTO fromSubscriberClaimsToDTO(Map<String, String> subscriberClaims, String subscriberName) throws APIManagementException {
    SubscriberInfoDTO subscriberInfoDTO = new SubscriberInfoDTO();
    subscriberInfoDTO.setName(subscriberName);
    List<ClaimDTO> claimDTOList = new ArrayList<>();
    for (String key : subscriberClaims.keySet()) {
        ClaimDTO claimDTO = new ClaimDTO();
        claimDTO.setName(APIUtil.getClaimDisplayName(key, subscriberName));
        claimDTO.setURI(key);
        claimDTO.setValue(subscriberClaims.get(key));
        claimDTOList.add(claimDTO);
    }
    subscriberInfoDTO.setClaims(claimDTOList);
    return subscriberInfoDTO;
}
Also used : ClaimDTO(org.wso2.carbon.apimgt.rest.api.publisher.v1.dto.ClaimDTO) ArrayList(java.util.ArrayList) SubscriberInfoDTO(org.wso2.carbon.apimgt.rest.api.publisher.v1.dto.SubscriberInfoDTO)

Example 2 with ClaimDTO

use of org.wso2.carbon.identity.user.endpoint.dto.ClaimDTO in project core-util by WSO2Telco.

the class ClaimUtil method convertToClaims.

public org.wso2.carbon.user.core.claim.Claim[] convertToClaims(ClaimDTO[] claims) {
    if (claims == null) {
        return new org.wso2.carbon.user.core.claim.Claim[0];
    }
    org.wso2.carbon.user.core.claim.Claim[] claimz = new org.wso2.carbon.user.core.claim.Claim[claims.length];
    int i = 0;
    for (ClaimDTO claim : claims) {
        claimz[i] = convertToClaim(claim);
        i++;
    }
    return claimz;
}
Also used : ClaimDTO(org.wso2.carbon.um.ws.api.stub.ClaimDTO)

Example 3 with ClaimDTO

use of org.wso2.carbon.identity.user.endpoint.dto.ClaimDTO in project product-microgateway by wso2.

the class MGWJWTGeneratorInvoker method getRetrievedClaims.

public static BMap<String, Object> getRetrievedClaims(BMap<String, Object> authContext) {
    try {
        List<ClaimDTO> claimList = abstractMGWClaimRetriever.retrieveClaims(convertBMapToMap(authContext));
        if (claimList == null) {
            return null;
        }
        BPackage packageId = new BPackage("wso2", "gateway", "3.2.1");
        BMap<String, Object> bMap = BValueCreator.createRecordValue(packageId, "RetrievedUserClaimsListDTO");
        bMap.put("count", claimList.size());
        BArray bArray = (BArray) bMap.get("list");
        for (Object claimDTO : claimList) {
            bArray.append(BValueCreator.createRecordValue(packageId, "ClaimDTO", (Map<String, Object>) claimDTO));
        }
        return bMap;
    // Not to break the flow if an exception occured during claim retrieval
    } catch (Exception e) {
        log.error("Error while retrieving user claims from remote url.", e);
        return null;
    }
}
Also used : ClaimDTO(org.wso2.micro.gateway.jwt.generator.ClaimDTO) HashMap(java.util.HashMap) Map(java.util.Map) BMap(org.ballerinalang.jvm.values.api.BMap) BArray(org.ballerinalang.jvm.values.api.BArray) InvocationTargetException(java.lang.reflect.InvocationTargetException) BPackage(org.ballerinalang.jvm.types.BPackage)

Example 4 with ClaimDTO

use of org.wso2.carbon.identity.user.endpoint.dto.ClaimDTO in project carbon-identity-framework by wso2.

the class UserIdentityManagementUtil method getAllUserIdentityClaims.

/**
 * 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);
    }
}
Also used : IdentityMgtServiceException(org.wso2.carbon.identity.mgt.IdentityMgtServiceException) ArrayList(java.util.ArrayList) UserStoreException(org.wso2.carbon.user.api.UserStoreException) UserStoreManager(org.wso2.carbon.user.api.UserStoreManager) UserIdentityClaimDTO(org.wso2.carbon.identity.mgt.dto.UserIdentityClaimDTO) Claim(org.wso2.carbon.user.api.Claim)

Example 5 with ClaimDTO

use of org.wso2.carbon.identity.user.endpoint.dto.ClaimDTO in project carbon-identity-framework by wso2.

the class ClaimAdminService method convertClaimToClaimDTO.

private ClaimDTO convertClaimToClaimDTO(Claim claim) {
    ClaimDTO claimDTO = new ClaimDTO();
    claimDTO.setClaimUri(claim.getClaimUri());
    claimDTO.setDescription(claim.getDescription());
    claimDTO.setDialectURI(claim.getDialectURI());
    claimDTO.setDisplayOrder(claim.getDisplayOrder());
    claimDTO.setDisplayTag(claim.getDisplayTag());
    claimDTO.setRegEx(claim.getRegEx());
    claimDTO.setRequired(claim.isRequired());
    claimDTO.setSupportedByDefault(claim.isSupportedByDefault());
    claimDTO.setValue(claim.getValue());
    claimDTO.setCheckedAttribute(claim.isCheckedAttribute());
    claimDTO.setReadOnly(claim.isReadOnly());
    return claimDTO;
}
Also used : ClaimDTO(org.wso2.carbon.claim.mgt.dto.ClaimDTO)

Aggregations

ArrayList (java.util.ArrayList)9 ClaimDTO (org.wso2.carbon.claim.mgt.stub.dto.ClaimDTO)7 ClaimMappingDTO (org.wso2.carbon.claim.mgt.stub.dto.ClaimMappingDTO)7 ISIntegrationTest (org.wso2.identity.integration.common.utils.ISIntegrationTest)5 Test (org.testng.annotations.Test)4 ClaimDialectDTO (org.wso2.carbon.claim.mgt.stub.dto.ClaimDialectDTO)4 Claim (org.wso2.carbon.user.api.Claim)4 HashMap (java.util.HashMap)3 ClaimAttributeDTO (org.wso2.carbon.claim.mgt.stub.dto.ClaimAttributeDTO)3 ClaimDTO (org.wso2.carbon.identity.test.integration.service.stub.ClaimDTO)3 ClaimDTO (org.wso2.carbon.identity.user.endpoint.dto.ClaimDTO)3 ClaimDTO (org.wso2.carbon.um.ws.api.stub.ClaimDTO)3 UserIdentityClaimDTO (org.wso2.carbon.identity.mgt.dto.UserIdentityClaimDTO)2 ClaimDTO (org.wso2.carbon.identity.recovery.endpoint.dto.ClaimDTO)2 ClaimValue (org.wso2.carbon.identity.test.integration.service.stub.ClaimValue)2 File (java.io.File)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 Map (java.util.Map)1 BPackage (org.ballerinalang.jvm.types.BPackage)1 BArray (org.ballerinalang.jvm.values.api.BArray)1