Search in sources :

Example 1 with HttpClusterModuleFactory

use of com.evolveum.midpoint.authentication.impl.factory.module.HttpClusterModuleFactory in project midpoint by Evolveum.

the class AuthSequenceUtil method getSpecificModuleFilter.

private static List<AuthModule> getSpecificModuleFilter(AuthModuleRegistryImpl authRegistry, String urlSuffix, HttpServletRequest httpRequest, Map<Class<?>, Object> sharedObjects, AuthenticationModulesType authenticationModulesType, CredentialsPolicyType credentialPolicy) {
    String localePath = httpRequest.getRequestURI().substring(httpRequest.getContextPath().length());
    String channel = searchChannelByPath(localePath);
    if (LOCAL_PATH_AND_CHANNEL.get("ws").equals(channel)) {
        String header = httpRequest.getHeader("Authorization");
        if (header != null) {
            String type = header.split(" ")[0];
            if (AuthenticationModuleNameConstants.CLUSTER.equalsIgnoreCase(type)) {
                List<AuthModule> authModules = new ArrayList<>();
                HttpClusterModuleFactory factory = authRegistry.findModelFactoryByClass(HttpClusterModuleFactory.class);
                AbstractAuthenticationModuleType module = new AbstractAuthenticationModuleType() {
                };
                module.setName(AuthenticationModuleNameConstants.CLUSTER.toLowerCase() + "-module");
                try {
                    authModules.add(factory.createModuleFilter(module, urlSuffix, httpRequest, sharedObjects, authenticationModulesType, credentialPolicy, null));
                } catch (Exception e) {
                    LOGGER.error("Couldn't create module for cluster authentication");
                    return null;
                }
                return authModules;
            }
        }
    }
    return null;
}
Also used : AuthModule(com.evolveum.midpoint.authentication.api.AuthModule) HttpClusterModuleFactory(com.evolveum.midpoint.authentication.impl.factory.module.HttpClusterModuleFactory) ServletException(javax.servlet.ServletException) AuthenticationException(org.springframework.security.core.AuthenticationException) AuthenticationServiceException(org.springframework.security.authentication.AuthenticationServiceException) IOException(java.io.IOException)

Aggregations

AuthModule (com.evolveum.midpoint.authentication.api.AuthModule)1 HttpClusterModuleFactory (com.evolveum.midpoint.authentication.impl.factory.module.HttpClusterModuleFactory)1 IOException (java.io.IOException)1 ServletException (javax.servlet.ServletException)1 AuthenticationServiceException (org.springframework.security.authentication.AuthenticationServiceException)1 AuthenticationException (org.springframework.security.core.AuthenticationException)1