Search in sources :

Example 1 with ClaimDialectDTO

use of org.wso2.carbon.identity.claim.metadata.mgt.stub.dto.ClaimDialectDTO in project carbon-identity-framework by wso2.

the class ClaimMetadataManagementAdminService method renameClaimDialect.

@SuppressWarnings("unused")
public void renameClaimDialect(ClaimDialectDTO oldClaimDialect, ClaimDialectDTO newClaimDialect) throws ClaimMetadataException {
    try {
        ClaimDialect oldDialect = ClaimMetadataUtils.convertClaimDialectDTOToClaimDialect(oldClaimDialect);
        ClaimDialect newDialect = ClaimMetadataUtils.convertClaimDialectDTOToClaimDialect(newClaimDialect);
        String tenantDomain = CarbonContext.getThreadLocalCarbonContext().getTenantDomain();
        IdentityClaimManagementServiceDataHolder.getInstance().getClaimManagementService().renameClaimDialect(oldDialect, newDialect, tenantDomain);
    } catch (Throwable e) {
        log.error(e.getMessage(), e);
        throw new ClaimMetadataException(e.getMessage(), e);
    }
}
Also used : ClaimMetadataException(org.wso2.carbon.identity.claim.metadata.mgt.exception.ClaimMetadataException) ClaimDialect(org.wso2.carbon.identity.claim.metadata.mgt.model.ClaimDialect)

Example 2 with ClaimDialectDTO

use of org.wso2.carbon.identity.claim.metadata.mgt.stub.dto.ClaimDialectDTO in project carbon-identity-framework by wso2.

the class ClaimMetadataManagementAdminService method removeClaimDialect.

@SuppressWarnings("unused")
public void removeClaimDialect(ClaimDialectDTO claimDialect) throws ClaimMetadataException {
    try {
        ClaimDialect dialect = ClaimMetadataUtils.convertClaimDialectDTOToClaimDialect(claimDialect);
        String tenantDomain = CarbonContext.getThreadLocalCarbonContext().getTenantDomain();
        IdentityClaimManagementServiceDataHolder.getInstance().getClaimManagementService().removeClaimDialect(dialect, tenantDomain);
    } catch (Throwable e) {
        log.error(e.getMessage(), e);
        throw new ClaimMetadataException(e.getMessage(), e);
    }
}
Also used : ClaimMetadataException(org.wso2.carbon.identity.claim.metadata.mgt.exception.ClaimMetadataException) ClaimDialect(org.wso2.carbon.identity.claim.metadata.mgt.model.ClaimDialect)

Example 3 with ClaimDialectDTO

use of org.wso2.carbon.identity.claim.metadata.mgt.stub.dto.ClaimDialectDTO in project carbon-identity-framework by wso2.

the class ClaimMetadataAdminClient method removeClaimDialect.

public void removeClaimDialect(String externalClaimDialect) throws RemoteException, ClaimMetadataManagementServiceClaimMetadataException {
    try {
        ClaimDialectDTO claimDialect = new ClaimDialectDTO();
        claimDialect.setClaimDialectURI(externalClaimDialect);
        stub.removeClaimDialect(claimDialect);
    } catch (RemoteException e) {
        log.error(e.getMessage(), e);
        throw e;
    } catch (ClaimMetadataManagementServiceClaimMetadataException e) {
        log.error(e.getMessage(), e);
        throw e;
    }
}
Also used : ClaimMetadataManagementServiceClaimMetadataException(org.wso2.carbon.identity.claim.metadata.mgt.stub.ClaimMetadataManagementServiceClaimMetadataException) ClaimDialectDTO(org.wso2.carbon.identity.claim.metadata.mgt.stub.dto.ClaimDialectDTO) RemoteException(java.rmi.RemoteException)

Example 4 with ClaimDialectDTO

use of org.wso2.carbon.identity.claim.metadata.mgt.stub.dto.ClaimDialectDTO in project product-is by wso2.

the class ClaimManagementServiceTestCase method testUpdateCliamMapping.

