use of org.wso2.carbon.identity.application.authentication.framework.handler.request.impl.PostAuthnMissingClaimHandler in project carbon-identity-framework by wso2.
the class FrameworkServiceComponent method activate.
@SuppressWarnings("unchecked")
@Activate
protected void activate(ComponentContext ctxt) {
FrameworkServiceDataHolder dataHolder = FrameworkServiceDataHolder.getInstance();
dataHolder.setJsFunctionRegistry(new JsFunctionRegistryImpl());
BundleContext bundleContext = ctxt.getBundleContext();
bundleContext.registerService(JsFunctionRegistry.class, dataHolder.getJsFunctionRegistry(), null);
bundleContext.registerService(UserSessionManagementService.class.getName(), new UserSessionManagementServiceImpl(), null);
bundleContext.registerService(HttpIdentityRequestFactory.class.getName(), new SessionExtenderRequestFactory(), null);
bundleContext.registerService(HttpIdentityResponseFactory.class.getName(), new SessionExtenderResponseFactory(), null);
bundleContext.registerService(IdentityProcessor.class.getName(), new SessionExtenderProcessor(), null);
ServerSessionManagementService serverSessionManagementService = new ServerSessionManagementServiceImpl();
bundleContext.registerService(ServerSessionManagementService.class.getName(), serverSessionManagementService, null);
dataHolder.setServerSessionManagementService(serverSessionManagementService);
setAdaptiveAuthExecutionSupervisor();
boolean tenantDropdownEnabled = ConfigurationFacade.getInstance().getTenantDropdownEnabled();
if (tenantDropdownEnabled) {
// Register the tenant management listener for tracking changes to tenants
bundleContext.registerService(TenantMgtListener.class.getName(), new AuthenticationEndpointTenantActivityListener(), null);
if (log.isDebugEnabled()) {
log.debug("AuthenticationEndpointTenantActivityListener is registered. Tenant Domains Dropdown is " + "enabled.");
}
}
AuthenticationMethodNameTranslatorImpl authenticationMethodNameTranslator = new AuthenticationMethodNameTranslatorImpl();
authenticationMethodNameTranslator.initializeConfigsWithServerConfig();
bundleContext.registerService(AuthenticationMethodNameTranslator.class, authenticationMethodNameTranslator, null);
dataHolder.setAuthenticationMethodNameTranslator(authenticationMethodNameTranslator);
// Register Common servlet
Servlet commonAuthServlet = new ContextPathServletAdaptor(new CommonAuthenticationServlet(), COMMON_SERVLET_URL);
Servlet identityServlet = new ContextPathServletAdaptor(new IdentityServlet(), IDENTITY_SERVLET_URL);
Servlet loginContextServlet = new ContextPathServletAdaptor(new LoginContextServlet(), LOGIN_CONTEXT_SERVLET_URL);
try {
httpService.registerServlet(COMMON_SERVLET_URL, commonAuthServlet, null, null);
httpService.registerServlet(IDENTITY_SERVLET_URL, identityServlet, null, null);
httpService.registerServlet(LOGIN_CONTEXT_SERVLET_URL, loginContextServlet, null, null);
} catch (Exception e) {
String errMsg = "Error when registering servlets via the HttpService.";
log.error(errMsg, e);
throw new RuntimeException(errMsg, e);
}
if (promptOnLongWait()) {
Servlet longWaitStatusServlet = new ContextPathServletAdaptor(new LongWaitStatusServlet(), LONGWAITSTATUS_SERVLET_URL);
try {
httpService.registerServlet(LONGWAITSTATUS_SERVLET_URL, longWaitStatusServlet, null, null);
} catch (Exception e) {
String errMsg = "Error when registering longwaitstatus servlet via the HttpService.";
log.error(errMsg, e);
throw new RuntimeException(errMsg, e);
}
}
dataHolder.setBundleContext(bundleContext);
dataHolder.getHttpIdentityRequestFactories().add(new HttpIdentityRequestFactory());
dataHolder.getHttpIdentityResponseFactories().add(new FrameworkLoginResponseFactory());
dataHolder.getHttpIdentityResponseFactories().add(new FrameworkLogoutResponseFactory());
JsGraphBuilderFactory jsGraphBuilderFactory = new JsGraphBuilderFactory();
jsGraphBuilderFactory.init();
UIBasedConfigurationLoader uiBasedConfigurationLoader = new UIBasedConfigurationLoader();
dataHolder.setSequenceLoader(uiBasedConfigurationLoader);
dataHolder.setJsGraphBuilderFactory(jsGraphBuilderFactory);
PostAuthenticationMgtService postAuthenticationMgtService = new PostAuthenticationMgtService();
bundleContext.registerService(PostAuthenticationMgtService.class.getName(), postAuthenticationMgtService, null);
dataHolder.setPostAuthenticationMgtService(postAuthenticationMgtService);
// Registering missing mandatory claim handler as a post authn handler
PostAuthenticationHandler postAuthnMissingClaimHandler = new PostAuthnMissingClaimHandler();
bundleContext.registerService(PostAuthenticationHandler.class.getName(), postAuthnMissingClaimHandler, null);
SSOConsentService ssoConsentService = new SSOConsentServiceImpl();
bundleContext.registerService(SSOConsentService.class.getName(), ssoConsentService, null);
dataHolder.setSSOConsentService(ssoConsentService);
bundleContext.registerService(PostAuthenticationHandler.class.getName(), consentMgtPostAuthnHandler, null);
JITProvisioningIdentityProviderMgtListener jitProvisioningIDPMgtListener = new JITProvisioningIdentityProviderMgtListener();
bundleContext.registerService(IdentityProviderMgtListener.class.getName(), jitProvisioningIDPMgtListener, null);
bundleContext.registerService(ClaimFilter.class.getName(), new DefaultClaimFilter(), null);
// this is done to load SessionDataStore class and start the cleanup tasks.
SessionDataStore.getInstance();
AsyncSequenceExecutor asyncSequenceExecutor = new AsyncSequenceExecutor();
asyncSequenceExecutor.init();
dataHolder.setAsyncSequenceExecutor(asyncSequenceExecutor);
LongWaitStatusDAOImpl daoImpl = new LongWaitStatusDAOImpl();
CacheBackedLongWaitStatusDAO cacheBackedDao = new CacheBackedLongWaitStatusDAO(daoImpl);
String connectionTimeoutString = IdentityUtil.getProperty("AdaptiveAuth.HTTPConnectionTimeout");
int connectionTimeout = 5000;
if (connectionTimeoutString != null) {
try {
connectionTimeout = Integer.parseInt(connectionTimeoutString);
} catch (NumberFormatException e) {
log.error("Error while parsing connection timeout : " + connectionTimeoutString, e);
}
}
LongWaitStatusStoreService longWaitStatusStoreService = new LongWaitStatusStoreService(cacheBackedDao, connectionTimeout);
dataHolder.setLongWaitStatusStoreService(longWaitStatusStoreService);
// Registering JIT, association and domain handler as post authentication handler
PostAuthenticationHandler postJITProvisioningHandler = JITProvisioningPostAuthenticationHandler.getInstance();
bundleContext.registerService(PostAuthenticationHandler.class.getName(), postJITProvisioningHandler, null);
PostAuthenticationHandler postAuthAssociationHandler = PostAuthAssociationHandler.getInstance();
bundleContext.registerService(PostAuthenticationHandler.class.getName(), postAuthAssociationHandler, null);
PostAuthenticationHandler postAuthenticatedUserDomainHandler = PostAuthenticatedSubjectIdentifierHandler.getInstance();
bundleContext.registerService(PostAuthenticationHandler.class.getName(), postAuthenticatedUserDomainHandler, null);
if (log.isDebugEnabled()) {
log.debug("Application Authentication Framework bundle is activated");
}
/**
* Load and reade the require.js file in resources.
*/
this.loadCodeForRequire();
// Set user session mapping enabled.
FrameworkServiceDataHolder.getInstance().setUserSessionMappingEnabled(FrameworkUtils.isUserSessionMappingEnabled());
if (FrameworkServiceDataHolder.getInstance().getSessionSerializer() == null) {
FrameworkServiceDataHolder.getInstance().setSessionSerializer(new JavaSessionSerializer());
}
bundleContext.registerService(ApplicationAuthenticationService.class.getName(), new ApplicationAuthenticationService(), null);
// Note : DO NOT add any activation related code below this point,
// to make sure the server doesn't start up if any activation failures
}
use of org.wso2.carbon.identity.application.authentication.framework.handler.request.impl.PostAuthnMissingClaimHandler in project carbon-identity-framework by wso2.
the class PostAuthnMissingClaimHandlerTest method testCorrectDisplayNamesDeriveForMissingClaims.
@SuppressWarnings("checkstyle:LocalVariableName")
@Test(description = "This test case tests the related display names for mandatory missing claims are derived")
public void testCorrectDisplayNamesDeriveForMissingClaims() throws NoSuchMethodException, InstantiationException, IllegalAccessException, InvocationTargetException {
List<AttributeMapping> mappedAttributes = new ArrayList<>();
Map<String, String> localClaimProperties = new HashMap<>();
localClaimProperties.put("Description", "Local");
localClaimProperties.put("DisplayName", "Local");
Map<String, String> localityClaimProperties = new HashMap<>();
localityClaimProperties.put("Description", "Locality");
localityClaimProperties.put("DisplayName", "Locality");
Map<String, String> secretKeyClaimProperties = new HashMap<>();
secretKeyClaimProperties.put("Description", "Claim to store the secret key");
secretKeyClaimProperties.put("DisplayName", "Secret Key");
Map<String, String> countryClaimProperties = new HashMap<>();
countryClaimProperties.put("Description", "Country");
countryClaimProperties.put("DisplayName", "Country");
Map<String, String> verifyEmailClaimProperties = new HashMap<>();
verifyEmailClaimProperties.put("Description", "Temporary claim to invoke email verified feature");
verifyEmailClaimProperties.put("DisplayName", "Verify Email");
List<LocalClaim> localClaims = new ArrayList<>();
LocalClaim localClaim = new LocalClaim("http://wso2.org/claims/local", mappedAttributes, localClaimProperties);
LocalClaim localClaim2 = new LocalClaim("http://wso2.org/claims/locality", mappedAttributes, localityClaimProperties);
LocalClaim localClaim3 = new LocalClaim("http://wso2.org/claims/identity/secretkey", mappedAttributes, secretKeyClaimProperties);
LocalClaim localClaim4 = new LocalClaim("http://wso2.org/claims/country", mappedAttributes, countryClaimProperties);
LocalClaim localClaim5 = new LocalClaim("http://wso2.org/claims/identity/verifyEmail", mappedAttributes, verifyEmailClaimProperties);
localClaims.add(localClaim);
localClaims.add(localClaim2);
localClaims.add(localClaim3);
localClaims.add(localClaim4);
localClaims.add(localClaim5);
Map<String, String> missingClaimMap = new HashMap<>();
missingClaimMap.put("http://wso2.org/claims/local", "http://wso2.org/claims/local");
missingClaimMap.put("http://wso2.org/claims/country", "http://wso2.org/claims/country");
missingClaimMap.put("http://wso2.org/claims/locality", "http://wso2.org/claims/locality");
String relatedDisplayNames = "http://wso2.org/claims/local|Local,http://wso2.org/claims/country|Country," + "http://wso2.org/claims/locality|Locality";
Class<PostAuthnMissingClaimHandler> claimDisplay = PostAuthnMissingClaimHandler.class;
Object obj = claimDisplay.newInstance();
Method displayName = claimDisplay.getDeclaredMethod("getMissingClaimsDisplayNames", Map.class, List.class);
displayName.setAccessible(true);
String returnedDisplayNames = (String) displayName.invoke(obj, missingClaimMap, localClaims);
assertEquals(returnedDisplayNames, relatedDisplayNames);
}
Aggregations