Search in sources :

Example 1 with MidpointRequestHeaderAuthenticationFilter

use of com.evolveum.midpoint.authentication.impl.filter.MidpointRequestHeaderAuthenticationFilter in project midpoint by Evolveum.

the class HttpHeaderModuleWebSecurityConfigurer method requestHeaderAuthenticationFilter.

private RequestHeaderAuthenticationFilter requestHeaderAuthenticationFilter() {
    MidpointRequestHeaderAuthenticationFilter filter = new MidpointRequestHeaderAuthenticationFilter();
    filter.setPrincipalRequestHeader(getConfiguration().getPrincipalRequestHeader());
    filter.setExceptionIfHeaderMissing(false);
    filter.setAuthenticationManager(authenticationManager);
    filter.setAuthenticationFailureHandler(new MidpointAuthenticationFailureHandler() {

        @Override
        protected String getPathAfterUnsuccessfulAuthentication(AuthenticationChannel authenticationChannel) {
            return "/error/401";
        }
    });
    MidPointAuthenticationSuccessHandler successHandler = new MidPointAuthenticationSuccessHandler() {

        @Override
        public void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication) throws ServletException, IOException {
            if (getRequestCache().getRequest(request, response) == null) {
                getRequestCache().saveRequest(request, response);
            }
            super.onAuthenticationSuccess(request, response, authentication);
        }
    };
    filter.setAuthenticationSuccessHandler(getObjectPostProcessor().postProcess(successHandler));
    filter.setSessionRegistry(getSessionRegistry());
    return filter;
}
Also used : MidPointAuthenticationSuccessHandler(com.evolveum.midpoint.authentication.impl.handler.MidPointAuthenticationSuccessHandler) HttpServletRequest(javax.servlet.http.HttpServletRequest) AuthenticationChannel(com.evolveum.midpoint.authentication.api.AuthenticationChannel) MidpointAuthenticationFailureHandler(com.evolveum.midpoint.authentication.impl.handler.MidpointAuthenticationFailureHandler) Authentication(org.springframework.security.core.Authentication) MidpointRequestHeaderAuthenticationFilter(com.evolveum.midpoint.authentication.impl.filter.MidpointRequestHeaderAuthenticationFilter) HttpServletResponse(javax.servlet.http.HttpServletResponse)

Aggregations

AuthenticationChannel (com.evolveum.midpoint.authentication.api.AuthenticationChannel)1 MidpointRequestHeaderAuthenticationFilter (com.evolveum.midpoint.authentication.impl.filter.MidpointRequestHeaderAuthenticationFilter)1 MidPointAuthenticationSuccessHandler (com.evolveum.midpoint.authentication.impl.handler.MidPointAuthenticationSuccessHandler)1 MidpointAuthenticationFailureHandler (com.evolveum.midpoint.authentication.impl.handler.MidpointAuthenticationFailureHandler)1 HttpServletRequest (javax.servlet.http.HttpServletRequest)1 HttpServletResponse (javax.servlet.http.HttpServletResponse)1 Authentication (org.springframework.security.core.Authentication)1