Search in sources :

Example 1 with RemoteModuleAuthenticationImpl

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

the class RemoteAuthenticationFilter method doRemoteFilter.

default void doRemoteFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException {
    Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
    boolean sentRequest = false;
    if (authentication instanceof MidpointAuthentication) {
        MidpointAuthentication mpAuthentication = (MidpointAuthentication) authentication;
        RemoteModuleAuthenticationImpl moduleAuthentication = (RemoteModuleAuthenticationImpl) mpAuthentication.getProcessingModuleAuthentication();
        if (moduleAuthentication != null && RequestState.SENDED.equals(moduleAuthentication.getRequestState())) {
            sentRequest = true;
        }
        boolean requiresAuthentication = requiresAuth((HttpServletRequest) req, (HttpServletResponse) res);
        if (!requiresAuthentication && sentRequest) {
            AuthenticationServiceException exception = new AuthenticationServiceException(getErrorMessageKeyNotResponse());
            unsuccessfulAuth((HttpServletRequest) req, (HttpServletResponse) res, exception);
        } else {
            if (moduleAuthentication != null && requiresAuthentication && sentRequest) {
                moduleAuthentication.setRequestState(RequestState.RECEIVED);
            }
            doAuth(req, res, chain);
        }
    } else {
        throw new AuthenticationServiceException("Unsupported type of Authentication");
    }
}
Also used : RemoteModuleAuthenticationImpl(com.evolveum.midpoint.authentication.impl.module.authentication.RemoteModuleAuthenticationImpl) MidpointAuthentication(com.evolveum.midpoint.authentication.api.config.MidpointAuthentication) Authentication(org.springframework.security.core.Authentication) MidpointAuthentication(com.evolveum.midpoint.authentication.api.config.MidpointAuthentication) AuthenticationServiceException(org.springframework.security.authentication.AuthenticationServiceException)

Example 2 with RemoteModuleAuthenticationImpl

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

the class AuthSequenceUtil method doRemoteFilter.

public static void doRemoteFilter(ServletRequest req, ServletResponse res, FilterChain chain, RemoteAuthenticationFilter remoteFilter) throws IOException, ServletException {
    Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
    boolean sendedRequest = false;
    if (authentication instanceof MidpointAuthentication) {
        MidpointAuthentication mpAuthentication = (MidpointAuthentication) authentication;
        RemoteModuleAuthenticationImpl moduleAuthentication = (RemoteModuleAuthenticationImpl) mpAuthentication.getProcessingModuleAuthentication();
        if (moduleAuthentication != null && RequestState.SENDED.equals(moduleAuthentication.getRequestState())) {
            sendedRequest = true;
        }
        boolean requiresAuthentication = remoteFilter.requiresAuth((HttpServletRequest) req, (HttpServletResponse) res);
        if (!requiresAuthentication && sendedRequest) {
            AuthenticationServiceException exception = new AuthenticationServiceException("web.security.flexAuth.oidc.not.response");
            remoteFilter.unsuccessfulAuth((HttpServletRequest) req, (HttpServletResponse) res, exception);
        } else {
            if (moduleAuthentication != null && requiresAuthentication && sendedRequest) {
                moduleAuthentication.setRequestState(RequestState.RECEIVED);
            }
            remoteFilter.doAuth(req, res, chain);
        }
    } else {
        throw new AuthenticationServiceException("Unsupported type of Authentication");
    }
}
Also used : RemoteModuleAuthenticationImpl(com.evolveum.midpoint.authentication.impl.module.authentication.RemoteModuleAuthenticationImpl) Authentication(org.springframework.security.core.Authentication) HttpModuleAuthentication(com.evolveum.midpoint.authentication.impl.module.authentication.HttpModuleAuthentication) ModuleAuthentication(com.evolveum.midpoint.authentication.api.config.ModuleAuthentication) MidpointAuthentication(com.evolveum.midpoint.authentication.api.config.MidpointAuthentication) MidpointAuthentication(com.evolveum.midpoint.authentication.api.config.MidpointAuthentication) AuthenticationServiceException(org.springframework.security.authentication.AuthenticationServiceException)

Aggregations

MidpointAuthentication (com.evolveum.midpoint.authentication.api.config.MidpointAuthentication)2 RemoteModuleAuthenticationImpl (com.evolveum.midpoint.authentication.impl.module.authentication.RemoteModuleAuthenticationImpl)2 AuthenticationServiceException (org.springframework.security.authentication.AuthenticationServiceException)2 Authentication (org.springframework.security.core.Authentication)2 ModuleAuthentication (com.evolveum.midpoint.authentication.api.config.ModuleAuthentication)1 HttpModuleAuthentication (com.evolveum.midpoint.authentication.impl.module.authentication.HttpModuleAuthentication)1