@Override protected void unsuccessfulAuthentication(HttpServletRequest request, HttpServletResponse response, AuthenticationException failed) throws IOException, ServletException { if (failed instanceof AccessTokenRequiredException) { // Need to force a redirect via the OAuth client filter, so rethrow here throw failed; } else { // If the exception is not a Spring Security exception this will result in a default error page super.unsuccessfulAuthentication(request, response, failed); } }
@Override public void setApplicationEventPublisher(ApplicationEventPublisher eventPublisher) { this.eventPublisher = eventPublisher; super.setApplicationEventPublisher(eventPublisher); }
/** * Sets the loginPage and updates the {@link AuthenticationEntryPoint}. * @param loginPage */ private void setLoginPage(String loginPage) { this.loginPage = loginPage; this.authenticationEntryPoint = new LoginUrlAuthenticationEntryPoint(loginPage); }
AuthenticationFailureHandler getSessionAuthenticationFailureHandler() { if (this.sessionAuthenticationFailureHandler != null) { return this.sessionAuthenticationFailureHandler; } if (this.sessionAuthenticationErrorUrl == null) { return null; } if (this.sessionAuthenticationFailureHandler == null) { this.sessionAuthenticationFailureHandler = new SimpleUrlAuthenticationFailureHandler( this.sessionAuthenticationErrorUrl); } return this.sessionAuthenticationFailureHandler; }
public void onAuthenticationFailure(HttpServletRequest request, HttpServletResponse response, AuthenticationException exception) throws IOException, ServletException { if (serviceTicketRequest(request, response)) { serviceTicketFailureHandler.onAuthenticationFailure(request, response, exception); } else { proxyFailureHandler.onAuthenticationFailure(request, response, exception); } } }
@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); }
/** * Creates a new instance * @throws Exception * @see HttpSecurity#httpBasic() */ public HttpBasicConfigurer() throws Exception { realmName(DEFAULT_REALM); LinkedHashMap<RequestMatcher, AuthenticationEntryPoint> entryPoints = new LinkedHashMap<>(); entryPoints.put(X_REQUESTED_WITH, new HttpStatusEntryPoint(HttpStatus.UNAUTHORIZED)); DelegatingAuthenticationEntryPoint defaultEntryPoint = new DelegatingAuthenticationEntryPoint( entryPoints); defaultEntryPoint.setDefaultEntryPoint(this.basicAuthEntryPoint); this.authenticationEntryPoint = defaultEntryPoint; }
@Override public void afterPropertiesSet() { Assert.state(restTemplate != null, "Supply a rest-template"); super.afterPropertiesSet(); }
/** * 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)); }
/** * OpenIdConnectAuthenticationFilter constructor */ public OIDCAuthenticationFilter() { super(FILTER_PROCESSES_URL); targetSuccessHandler.passthrough = super.getSuccessHandler(); super.setAuthenticationSuccessHandler(targetSuccessHandler); }
/** * The HTTP parameter to look for the username when performing authentication. Default * is "username". * * @param usernameParameter the HTTP parameter to look for the username when * performing authentication * @return the {@link FormLoginConfigurer} for additional customization */ public FormLoginConfigurer<H> usernameParameter(String usernameParameter) { getAuthenticationFilter().setUsernameParameter(usernameParameter); return this; }
/** * The HTTP parameter to look for the password when performing authentication. Default * is "password". * * @param passwordParameter the HTTP parameter to look for the password when * performing authentication * @return the {@link FormLoginConfigurer} for additional customization */ public FormLoginConfigurer<H> passwordParameter(String passwordParameter) { getAuthenticationFilter().setPasswordParameter(passwordParameter); return this; }
@Override public void setAuthenticationSuccessHandler(AuthenticationSuccessHandler successHandler) { targetSuccessHandler.passthrough = successHandler; super.setAuthenticationSuccessHandler(targetSuccessHandler); }
@Override public String toString() { StringBuilder result = new StringBuilder(); result.append(super.toString()); result.append("ServiceUrl: "); result.append(serviceUrl); return result.toString(); }
/** * Gets the HTTP parameter that is used to submit the username. * * @return the HTTP parameter that is used to submit the username */ private String getUsernameParameter() { return getAuthenticationFilter().getUsernameParameter(); }
@Override protected String determineTargetUrl(HttpServletRequest request, HttpServletResponse response) { String targetUrl = super.determineTargetUrl(request, response); return targetUrl; }
@Override public int hashCode() { final int prime = 31; int result = super.hashCode(); result = prime * result + serviceUrl.hashCode(); return result; }
@Override public void configure(H http) throws Exception { authenticationFilter.afterPropertiesSet(); http.addFilter(authenticationFilter); }
/** * Forward Authentication Success Handler * * @param forwardUrl the target URL in case of success * @return the {@link FormLoginConfigurer} for additional customization */ public FormLoginConfigurer<H> successForwardUrl(String forwardUrl) { successHandler(new ForwardAuthenticationSuccessHandler(forwardUrl)); return this; }
@Override protected void successfulAuthentication(HttpServletRequest request, HttpServletResponse response, FilterChain chain, Authentication authResult) throws IOException, ServletException { super.successfulAuthentication(request, response, chain, authResult); // Nearly a no-op, but if there is a ClientTokenServices then the token will now be stored restTemplate.getAccessToken(); }