use of org.wso2.carbon.identity.claim.metadata.mgt.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);
}
}
use of org.wso2.carbon.identity.claim.metadata.mgt.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);
}
}
use of org.wso2.carbon.identity.claim.metadata.mgt.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;
}
}
use of org.wso2.carbon.identity.claim.metadata.mgt.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);
}
}
use of org.wso2.carbon.identity.claim.metadata.mgt.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);
}
}
Aggregations