Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Storing pages a user can access

 
Dave Bosky
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to restrict users to specific pages after they properly login.
What would be the best method for storing the pages?

Should I store all the pages the user has access to in a session ArrayList variable and then check each page to see if a match is found in the list using a filter?

Thanks,
Dave
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64633
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you talking about storing the pages themselves? (If so, why?)

Or are you asking about a mechanism to determine who has access to what?
 
Dave Bosky
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I was asking about a mechanism to determine who has access to which pages and method would be best to accomplish this task. Sorry for the ill formatted question...

Thanks,
Dave
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64633
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
One way to handle this could be to assign each user a role. Each page requires certain roles in order to be accessed. For example, admin pages require users to have the "ADMININSTRATOR" role.

There are lots of ways to keep track of which roles each page requires. One of the simplest might be a Map in the application context that uses the URI of the page as a key to a list of required roles (or a single role if your layout is that simple). This could be loaded by a context listener at app startup, perhaps from a properties file or an XML file.

If a role-based approach isn't appropriate, then there may be other ways. More info on how your app operates and is organized would be necessary.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic