java - How do I add an Access Denied Handler in spring-security-javaconfig -


i'm using spring-security-javaconfig library spring security. if using xml config files, i'd use define custom access denied page:

<http auto-config="true">     <intercept-url pattern="/admin*" access="role_admin" />     <access-denied-handler ref="accessdeniedhandler"/> </http> 

here security configuration class far:

@configuration @enablewebsecurity public class securityconfigurator extends websecurityconfigureradapter {      @override     protected void registerauthentication(authenticationmanagerbuilder auth)             throws exception {         auth.inmemoryauthentication().withuser("user").password("password").roles("user");         auth.inmemoryauthentication().withuser("admin").password("password").roles("admin");      }      @override     protected void configure(httpsecurity http) throws exception {         http.authorizeurls().antmatchers( "/admin").hasrole("admin");     } } 

i suppose should trick:

httpsecurity http = ... http.exceptionhandling().accessdeniedhandler(myaccessdeniedhandler); 

Comments

Popular posts from this blog

css - Which browser returns the correct result for getBoundingClientRect of an SVG element? -

gcc - Calling fftR4() in c from assembly -

Function that returns a formatted array in VBA -