Search in sources :

Example 16 with ModuleAuthenticationImpl

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

the class MidpointAnonymousAuthenticationFilter method processAuthentication.

protected void processAuthentication(ServletRequest req) {
    if (SecurityContextHolder.getContext().getAuthentication() instanceof MidpointAuthentication) {
        MidpointAuthentication mpAuthentication = (MidpointAuthentication) SecurityContextHolder.getContext().getAuthentication();
        ModuleAuthenticationImpl moduleAuthentication = (ModuleAuthenticationImpl) mpAuthentication.getProcessingModuleAuthentication();
        if (moduleAuthentication != null && moduleAuthentication.getAuthentication() == null) {
            Authentication authentication = createBasicAuthentication((HttpServletRequest) req);
            moduleAuthentication.setAuthentication(authentication);
            mpAuthentication.setPrincipal(authentication.getPrincipal());
        }
    }
}
Also used : ModuleAuthenticationImpl(com.evolveum.midpoint.authentication.impl.module.authentication.ModuleAuthenticationImpl) MidpointAuthentication(com.evolveum.midpoint.authentication.api.config.MidpointAuthentication) Authentication(org.springframework.security.core.Authentication) MidpointAuthentication(com.evolveum.midpoint.authentication.api.config.MidpointAuthentication)

Example 17 with ModuleAuthenticationImpl

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

the class MidpointExceptionTranslationFilter method sendStartAuthentication.

@Override
protected void sendStartAuthentication(HttpServletRequest request, HttpServletResponse response, FilterChain chain, AuthenticationException reason) throws ServletException, IOException {
    Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
    if (!AuthSequenceUtil.isRecordSessionLessAccessChannel(request)) {
        requestCache.saveRequest(request, response);
    }
    LOGGER.debug("Calling Authentication entry point.");
    getAuthenticationEntryPoint().commence(request, response, reason);
    if (authentication instanceof MidpointAuthentication) {
        MidpointAuthentication mpAuthentication = (MidpointAuthentication) authentication;
        ModuleAuthenticationImpl moduleAuthentication = (ModuleAuthenticationImpl) mpAuthentication.getProcessingModuleAuthentication();
        if (moduleAuthentication != null && moduleAuthentication.getAuthentication() instanceof AnonymousAuthenticationToken) {
            moduleAuthentication.setAuthentication(createNewAuthentication((AnonymousAuthenticationToken) moduleAuthentication.getAuthentication()));
            mpAuthentication.setPrincipal(null);
        }
        SecurityContextHolder.getContext().setAuthentication(mpAuthentication);
    }
}
Also used : ModuleAuthenticationImpl(com.evolveum.midpoint.authentication.impl.module.authentication.ModuleAuthenticationImpl) MidpointAuthentication(com.evolveum.midpoint.authentication.api.config.MidpointAuthentication) Authentication(org.springframework.security.core.Authentication) AnonymousAuthenticationToken(org.springframework.security.authentication.AnonymousAuthenticationToken) MidpointAuthentication(com.evolveum.midpoint.authentication.api.config.MidpointAuthentication)

Example 18 with ModuleAuthenticationImpl

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

the class PreLogoutFilter method doFilter.

@Override
public void doFilter(ServletRequest request, ServletResponse response) {
    Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
    ModuleAuthenticationImpl moduleAuthentication = null;
    if (authentication != null && authentication.isAuthenticated()) {
        moduleAuthentication = (ModuleAuthenticationImpl) AuthUtil.getAuthenticatedModule();
    }
    if (authentication == null || ((moduleAuthentication == null || !moduleAuthentication.isInternalLogout()) && !((HttpServletRequest) request).getServletPath().endsWith("/logout"))) {
        return;
    }
    if (moduleAuthentication != null) {
        moduleAuthentication.setState(AuthenticationModuleState.LOGOUT_PROCESSING);
    }
}
Also used : ModuleAuthenticationImpl(com.evolveum.midpoint.authentication.impl.module.authentication.ModuleAuthenticationImpl) Authentication(org.springframework.security.core.Authentication)

Example 19 with ModuleAuthenticationImpl

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

the class HttpClusterModuleFactory method createEmptyModuleAuthentication.

private ModuleAuthenticationImpl createEmptyModuleAuthentication(ModuleWebSecurityConfiguration configuration) {
    ModuleAuthenticationImpl moduleAuthentication = new ModuleAuthenticationImpl(AuthenticationModuleNameConstants.CLUSTER);
    moduleAuthentication.setPrefix(configuration.getPrefixOfModule());
    moduleAuthentication.setNameOfModule(configuration.getNameOfModule());
    return moduleAuthentication;
}
Also used : ModuleAuthenticationImpl(com.evolveum.midpoint.authentication.impl.module.authentication.ModuleAuthenticationImpl)

Aggregations

ModuleAuthenticationImpl (com.evolveum.midpoint.authentication.impl.module.authentication.ModuleAuthenticationImpl)19 MidpointAuthentication (com.evolveum.midpoint.authentication.api.config.MidpointAuthentication)9 Authentication (org.springframework.security.core.Authentication)8 HttpSecurity (org.springframework.security.config.annotation.web.builders.HttpSecurity)7 SecurityFilterChain (org.springframework.security.web.SecurityFilterChain)7 ModuleAuthentication (com.evolveum.midpoint.authentication.api.config.ModuleAuthentication)2 LdapModuleAuthentication (com.evolveum.midpoint.authentication.impl.module.authentication.LdapModuleAuthentication)2 AnonymousAuthenticationToken (org.springframework.security.authentication.AnonymousAuthenticationToken)2 AuthModule (com.evolveum.midpoint.authentication.api.AuthModule)1 AuthenticationChannel (com.evolveum.midpoint.authentication.api.AuthenticationChannel)1 ModuleWebSecurityConfiguration (com.evolveum.midpoint.authentication.api.ModuleWebSecurityConfiguration)1 MidpointAnonymousAuthenticationFilter (com.evolveum.midpoint.authentication.impl.filter.MidpointAnonymousAuthenticationFilter)1 LdapDirContextAdapter (com.evolveum.midpoint.authentication.impl.ldap.LdapDirContextAdapter)1 CredentialModuleAuthenticationImpl (com.evolveum.midpoint.authentication.impl.module.authentication.CredentialModuleAuthenticationImpl)1 OidcClientModuleAuthenticationImpl (com.evolveum.midpoint.authentication.impl.module.authentication.OidcClientModuleAuthenticationImpl)1 RemoteModuleAuthenticationImpl (com.evolveum.midpoint.authentication.impl.module.authentication.RemoteModuleAuthenticationImpl)1 Saml2ModuleAuthenticationImpl (com.evolveum.midpoint.authentication.impl.module.authentication.Saml2ModuleAuthenticationImpl)1 HttpHeaderModuleWebSecurityConfiguration (com.evolveum.midpoint.authentication.impl.module.configuration.HttpHeaderModuleWebSecurityConfiguration)1 LdapModuleWebSecurityConfiguration (com.evolveum.midpoint.authentication.impl.module.configuration.LdapModuleWebSecurityConfiguration)1 OidcClientModuleWebSecurityConfiguration (com.evolveum.midpoint.authentication.impl.module.configuration.OidcClientModuleWebSecurityConfiguration)1