Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes Swing / AWT / SWT and the fly likes Setting permission on certain part of an application Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Setting permission on certain part of an application" Watch "Setting permission on certain part of an application" New topic
Author

Setting permission on certain part of an application

Dalia Sultana
Ranch Hand

Joined: Jul 16, 2006
Posts: 42
Hi All,

I am trying to enable/disable certain parts of an application depending on the user's role. Every dialog at start up checks for the role of the current user and enables or disables various parts. Somehow it doesn't seem that object oriented to me but can't think of a better way either. I was just wondering if there is a standard way to do this.

Thanks,

Dalia
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 37970
    
  22
Sounds like a call to the Strategy pattern.

Put all your users into a HashMap, with objects representing their access status; loading that object at log-in time will activate and deactivate the appropriate parts of the application.
Dalia Sultana
Ranch Hand

Joined: Jul 16, 2006
Posts: 42
I am not sure, I follow your suggestion. Perhaps, I was unclear as to what it is that I am trying to achieve. The application has many dialogs with buttons, tables and checkboxes. Depending on what user is currently accessing it certain buttons/checkboxes need to disappear or become disabled. This is currently done at initialization of the dialog. I was wondering if there is a way to extract this part of the code out in a different module somehow. These bits and pieces of code check to see what role the user has and then enables/disables the appropriate buttons/checkboxes. I am not sure if this is the best way to this. I was just wondering if there is a standard/well accepted way to do this.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Setting permission on certain part of an application
 
Similar Threads
Filter or RequestProcessor
Create unprotected area
Get List Of Roles
Getting defined security-roles programatically
How to set the security role name?