use of org.wso2.carbon.identity.application.authentication.framework.config.model.ApplicationConfig in project carbon-identity-framework by wso2.
the class DefaultClaimHandler method retrieveAllNunNullUserClaimValues.
private Map<String, String> retrieveAllNunNullUserClaimValues(AuthenticatedUser authenticatedUser, ClaimManager claimManager, ApplicationConfig appConfig, AbstractUserStoreManager userStore) throws FrameworkException {
String tenantDomain = authenticatedUser.getTenantDomain();
Map<String, String> allLocalClaims = new HashMap<>();
try {
org.wso2.carbon.user.api.ClaimMapping[] claimMappings = claimManager.getAllClaimMappings(ApplicationConstants.LOCAL_IDP_DEFAULT_CLAIM_DIALECT);
List<String> localClaimURIs = new ArrayList<>();
for (org.wso2.carbon.user.api.ClaimMapping mapping : claimMappings) {
String claimURI = mapping.getClaim().getClaimUri();
localClaimURIs.add(claimURI);
}
allLocalClaims = userStore.getUserClaimValuesWithID(authenticatedUser.getUserId(), localClaimURIs.toArray(new String[0]), null);
if (allLocalClaims == null) {
return new HashMap<>();
}
} catch (UserStoreException e) {
if (e.getMessage().contains("UserNotFound")) {
if (log.isDebugEnabled()) {
log.debug("User " + authenticatedUser.getLoggableUserId() + " not found in user store");
}
} else {
throw new FrameworkException("Error occurred while getting all user claims for " + authenticatedUser.getLoggableUserId() + " in " + tenantDomain, e);
}
} catch (UserIdNotFoundException e) {
throw new FrameworkException("User id is not available for user: " + authenticatedUser.getLoggableUserId(), e);
}
return allLocalClaims;
}
use of org.wso2.carbon.identity.application.authentication.framework.config.model.ApplicationConfig in project carbon-identity-framework by wso2.
the class DefaultClaimFilter method getSpClaimMappings.
private List<ClaimMapping> getSpClaimMappings(ApplicationConfig appConfig) {
Map<String, String> spClaimMapping = appConfig.getClaimMappings();
Map<String, String> mandatoryClaims = appConfig.getMandatoryClaimMappings();
Map<String, String> requestedClaims = appConfig.getRequestedClaimMappings();
List<ClaimMapping> spClaimMappingsList = new ArrayList<>();
spClaimMapping.forEach((key, value) -> {
ClaimMapping claimMapping = ClaimMapping.build(value, key, null, false);
mandatoryClaims.entrySet().stream().filter(entry1 -> key.equals(entry1.getKey())).map(entry1 -> true).forEach(claimMapping::setMandatory);
requestedClaims.entrySet().stream().filter(entry2 -> key.equals(entry2.getKey())).map(entry2 -> true).forEach(claimMapping::setRequested);
spClaimMappingsList.add(claimMapping);
});
return spClaimMappingsList;
}
use of org.wso2.carbon.identity.application.authentication.framework.config.model.ApplicationConfig in project carbon-identity-framework by wso2.
the class DefaultStepBasedSequenceHandlerTest method testHandlePostUserName.
@Test(dataProvider = "postAuthenticationDataProvider")
public void testHandlePostUserName(String subjectClaimUriFromAppConfig, String spSubjectClaimValue, boolean appendTenantDomainToSubject, boolean appendUserStoreDomainToSubject, String authenticatedUserNameInSequence, String expectedSubjectIdentifier) throws Exception {
stepBasedSequenceHandler = new DefaultStepBasedSequenceHandler();
ApplicationConfig applicationConfig = spy(new ApplicationConfig(new ServiceProvider()));
when(applicationConfig.getSubjectClaimUri()).thenReturn(subjectClaimUriFromAppConfig);
when(applicationConfig.isUseTenantDomainInLocalSubjectIdentifier()).thenReturn(appendTenantDomainToSubject);
when(applicationConfig.isUseUserstoreDomainInLocalSubjectIdentifier()).thenReturn(appendUserStoreDomainToSubject);
AuthenticatedUser authenticatedUser = new AuthenticatedUser();
authenticatedUser.setUserName(authenticatedUserNameInSequence);
authenticatedUser.setTenantDomain(FOO_TENANT);
authenticatedUser.setUserStoreDomain(XY_USER_STORE_DOMAIN);
SequenceConfig sequenceConfig = spy(new SequenceConfig());
Map<Integer, StepConfig> stepConfigMap = new HashMap<>();
StepConfig stepConfig = spy(new StepConfig());
when(stepConfig.getAuthenticatedUser()).thenReturn(authenticatedUser);
when(stepConfig.isSubjectIdentifierStep()).thenReturn(false);
when(stepConfig.isSubjectAttributeStep()).thenReturn(false);
AuthenticatorConfig authenticatorConfig = new AuthenticatorConfig();
authenticatorConfig.setApplicationAuthenticator(authenticator);
when(stepConfig.getAuthenticatedAutenticator()).thenReturn(authenticatorConfig);
stepConfigMap.put(1, stepConfig);
sequenceConfig.setStepMap(stepConfigMap);
sequenceConfig.setAuthenticatedUser(authenticatedUser);
sequenceConfig.setApplicationConfig(applicationConfig);
// SP subject claim value
context.setProperty(FrameworkConstants.SERVICE_PROVIDER_SUBJECT_CLAIM_VALUE, spSubjectClaimValue);
context.setSequenceConfig(sequenceConfig);
stepBasedSequenceHandler.handlePostAuthentication(request, response, context);
assertEquals(context.getSequenceConfig().getAuthenticatedUser().getUserName(), authenticatedUserNameInSequence);
}
use of org.wso2.carbon.identity.application.authentication.framework.config.model.ApplicationConfig in project carbon-identity-framework by wso2.
the class DefaultStepBasedSequenceHandlerTest method testGetSpRoleClaimUri.
/*
Find SP mapped role claim URI among mapped claims
*/
@Test(dataProvider = "spRoleClaimUriProvider")
public void testGetSpRoleClaimUri(String spRoleClaimUri, String expectedRoleClaimUri) throws Exception {
Util.mockIdentityUtil();
ApplicationConfig appConfig = mock(ApplicationConfig.class);
when(appConfig.getRoleClaim()).thenReturn(spRoleClaimUri);
assertEquals(stepBasedSequenceHandler.getSpRoleClaimUri(appConfig), expectedRoleClaimUri);
}
use of org.wso2.carbon.identity.application.authentication.framework.config.model.ApplicationConfig in project carbon-identity-framework by wso2.
the class DefaultStepBasedSequenceHandlerTest method testGetSpRoleClaimUriSpMappedClaim.
/*
Get role claim URI from SP mapped claims
*/
@Test(dataProvider = "spClaimMappingProvider")
public void testGetSpRoleClaimUriSpMappedClaim(Map<String, String> claimMappings, String expectedRoleClaim) throws Exception {
Util.mockIdentityUtil();
ApplicationConfig appConfig = mock(ApplicationConfig.class);
when(appConfig.getClaimMappings()).thenReturn(claimMappings);
String roleClaim = stepBasedSequenceHandler.getSpRoleClaimUri(appConfig);
assertEquals(roleClaim, expectedRoleClaim);
}
Aggregations