use of org.wso2.micro.gateway.jwt.generator.ClaimDTO 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);
}
}
use of org.wso2.micro.gateway.jwt.generator.ClaimDTO in project product-is by wso2.
the class OpenIDUserProfileTestCase method testUserProfile.
@Test(alwaysRun = true, description = "Test reading user profile and claims from the profile")
public void testUserProfile() {
String openId = Util.getDefaultOpenIDIdentifier(userName);
OpenIDParameterDTO[] openidRequestParams = Util.getDummyOpenIDParameterDTOArray();
OpenIDUserProfileDTO[] userProfiles = null;
// reading back user profiles
try {
userProfiles = openidServiceClient.getUserProfiles(openId, openidRequestParams);
} catch (Exception e) {
Assert.fail("Error while reading user profiles", e);
}
Assert.assertEquals(userProfiles[0].getProfileName(), profileName);
Assert.assertNotNull(userProfiles[0].getClaimSet());
// we expect 4 claims : email, firstname, lastname and country
Assert.assertEquals(userProfiles[0].getClaimSet().length, 4);
for (OpenIDClaimDTO claimDTO : userProfiles[0].getClaimSet()) {
if (emailClaimURI.equals(claimDTO.getClaimUri())) {
Assert.assertTrue(claimDTO.getClaimValue().contains(emailClaimValue));
} else if (firstNameClaimURI.equals(claimDTO.getClaimUri())) {
Assert.assertTrue(claimDTO.getClaimValue().contains(firstNameClaimValue));
} else if (lastNameClaimURI.equals(claimDTO.getClaimUri())) {
Assert.assertTrue(claimDTO.getClaimValue().contains(lastNameClaimValue));
} else if (countryClaimURI.equals(claimDTO.getClaimUri())) {
Assert.assertTrue(claimDTO.getClaimValue().contains(countryClaimValue));
} else {
Assert.fail("Invalid claim returned");
}
}
// Login with created user
try {
openidServiceClient.authenticateWithOpenID(openId, password);
} catch (Exception e) {
Assert.fail("Error while authenticating", e);
}
}
use of org.wso2.micro.gateway.jwt.generator.ClaimDTO in project product-is by wso2.
the class ClaimManagementServiceClient method addNewClaimMapping.
public void addNewClaimMapping(String dialectURI, String claimUri, String description, String mappedAttribute) throws ClaimManagementServiceClaimManagementException, RemoteException {
ClaimMappingDTO claimMappingDTO = new ClaimMappingDTO();
ClaimDTO claimDTO = new ClaimDTO();
claimDTO.setDialectURI(dialectURI);
claimDTO.setClaimUri(claimUri);
claimDTO.setDescription(description);
claimMappingDTO.setClaim(claimDTO);
claimMappingDTO.setMappedAttribute(mappedAttribute);
claimManagementServiceStub.addNewClaimMapping(claimMappingDTO);
}
use of org.wso2.micro.gateway.jwt.generator.ClaimDTO in project product-is by wso2.
the class RemoteUserStoreManagerServiceTestCase method testGetUserClaimValues.
@Test(priority = 5, groups = "wso2.is", description = "Test getUserClaimValues operation")
public void testGetUserClaimValues() throws RemoteUserStoreManagerServiceUserStoreExceptionException, RemoteException {
ClaimDTO[] claims = remoteUserStoreManagerClient.getUserClaimValues(user2, null);
Assert.assertNotNull(claims, "User claims retrieval failed");
Map<String, ClaimDTO> claimMap = new HashMap<String, ClaimDTO>();
for (ClaimDTO claim : claims) {
claimMap.put(claim.getClaimUri(), claim);
}
// verify newly added claims are included in list
Assert.assertTrue(claimMap.containsKey(claimURI1), "Claim not found :" + claimURI1);
Assert.assertEquals(claimMap.get(claimURI1).getValue(), claimValue1, "Claim deviate from added value");
Assert.assertTrue(claimMap.containsKey(claimURI2), "Claim not found :" + claimURI2);
Assert.assertEquals(claimMap.get(claimURI2).getValue(), claimValue2, "Claim deviate from added value");
Assert.assertTrue(claimMap.containsKey(claimURI3), "Claim not found :" + claimURI3);
Assert.assertEquals(claimMap.get(claimURI3).getValue(), claimValue3, "Claim deviate from added value");
}
use of org.wso2.micro.gateway.jwt.generator.ClaimDTO in project product-is by wso2.
the class UUIDUserStoreManagerService method convertClaimToClaimDTO.
private ClaimDTO[] convertClaimToClaimDTO(List<Claim> claims) {
List<ClaimDTO> ClaimDTOs = new ArrayList<>();
for (Claim claim : claims) {
ClaimDTO claimDTO = new ClaimDTO();
claimDTO.setClaimUri(claim.getClaimUri());
claimDTO.setValue(claim.getValue());
claimDTO.setDescription(claim.getDescription());
claimDTO.setDialectURI(claim.getDialectURI());
claimDTO.setDisplayOrder(claim.getDisplayOrder());
claimDTO.setRegEx(claim.getRegEx());
claimDTO.setSupportedByDefault(claim.isSupportedByDefault());
claimDTO.setRequired(claim.isRequired());
ClaimDTOs.add(claimDTO);
}
return ClaimDTOs.toArray(new ClaimDTO[0]);
}
Aggregations