use of org.wso2.carbon.identity.application.authentication.framework.handler.claims.ClaimHandler in project carbon-identity-framework by wso2.
the class FrameworkUtils method getClaimHandler.
/**
* @return
*/
public static ClaimHandler getClaimHandler() {
ClaimHandler claimHandler = null;
Object obj = ConfigurationFacade.getInstance().getExtensions().get(FrameworkConstants.Config.QNAME_EXT_CLAIM_HANDLER);
if (obj instanceof ClaimHandler) {
claimHandler = (ClaimHandler) obj;
} else {
claimHandler = DefaultClaimHandler.getInstance();
}
return claimHandler;
}
use of org.wso2.carbon.identity.application.authentication.framework.handler.claims.ClaimHandler in project carbon-identity-framework by wso2.
the class PostAuthAssociationHandlerTest method setupSuite.
@BeforeMethod
protected void setupSuite() throws Exception {
configurationLoader = new UIBasedConfigurationLoader();
mockStatic(FrameworkUtils.class);
mockStatic(ConfigurationFacade.class);
mockStatic(ClaimMetadataHandler.class);
mockStatic(IdentityTenantUtil.class);
ConfigurationFacade configurationFacade = mock(ConfigurationFacade.class);
PowerMockito.when(ConfigurationFacade.getInstance()).thenReturn(configurationFacade);
ClaimMetadataHandler claimMetadataHandler = mock(ClaimMetadataHandler.class);
PowerMockito.when(ClaimMetadataHandler.getInstance()).thenReturn(claimMetadataHandler);
Map<String, String> emptyMap = new HashMap<>();
PowerMockito.when(ClaimMetadataHandler.getInstance().getMappingsMapFromOtherDialectToCarbon(Mockito.anyString(), Mockito.anySet(), Mockito.anyString(), Mockito.anyBoolean())).thenReturn(emptyMap);
IdentityProvider identityProvider = getTestIdentityProvider("default-tp-1.xml");
ExternalIdPConfig externalIdPConfig = new ExternalIdPConfig(identityProvider);
Mockito.doReturn(externalIdPConfig).when(configurationFacade).getIdPConfigByName(Mockito.anyString(), Mockito.anyString());
when(FrameworkUtils.isStepBasedSequenceHandlerExecuted(Mockito.any(AuthenticationContext.class))).thenCallRealMethod();
when(FrameworkUtils.prependUserStoreDomainToName(Mockito.anyString())).thenCallRealMethod();
when(FrameworkUtils.buildClaimMappings(Mockito.anyMap())).thenCallRealMethod();
when(FrameworkUtils.getStandardDialect(Mockito.anyString(), Mockito.any(ApplicationConfig.class))).thenCallRealMethod();
request = mock(HttpServletRequest.class);
response = mock(HttpServletResponse.class);
postAuthAssociationHandler = PostAuthAssociationHandler.getInstance();
sp = getTestServiceProvider("default-sp-1.xml");
PowerMockito.when(FrameworkUtils.getMultiAttributeSeparator()).thenReturn(",");
ClaimHandler claimHandler = PowerMockito.mock(ClaimHandler.class);
Map<String, String> claims = new HashMap<>();
claims.put("claim1", "value1");
claims.put(FrameworkConstants.LOCAL_ROLE_CLAIM_URI, String.format("%s,%s", ORI_ROLE_1, ORI_ROLE_2));
PowerMockito.doReturn(claims).when(claimHandler).handleClaimMappings(any(StepConfig.class), any(AuthenticationContext.class), any(Map.class), anyBoolean());
PowerMockito.when(FrameworkUtils.getClaimHandler()).thenReturn(claimHandler);
}
use of org.wso2.carbon.identity.application.authentication.framework.handler.claims.ClaimHandler in project carbon-identity-framework by wso2.
the class DefaultRequestPathBasedSequenceHandlerTest method testHandleClaimMappingsErrorFlow.
@Test
public void testHandleClaimMappingsErrorFlow() throws Exception {
ClaimHandler claimHandler = mock(ClaimHandler.class);
doThrow(new FrameworkException("ERROR")).when(claimHandler).handleClaimMappings(any(StepConfig.class), any(AuthenticationContext.class), any(Map.class), anyBoolean());
mockStatic(FrameworkUtils.class);
when(FrameworkUtils.getClaimHandler()).thenReturn(claimHandler);
Map<String, String> claims = requestPathBasedSequenceHandler.handleClaimMappings(new AuthenticationContext());
assertNotNull(claims);
assertEquals(claims.size(), 0);
}
use of org.wso2.carbon.identity.application.authentication.framework.handler.claims.ClaimHandler in project carbon-identity-framework by wso2.
the class DefaultRequestPathBasedSequenceHandlerTest method testHandleClaimMappingsFailed.
@Test
public void testHandleClaimMappingsFailed() throws Exception {
ClaimHandler claimHandler = mock(ClaimHandler.class);
doThrow(new FrameworkException("Claim Handling failed")).when(claimHandler).handleClaimMappings(any(StepConfig.class), any(AuthenticationContext.class), any(Map.class), anyBoolean());
mockStatic(FrameworkUtils.class);
when(FrameworkUtils.getClaimHandler()).thenReturn(claimHandler);
Map<String, String> claims = requestPathBasedSequenceHandler.handleClaimMappings(new AuthenticationContext());
assertNotNull(claims);
assertEquals(claims.size(), 0);
}
use of org.wso2.carbon.identity.application.authentication.framework.handler.claims.ClaimHandler in project carbon-identity-framework by wso2.
the class Util method mockClaimHandler.
public static ClaimHandler mockClaimHandler() throws FrameworkException {
ClaimHandler claimHandler = mock(ClaimHandler.class);
Map<String, String> claims = new HashMap<>();
claims.put("claim1", "value1");
doReturn(claims).when(claimHandler).handleClaimMappings(any(StepConfig.class), any(AuthenticationContext.class), any(Map.class), anyBoolean());
return claimHandler;
}
Aggregations