use of org.wso2.carbon.identity.application.common.model.xsd.ClaimMapping in project product-is by wso2.
the class TestPassiveSTS method testAddClaimConfiguration.
@Test(alwaysRun = true, description = "4.1.5.3", dependsOnMethods = { "testUpdateSP" })
public void testAddClaimConfiguration() throws Exception {
serviceProvider.getClaimConfig().setClaimMappings(getClaimMappings());
appMgtclient.updateApplicationData(serviceProvider);
ServiceProvider updatedServiceProvider = appMgtclient.getApplication(SERVICE_PROVIDER_NAME);
ClaimConfig updatedClaimConfig = updatedServiceProvider.getClaimConfig();
Assert.assertNotNull(updatedClaimConfig.getClaimMappings(), "Claim mapping is null. Claim mapping creation failed.");
for (ClaimMapping claimMapping : getClaimMappings()) {
boolean success = false;
for (ClaimMapping updatedClaimMapping : updatedClaimConfig.getClaimMappings()) {
if (claimMapping.getLocalClaim().getClaimUri().equals(updatedClaimMapping.getLocalClaim().getClaimUri())) {
success = true;
break;
}
}
Assert.assertTrue(success, "Failed to set claim uri: " + claimMapping.getLocalClaim().getClaimUri());
}
}
use of org.wso2.carbon.identity.application.common.model.xsd.ClaimMapping in project product-is by wso2.
the class SSOUtil method addClaimMapping.
private static void addClaimMapping(List<ClaimMapping> claimMappingList, String emailClaimUri) {
Claim emailClaim = new Claim();
emailClaim.setClaimUri(emailClaimUri);
ClaimMapping emailClaimMapping = new ClaimMapping();
emailClaimMapping.setRequested(true);
emailClaimMapping.setLocalClaim(emailClaim);
emailClaimMapping.setRemoteClaim(emailClaim);
claimMappingList.add(emailClaimMapping);
}
use of org.wso2.carbon.identity.application.common.model.xsd.ClaimMapping in project identity-inbound-provisioning-scim2 by wso2-extensions.
the class SCIMUserManagerTest method data.
@DataProvider(name = "ClaimData")
public Object[][] data() {
String coreClaimUri1;
String testMappedAttributesCore1;
String coreClaimUri2;
String testMappedAttributesCore2;
String userClaimUri1;
String testMappedAttributesUser1;
String userClaimUri2;
String testMappedAttributesUser2;
Claim claim1 = new Claim();
Claim claim2 = new Claim();
Claim claim3 = new Claim();
Claim claim4 = new Claim();
coreClaimUri1 = "testCoreClaimURI1";
claim1.setClaimUri(coreClaimUri1);
testMappedAttributesCore1 = "MappedAttributesCore1";
coreClaimUri2 = "testCoreClaimURI2";
claim2.setClaimUri(coreClaimUri2);
testMappedAttributesCore2 = "MappedAttributesCore2";
userClaimUri1 = "testUserClaimURI1";
claim3.setClaimUri(userClaimUri1);
testMappedAttributesUser1 = "MappedAttributesUser1";
userClaimUri2 = "testUserClaimURI2";
claim4.setClaimUri(userClaimUri2);
testMappedAttributesUser2 = "MappedAttributesUser2";
ClaimMapping cMap1 = new ClaimMapping(claim1, testMappedAttributesCore1);
ClaimMapping cMap2 = new ClaimMapping(claim2, testMappedAttributesCore2);
ClaimMapping cMap3 = new ClaimMapping(claim3, testMappedAttributesUser1);
ClaimMapping cMap4 = new ClaimMapping(claim4, testMappedAttributesUser2);
ClaimMapping[] coreClaims = new ClaimMapping[] { cMap1, cMap2, cMap3, cMap4 };
HashMap<String, Boolean> requiredAttributes = new HashMap<String, Boolean>() {
{
put("test1.test", true);
}
};
String[] roles = new String[] { "role1", "role2", "role3" };
return new Object[][] { { coreClaims, requiredAttributes, roles } };
}
use of org.wso2.carbon.identity.application.common.model.xsd.ClaimMapping in project identity-inbound-provisioning-scim2 by wso2-extensions.
the class SCIMUserManagerTest method getTestClaimMappings.
private ClaimMapping[] getTestClaimMappings() {
ClaimMapping[] claimMappings = new ClaimMapping[3];
Claim claim1 = new Claim();
claim1.setClaimUri("urn:ietf:params:scim:schemas:core:2.0:User:userName");
ClaimMapping claimMapping1 = new ClaimMapping();
claimMapping1.setClaim(claim1);
claimMapping1.setMappedAttribute("PRIMARY", "http://wso2.org/claims/username");
claimMappings[0] = claimMapping1;
Claim claim2 = new Claim();
claim2.setClaimUri("urn:ietf:params:scim:schemas:core:2.0:User:emails");
ClaimMapping claimMapping2 = new ClaimMapping();
claimMapping2.setClaim(claim2);
claimMapping2.setMappedAttribute("PRIMARY", "http://wso2.org/claims/emailaddress");
claimMappings[1] = claimMapping2;
Claim claim3 = new Claim();
claim3.setClaimUri("urn:ietf:params:scim:schemas:core:2.0:User:name.givenName");
ClaimMapping claimMapping3 = new ClaimMapping();
claimMapping3.setClaim(claim3);
claimMapping3.setMappedAttribute("PRIMARY", "http://wso2.org/claims/givenname");
claimMappings[2] = claimMapping3;
return claimMappings;
}
use of org.wso2.carbon.identity.application.common.model.xsd.ClaimMapping in project identity-inbound-provisioning-scim2 by wso2-extensions.
the class SCIMUserManagerTest method testFilteringUsersWithGET.
@Test(dataProvider = "userInfoForFiltering")
public void testFilteringUsersWithGET(List<org.wso2.carbon.user.core.common.User> users, String filter, int expectedResultCount, List<org.wso2.carbon.user.core.common.User> filteredUsers) throws Exception {
Map<String, String> scimToLocalClaimMap = new HashMap<>();
scimToLocalClaimMap.put("urn:ietf:params:scim:schemas:core:2.0:User:userName", "http://wso2.org/claims/username");
scimToLocalClaimMap.put("urn:ietf:params:scim:schemas:core:2.0:id", "http://wso2.org/claims/userid");
scimToLocalClaimMap.put("urn:ietf:params:scim:schemas:core:2.0:User:emails", "http://wso2.org/claims/emailaddress");
scimToLocalClaimMap.put("urn:ietf:params:scim:schemas:core:2.0:User:name.givenName", "http://wso2.org/claims/givenname");
mockStatic(SCIMCommonUtils.class);
when(SCIMCommonUtils.getSCIMtoLocalMappings()).thenReturn(scimToLocalClaimMap);
when(SCIMCommonUtils.convertLocalToSCIMDialect(anyMap(), anyMap())).thenReturn(new HashMap<String, String>() {
{
put(SCIMConstants.CommonSchemaConstants.ID_URI, "1f70378a-69bb-49cf-aa51-a0493c09110c");
}
});
mockedUserStoreManager = PowerMockito.mock(AbstractUserStoreManager.class);
when(mockedUserStoreManager.getUserListWithID("http://wso2.org/claims/userid", "*", null)).thenReturn(users);
when(mockedUserStoreManager.getUserListWithID("http://wso2.org/claims/givenname", "testUser", "default")).thenReturn(filteredUsers);
when(mockedUserStoreManager.getUserListWithID(any(Condition.class), anyString(), anyString(), anyInt(), anyInt(), anyString(), anyString())).thenReturn(filteredUsers);
when(mockedUserStoreManager.getRoleListOfUserWithID(anyString())).thenReturn(new ArrayList<>());
whenNew(GroupDAO.class).withAnyArguments().thenReturn(mockedGroupDAO);
when(mockedGroupDAO.listSCIMGroups(anyInt())).thenReturn(anySet());
when(mockedUserStoreManager.getSecondaryUserStoreManager("PRIMARY")).thenReturn(mockedUserStoreManager);
when(mockedUserStoreManager.isSCIMEnabled()).thenReturn(true);
when(mockedUserStoreManager.getSecondaryUserStoreManager("SECONDARY")).thenReturn(secondaryUserStoreManager);
when(secondaryUserStoreManager.isSCIMEnabled()).thenReturn(true);
when(mockedUserStoreManager.getRealmConfiguration()).thenReturn(mockedRealmConfig);
when(mockedRealmConfig.getUserStoreProperty(UserCoreConstants.RealmConfig.PROPERTY_MAX_USER_LIST)).thenReturn("100");
mockStatic(IdentityTenantUtil.class);
when(IdentityTenantUtil.getRealmService()).thenReturn(mockRealmService);
when(mockRealmService.getBootstrapRealmConfiguration()).thenReturn(mockedRealmConfig);
mockStatic(IdentityUtil.class);
when(IdentityUtil.isGroupsVsRolesSeparationImprovementsEnabled()).thenReturn(false);
ClaimMapping[] claimMappings = getTestClaimMappings();
when(mockedClaimManager.getAllClaimMappings(anyString())).thenReturn(claimMappings);
HashMap<String, Boolean> requiredClaimsMap = new HashMap<>();
requiredClaimsMap.put("urn:ietf:params:scim:schemas:core:2.0:User:userName", false);
SCIMUserManager scimUserManager = new SCIMUserManager(mockedUserStoreManager, mockedClaimManager);
Node node = null;
if (StringUtils.isNotBlank(filter)) {
SCIMResourceTypeSchema schema = SCIMResourceSchemaManager.getInstance().getUserResourceSchema();
FilterTreeManager filterTreeManager = new FilterTreeManager(filter, schema);
node = filterTreeManager.buildTree();
}
List<Object> result = scimUserManager.listUsersWithGET(node, 1, null, null, null, null, requiredClaimsMap);
assertEquals(expectedResultCount, result.size());
}
Aggregations