jsf 2 - JSF Redirect page based on User role -


i have 2 types of admin. super admin , normal admin.

both start on page admin.xhtml.

i want forward super admin users super-admin.xhtml , normal admin normal-admin.xhtml.

how do in jsf (i'm using spring security)?

i'm unfamiliar jsf, assuming functions under hood spring mvc jsp application, can have controller deliver different page depending on role(s) held user:

@requestmapping("/admin.xhtml") @preauthorize("hasanyrole('role_admin', 'role_superadmin')") public string getadminpage(modelmap model, principal principal) {     collection<? extends grantedauthority> authorities = securitycontextholder.getcontext().getauthentication().getauthorities();     (grantedauthority authority : authorities) {         if (authority.tostring() == "role_superadmin") { return "superadminpage"; }     }     //no need check admin privileges, since annotation took care of     //if you're not using annotations (or @postauthorize), you'd have capture     //'admin' role well, , adjust return statements accordingly.     return "adminpage"; } 

Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

qt - Errors in generated MOC files for QT5 from cmake -