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
Post a Comment