@Override protected void successfulAuthentication(HttpServletRequest request, HttpServletResponse response, FilterChain chain, Authentication authResult) throws IOException, ServletException { super.successfulAuthentication(request, response, chain, authResult); chain.doFilter(request, response); }
@Override public void afterPropertiesSet() { Assert.state(restTemplate != null, "Supply a rest-template"); super.afterPropertiesSet(); }
@Override public void configure(B http) throws Exception { PortMapper portMapper = http.getSharedObject(PortMapper.class); if (portMapper != null) { authenticationEntryPoint.setPortMapper(portMapper); } RequestCache requestCache = http.getSharedObject(RequestCache.class); if (requestCache != null) { this.defaultSuccessHandler.setRequestCache(requestCache); } authFilter.setAuthenticationManager(http .getSharedObject(AuthenticationManager.class)); authFilter.setAuthenticationSuccessHandler(successHandler); authFilter.setAuthenticationFailureHandler(failureHandler); if (authenticationDetailsSource != null) { authFilter.setAuthenticationDetailsSource(authenticationDetailsSource); } SessionAuthenticationStrategy sessionAuthenticationStrategy = http .getSharedObject(SessionAuthenticationStrategy.class); if (sessionAuthenticationStrategy != null) { authFilter.setSessionAuthenticationStrategy(sessionAuthenticationStrategy); } RememberMeServices rememberMeServices = http .getSharedObject(RememberMeServices.class); if (rememberMeServices != null) { authFilter.setRememberMeServices(rememberMeServices); } F filter = postProcess(authFilter); http.addFilter(filter); }
/** * OpenIdConnectAuthenticationFilter constructor */ public OIDCAuthenticationFilter() { super(FILTER_PROCESSES_URL); targetSuccessHandler.passthrough = super.getSuccessHandler(); super.setAuthenticationSuccessHandler(targetSuccessHandler); }
@Bean public AbstractAuthenticationProcessingFilter loginFilter( ObjectMapper objectMapper, AuthenticationManager authenticationManager, AuthenticationSuccessHandler authenticationSuccessHandler, AuthenticationFailureHandler authenticationFailureHandler, RememberMeServices rememberMeServices) { AbstractAuthenticationProcessingFilter loginFilter = new LoginFilter(LOGIN_ENDPOINT, objectMapper); loginFilter.setAuthenticationManager(authenticationManager); loginFilter.setAuthenticationSuccessHandler(authenticationSuccessHandler); loginFilter.setAuthenticationFailureHandler(authenticationFailureHandler); loginFilter.setRememberMeServices(rememberMeServices); return loginFilter; }
HttpServletResponse response = (HttpServletResponse) res; if (!requiresAuthentication(request, response)) { chain.doFilter(request, response); authResult = attemptAuthentication(request, response); if (authResult == null) { "An internal error occurred while trying to authenticate the user.", failed); unsuccessfulAuthentication(request, response, failed); unsuccessfulAuthentication(request, response, failed); successfulAuthentication(request, response, chain, authResult);
/** * Indicates if the request is elgible to process a service ticket. This method exists * for readability. * @param request * @param response * @return */ private boolean serviceTicketRequest(final HttpServletRequest request, final HttpServletResponse response) { boolean result = super.requiresAuthentication(request, response); if (logger.isDebugEnabled()) { logger.debug("serviceTicketRequest = " + result); } return result; }
/** * Wraps the {@link AuthenticationFailureHandler} to distinguish between handling * proxy ticket authentication failures and service ticket failures. */ @Override public final void setAuthenticationFailureHandler( AuthenticationFailureHandler failureHandler) { super.setAuthenticationFailureHandler(new CasAuthenticationFailureHandler( failureHandler)); }
@Override public void setApplicationEventPublisher(ApplicationEventPublisher eventPublisher) { this.eventPublisher = eventPublisher; super.setApplicationEventPublisher(eventPublisher); }
/** * Sets the URL used to determine if this Filter is invoked * @param filterProcessesUrl the URL used to determine if this Filter is invoked */ @Override public void setFilterProcessesUrl(String filterProcessesUrl) { this.filterProcessesUrl = filterProcessesUrl; super.setFilterProcessesUrl(filterProcessesUrl); }
/** * Creates a new Keycloak authentication processing filter with given {@link AuthenticationManager} and * {@link RequestMatcher}. * <p> * Note: the given request matcher must support matching the <code>Authorization</code> header if * bearer token authentication is to be accepted. * </p> * * @param authenticationManager the {@link AuthenticationManager} to authenticate requests (cannot be null) * @param requiresAuthenticationRequestMatcher the {@link RequestMatcher} used to determine if authentication * is required (cannot be null) * * @see RequestHeaderRequestMatcher * @see OrRequestMatcher * */ public KeycloakAuthenticationProcessingFilter(AuthenticationManager authenticationManager, RequestMatcher requiresAuthenticationRequestMatcher) { super(requiresAuthenticationRequestMatcher); Assert.notNull(authenticationManager, "authenticationManager cannot be null"); this.authenticationManager = authenticationManager; super.setAuthenticationManager(authenticationManager); super.setAllowSessionCreation(false); super.setContinueChainBeforeSuccessfulAuthentication(false); }
@Autowired public void setAuthenticationManager( AuthenticationManager authenticationManager) { super.setAuthenticationManager(authenticationManager); }
@Override public void setAuthenticationSuccessHandler(AuthenticationSuccessHandler successHandler) { targetSuccessHandler.passthrough = successHandler; super.setAuthenticationSuccessHandler(targetSuccessHandler); }
@Override @Autowired(required = false) public void setRememberMeServices(RememberMeServices rememberMeServices) { super.setRememberMeServices(rememberMeServices); }
@Override protected boolean requiresAuthentication(HttpServletRequest request, HttpServletResponse response) { String clientId = request.getParameter("client_id"); if (clientId == null) { // Give basic auth a chance to work instead (it's preferred anyway) return false; } return super.requiresAuthentication(request, response); } }
/** * Wraps the {@link AuthenticationFailureHandler} to distinguish between handling * proxy ticket authentication failures and service ticket failures. */ @Override public final void setAuthenticationFailureHandler( AuthenticationFailureHandler failureHandler) { super.setAuthenticationFailureHandler(new CasAuthenticationFailureHandler( failureHandler)); }
@Override public void setApplicationEventPublisher(ApplicationEventPublisher eventPublisher) { this.eventPublisher = eventPublisher; super.setApplicationEventPublisher(eventPublisher); }
@Override public void setFilterProcessesUrl(String filterProcessesUrl) { super.setFilterProcessesUrl(filterProcessesUrl); this.filterProcessesUrl = filterProcessesUrl; }
/** * OpenIdConnectAuthenticationFilter constructor */ public OIDCAuthenticationFilter() { super(FILTER_PROCESSES_URL); targetSuccessHandler.passthrough = super.getSuccessHandler(); super.setAuthenticationSuccessHandler(targetSuccessHandler); }
@Override public void setAuthenticationSuccessHandler(AuthenticationSuccessHandler successHandler) { targetSuccessHandler.passthrough = successHandler; super.setAuthenticationSuccessHandler(targetSuccessHandler); }