Search in sources :

Example 16 with ClaimDTO

use of org.wso2.micro.gateway.jwt.generator.ClaimDTO in project carbon-identity-framework by wso2.

the class ClaimAdminClient method getAllClaimMappingsByDialectWithRole.

/**
 * We need to treat http://wso2.org/claims/role claim differently.
 * Should not be set to supporrtedByDefaut to true.
 *
 * @param dialect
 * @return
 * @throws AxisFault
 */
public ClaimDialectDTO getAllClaimMappingsByDialectWithRole(String dialect) throws AxisFault {
    try {
        ClaimDialectDTO claims = stub.getClaimMappingByDialect(dialect);
        ClaimMappingDTO[] oldClaims = claims.getClaimMappings();
        ClaimMappingDTO[] newClaims = new ClaimMappingDTO[claims.getClaimMappings().length + 1];
        int i = 0;
        for (; i < oldClaims.length; i++) {
            newClaims[i] = oldClaims[i];
        }
        ClaimMappingDTO mapping = new ClaimMappingDTO();
        ClaimDTO role = new ClaimDTO();
        role.setClaimUri("http://wso2.org/claims/role");
        mapping.setClaim(role);
        newClaims[i] = mapping;
        // If role group separation is enabled, we need to send the roles claim also as UI might need that.
        ClaimMappingDTO rolesMapping = new ClaimMappingDTO();
        ClaimDTO roles = new ClaimDTO();
        roles.setClaimUri("http://wso2.org/claims/roles");
        rolesMapping.setClaim(roles);
        newClaims[i] = rolesMapping;
        claims.setClaimMappings(newClaims);
        return claims;
    } catch (Exception e) {
        handleException("Error while reading claim mappings by dialect", e);
    }
    return null;
}
Also used : ClaimMappingDTO(org.wso2.carbon.claim.mgt.stub.dto.ClaimMappingDTO) ClaimDTO(org.wso2.carbon.claim.mgt.stub.dto.ClaimDTO) ClaimDialectDTO(org.wso2.carbon.claim.mgt.stub.dto.ClaimDialectDTO)

Example 17 with ClaimDTO

use of org.wso2.micro.gateway.jwt.generator.ClaimDTO in project carbon-identity-framework by wso2.

the class ClaimAdminService method convertClaimDTOToClaim.

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

Example 18 with ClaimDTO

use of org.wso2.micro.gateway.jwt.generator.ClaimDTO in project carbon-identity-framework by wso2.

the class UserInformationRecoveryService method getUserIdentitySupportedClaims.

/**
 * This returns the user supported claims.
 *
 * @param dialect
 * @return
 * @throws IdentityException
 */
public UserIdentityClaimDTO[] getUserIdentitySupportedClaims(String dialect) throws IdentityException {
    IdentityClaimManager claimManager = null;
    Claim[] claims = null;
    UserRealm realm = null;
    claimManager = IdentityClaimManager.getInstance();
    realm = IdentityTenantUtil.getRealm(null, null);
    claims = claimManager.getAllSupportedClaims(dialect, realm);
    if (claims == null || claims.length == 0) {
        log.warn("Could not find any matching claims for requested dialect : " + dialect);
        return new UserIdentityClaimDTO[0];
    }
    List<UserIdentityClaimDTO> claimList = new ArrayList<UserIdentityClaimDTO>();
    for (int i = 0; i < claims.length; i++) {
        if (claims[i].getDisplayTag() != null && !IdentityConstants.PPID_DISPLAY_VALUE.equals(claims[i].getDisplayTag())) {
            if (UserCoreConstants.ClaimTypeURIs.ACCOUNT_STATUS.equals(claims[i].getClaimUri())) {
                continue;
            }
            if (claims[i].isSupportedByDefault() && (!claims[i].isReadOnly())) {
                UserIdentityClaimDTO claimDto = new UserIdentityClaimDTO();
                claimDto.setClaimUri(claims[i].getClaimUri());
                claimDto.setClaimValue(claims[i].getValue());
                claimDto.setRequired(claims[i].isRequired());
                claimDto.setDisplayName(claims[i].getDisplayTag());
                claimList.add(claimDto);
            }
        }
    }
    return claimList.toArray(new UserIdentityClaimDTO[claimList.size()]);
}
Also used : UserRealm(org.wso2.carbon.user.core.UserRealm) ArrayList(java.util.ArrayList) IdentityClaimManager(org.wso2.carbon.identity.core.IdentityClaimManager) UserIdentityClaimDTO(org.wso2.carbon.identity.mgt.dto.UserIdentityClaimDTO) Claim(org.wso2.carbon.user.core.claim.Claim)

Example 19 with ClaimDTO

use of org.wso2.micro.gateway.jwt.generator.ClaimDTO in project identity-governance by wso2-extensions.

the class Utils method getClaims.

public static Claim[] getClaims(List<ClaimDTO> claimDTOs) {
    if (claimDTOs != null && claimDTOs.size() > 0) {
        Claim[] claims = new Claim[claimDTOs.size()];
        for (int i = 0; i < claimDTOs.size(); i++) {
            Claim claim = new Claim();
            claim.setClaimUri(claimDTOs.get(i).getUri());
            claim.setValue(claimDTOs.get(i).getValue());
            claims[i] = claim;
        }
        return claims;
    } else {
        return new Claim[0];
    }
}
Also used : Claim(org.wso2.carbon.user.api.Claim)

Example 20 with ClaimDTO

use of org.wso2.micro.gateway.jwt.generator.ClaimDTO in project identity-governance by wso2-extensions.

the class UtilsTest method buildClaimDTO.

private List<ClaimDTO> buildClaimDTO() {
    ClaimDTO claimDTO = new ClaimDTO();
    claimDTO.setValue("testValue");
    claimDTO.setUri("testUri");
    List<ClaimDTO> claimDTOs = Lists.newArrayList(claimDTO);
    return claimDTOs;
}
Also used : ClaimDTO(org.wso2.carbon.identity.user.endpoint.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