@Test(alwaysRun = true, description = "Update claim mapping", dependsOnMethods = "testAddNewCliamMapping")
public void testUpdateCliamMapping() {
    ClaimMappingDTO mapping = new ClaimMappingDTO();
    ClaimDTO claim = new ClaimDTO();
    claim.setClaimUri(CLAIM_URI_NEW);
    claim.setDisplayTag(DISPLAY_NAME_NEW);
    claim.setDescription(DESCRIPTION_NEW);
    claim.setDialectURI(DIALECT);
    claim.setRegEx(REGEX);
    claim.setDisplayOrder(DISPLAY_ORDER);
    claim.setRequired(REQUIRED);
    claim.setSupportedByDefault(SUPPORTED);
    claim.setReadOnly(READONLY);
    mapping.setClaim(claim);
    if (ATTRIBUTE != null) {
        String[] attributes = ATTRIBUTE.split(";");
        List<ClaimAttributeDTO> attrList = new ArrayList<ClaimAttributeDTO>();
        for (int i = 0; i < attributes.length; i++) {
            int index = 0;
            if ((index = attributes[i].indexOf("/")) > 1 && attributes[i].indexOf("/") == attributes[i].lastIndexOf("/")) {
                String domain = attributes[i].substring(0, index);
                String attrName = attributes[i].substring(index + 1);
                ClaimAttributeDTO attr = new ClaimAttributeDTO();
                attr.setAttributeName(attrName);
                attr.setDomainName(domain);
                attrList.add(attr);
            } else {
                mapping.setMappedAttribute(attributes[i]);
            }
        }
        if (attrList.size() > 0) {
            mapping.setMappedAttributes(attrList.toArray(new ClaimAttributeDTO[attrList.size()]));
        }
    }
    try {
        adminClient.updateClaimMapping(mapping);
        ClaimDialectDTO dialectDTO = adminClient.getClaimMappingByDialect(DIALECT);
        Assert.assertNotNull(dialectDTO, "Claim mapping adding failed.");
        for (ClaimMappingDTO mappingDTO : dialectDTO.getClaimMappings()) {
            if (CLAIM_URI_NEW.equals(mappingDTO.getClaim().getClaimUri())) {
                Assert.assertEquals(DESCRIPTION_NEW, mappingDTO.getClaim().getDescription(), "Claim mapping update failed.");
                Assert.assertEquals(DISPLAY_NAME_NEW, mappingDTO.getClaim().getDisplayTag(), "Claim mapping update failed.");
                break;
            }
        }
    } catch (Exception e) {
        Assert.fail("Error while trying to update claim mapping", e);
    }
}
Also used : ClaimMappingDTO(org.wso2.carbon.claim.mgt.stub.dto.ClaimMappingDTO) ClaimDTO(org.wso2.carbon.claim.mgt.stub.dto.ClaimDTO) ArrayList(java.util.ArrayList) ClaimAttributeDTO(org.wso2.carbon.claim.mgt.stub.dto.ClaimAttributeDTO) ClaimDialectDTO(org.wso2.carbon.claim.mgt.stub.dto.ClaimDialectDTO) ISIntegrationTest(org.wso2.identity.integration.common.utils.ISIntegrationTest) Test(org.testng.annotations.Test)

Example 5 with ClaimDialectDTO

use of org.wso2.carbon.identity.claim.metadata.mgt.stub.dto.ClaimDialectDTO in project product-is by wso2.

the class ClaimManagementServiceTestCase method testAddNewCliamMapping.

