security - spring authentication entry point -


i have controller method, annotated with

@requestmapping(value = "/someting") @preauthorize("hasanyrole('role_active')") ... 

when users without role transit on mapping want make users without appropriate role of redirect home page , displays alert, fact access denied.

to solve problem make custom accessdeniedhandler, works perfectly, authenticated users

for users without authentication found authenticationentrypoint looks like

public class customauthenticationentrypoint implements authenticationentrypoint {      @override     public void commence(httpservletrequest httpservletrequest,                      httpservletresponse httpservletresponse,                      authenticationexception e) throws ioexception, servletexception {         flashmap flashmap = requestcontextutils.getoutputflashmap(httpservletrequest);         if(flashmap != null) {             alerts.addwarningalert(flashmap, "access denied");         }         httpservletresponse.sendredirect("/");     }  } 

my alert can added flash attributes or model of main page, flash map in method have null value

how can solve without redirecting other controller, redirects main page , add value model? or can add flash attributes http servlet response?

it possible using session attributes. added attribute , take attribute session in alerts handler.


Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -