Welcome file chosen based on assigned roles (Java web app)?
I have a Java web application running on JBoss using JAAS for authentication. I would like to dynamically select the page a user logging in is shown based upon their roles as I have disjoint sets of users that should not have access to the same pages.
I tried using a Filter, but Tomcat denies access (correctly) to the requested URL before the filter has a chance to run.
Create a servlet for serving up the files. Tell Tomcat all users have access to the URL pattern this servlet is bound to, but then in the servlet check the user's credentials and server the appropriate file (or an error) based on said credentials.
Risposta num. 1
Have the welcome file defined that is protected. The welcome file does a server side forward to specific pages that are defined based on the user roles.
To illustrate step by step what could happen
- Create the welcome page say standard-welcome.jsp. Users can access this page via http://://standard-welcome.jsp
- Secure this welcome page to authenticated users only
- When user accesses this item they are redirected to the login page
- Upon successful login, the server initiates the forward to this welcome page
- Welcome page checks the role via a Custom Tag. The user role is known at this point in time.
- User sees the page that is the default for their role.