@Test(alwaysRun = true, description = "Add new claim mapping dialect", dependsOnMethods = "testAddNewCliamDialect")
public void testAddNewCliamMapping() {
    ClaimMappingDTO mapping = new ClaimMappingDTO();
    ClaimDTO claim = new ClaimDTO();
    claim.setClaimUri(CLAIM_URI_NEW);
    claim.setDisplayTag("Test1");
    claim.setDescription("Test1");
    claim.setDialectURI(DIALECT);
    claim.setRegEx(REGEX);
    claim.setDisplayOrder(DISPLAY_ORDER);
    claim.setRequired(REQUIRED);
    claim.setSupportedByDefault(SUPPORTED);
    claim.setReadOnly(READONLY);
    mapping.setClaim(claim);
    if (ATTRIBUTE != null) {
        String[] attributes = ATTRIBUTE.split(";");
        List<ClaimAttributeDTO> attrList = new ArrayList<ClaimAttributeDTO>();
        for (int i = 0; i < attributes.length; i++) {
            int index = 0;
            if ((index = attributes[i].indexOf("/")) > 1) {
                String domain = attributes[i].substring(0, index);
                String attrName = attributes[i].substring(index + 1);
                if (domain != null) {
                    ClaimAttributeDTO attr = new ClaimAttributeDTO();
                    attr.setAttributeName(attrName);
                    attr.setDomainName(domain);
                    attrList.add(attr);
                }
            } else {
                ClaimAttributeDTO attr = new ClaimAttributeDTO();
                attr.setAttributeName(attributes[i]);
                attr.setDomainName(null);
                attrList.add(attr);
            }
        }
        if (attrList.size() > 0) {
            mapping.setMappedAttributes(attrList.toArray(new ClaimAttributeDTO[attrList.size()]));
        }
    }
    try {
        adminClient.addNewClaimMapping(mapping);
        ClaimDialectDTO dialectDTO = adminClient.getClaimMappingByDialect(DIALECT);
        Assert.assertNotNull(dialectDTO, "Claim dialect adding failed.");
        String dialectURI = null;
        for (ClaimMappingDTO mappingDTO : dialectDTO.getClaimMappings()) {
            if (CLAIM_URI_NEW.equals(mappingDTO.getClaim().getClaimUri())) {
                dialectURI = mappingDTO.getClaim().getDialectURI();
            }
        }
        Assert.assertNotNull(dialectURI, "Error occured while adding claim mapping.");
    } catch (Exception e) {
        Assert.fail("Error while trying to add new claim dialect", e);
    }
}
Also used : ClaimMappingDTO(org.wso2.carbon.claim.mgt.stub.dto.ClaimMappingDTO) ClaimDTO(org.wso2.carbon.claim.mgt.stub.dto.ClaimDTO) ArrayList(java.util.ArrayList) ClaimAttributeDTO(org.wso2.carbon.claim.mgt.stub.dto.ClaimAttributeDTO) ClaimDialectDTO(org.wso2.carbon.claim.mgt.stub.dto.ClaimDialectDTO) ISIntegrationTest(org.wso2.identity.integration.common.utils.ISIntegrationTest) Test(org.testng.annotations.Test)

Aggregations

Test (org.testng.annotations.Test)9 ClaimDialectDTO (org.wso2.carbon.claim.mgt.stub.dto.ClaimDialectDTO)6 ClaimDialect (org.wso2.carbon.identity.claim.metadata.mgt.model.ClaimDialect)6 ClaimMappingDTO (org.wso2.carbon.claim.mgt.stub.dto.ClaimMappingDTO)5 ClaimDialectDTO (org.wso2.carbon.identity.claim.metadata.mgt.stub.dto.ClaimDialectDTO)5 ISIntegrationTest (org.wso2.identity.integration.common.utils.ISIntegrationTest)5 ArrayList (java.util.ArrayList)4 ClaimDTO (org.wso2.carbon.claim.mgt.stub.dto.ClaimDTO)4 ClaimDialectDTO (org.wso2.carbon.identity.claim.metadata.mgt.dto.ClaimDialectDTO)4 ClaimMetadataException (org.wso2.carbon.identity.claim.metadata.mgt.exception.ClaimMetadataException)4 RemoteException (java.rmi.RemoteException)3 ClaimAttributeDTO (org.wso2.carbon.claim.mgt.stub.dto.ClaimAttributeDTO)3 ClaimMetadataManagementServiceClaimMetadataException (org.wso2.carbon.identity.claim.metadata.mgt.stub.ClaimMetadataManagementServiceClaimMetadataException)3 AutomationContext (org.wso2.carbon.automation.engine.context.AutomationContext)2 ClaimDialectDTO (org.wso2.carbon.claim.mgt.dto.ClaimDialectDTO)2 LoginLogoutClient (org.wso2.carbon.integration.common.utils.LoginLogoutClient)2 ClaimMetadataManagementServiceClient (org.wso2.identity.integration.common.clients.claim.metadata.mgt.ClaimMetadataManagementServiceClient)2 SCIM2BaseTest (org.wso2.identity.integration.test.scim2.rest.api.SCIM2BaseTest)2