@Override protected void configure(HttpSecurity http) throws Exception { http.exceptionHandling().accessDeniedHandler(new AccessDeniedHandler() { @Override public void handle(HttpServletRequest request, HttpServletResponse response, AccessDeniedException accessDeniedException) throws IOException, ServletException { accessDeniedException.printStackTrace(); } }) .and() .authorizeRequests() .antMatchers("/registration").permitAll() .anyRequest().authenticated() .and() .httpBasic() .and() .csrf().disable() ; }
@Autowired public FormLoginSecurityConfig(AccessDeniedHandler accessDeniedHandler, UserDetailsService userDetailsService, OAuth2ClientContext oauth2ClientContext) { this.accessDeniedHandler = accessDeniedHandler; this.userDetailsService = userDetailsService; this.oauth2ClientContext = oauth2ClientContext; }
protected AccessDeniedHandler accessDeniedHandler() { return new AccessDeniedHandler() { @Override public void handle(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, AccessDeniedException e) throws IOException, ServletException { httpServletResponse.getWriter().append("Access denied"); httpServletResponse.setStatus(403); } }; }
@Autowired public ProfChoperSecurityConfig(@Qualifier("profChoperDataSource") DataSource dataSource, AccessDeniedHandler accessDeniedHandler, AuthenticationSuccessHandler successHandler) { this.dataSource = dataSource; this.accessDeniedHandler = accessDeniedHandler; this.successHandler = successHandler; }
@Bean public AccessDeniedHandler getJwtAccessDeniedHandler() { JwtAccessDeniedHandler handler = new JwtAccessDeniedHandler(); return handler; }
@Bean public AccessDeniedHandler accessDeniedHandler(){ AccessDeniedHandlerCustomImpl handler = new AccessDeniedHandlerCustomImpl(); handler.setErrorPage("/accessDenied"); return handler; }
@Bean public AccessDeniedHandler accessDeniedHandlerImpl() { return new AccessDeniedHandlerRestImpl(); }
@Bean public AccessDeniedHandler nonRedirectingAccessDeniedHandler(){ return new AccessDeniedHandlerImpl(); }
private AccessDeniedHandler accessDeniedHandler() { return new CsrfAccessDeniedHandler() { }; }
public void setOrdinaryAccessDeniedHandler(AccessDeniedHandler pImpl) { this.pImpl = pImpl; }
@Bean public AccessDeniedHandler accessDeniedHandler() { LinkedHashMap<Class<? extends AccessDeniedException>, AccessDeniedHandler> handlers = new LinkedHashMap<>(); handlers.put(CsrfException.class, new CsrfTokenExceptionHandler()); return new DelegatingAccessDeniedHandler(handlers, new AccessDeniedHandlerImpl()); }
/** * The oauth failure handler. * * @return The oauth failure handler. */ public AccessDeniedHandler getOAuthFailureHandler() { return OAuthFailureHandler; }
/** * The oauth failure handler. * * @param OAuthFailureHandler The oauth failure handler. */ public void setOAuthFailureHandler(AccessDeniedHandler OAuthFailureHandler) { this.OAuthFailureHandler = OAuthFailureHandler; }