org.springframework.security.web.access.ExceptionTranslationFilter Java Examples
The following examples show how to use
org.springframework.security.web.access.ExceptionTranslationFilter.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SecurityConfig.java From Spring with Apache License 2.0 | 6 votes |
@Override protected void configure(HttpSecurity http) throws Exception { http.authorizeRequests() .regexMatchers("/chief/.*").hasRole("CHIEF") .regexMatchers("/agent/.*").access("hasRole('USER') and principal.name='James Bond'") .anyRequest().authenticated() .and().httpBasic() .and().requiresChannel().anyRequest().requiresSecure(); http.exceptionHandling().accessDeniedPage("/accessDenied"); http.formLogin().loginPage("/login").permitAll(); http.logout().logoutUrl("/customlogout"); http.addFilterBefore(securityContextPersistenceFilter(), SecurityContextPersistenceFilter.class); http.addFilterAt(exceptionTranslationFilter(), ExceptionTranslationFilter.class); http.addFilter(filterSecurityInterceptor()); // This ensures filter ordering by default http.addFilterAfter(new CustomFilter(), FilterSecurityInterceptor.class); }
Example #2
Source File: SecurityConfig.java From Spring with Apache License 2.0 | 5 votes |
@Bean public ExceptionTranslationFilter exceptionTranslationFilter() { final AuthenticationEntryPoint loginUrlAuthenticationEntryPoint = new LoginUrlAuthenticationEntryPoint("/login.jsp"); final AccessDeniedHandlerImpl accessDeniedHandlerImpl = new AccessDeniedHandlerImpl(); accessDeniedHandlerImpl.setErrorPage("/accessDenied.jsp"); final ExceptionTranslationFilter eTranslationFilter = new ExceptionTranslationFilter(loginUrlAuthenticationEntryPoint); eTranslationFilter.setAccessDeniedHandler(accessDeniedHandlerImpl); return eTranslationFilter; }