• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to assign permission to user roles.  RSS feed

 
Ranch Hand
Posts: 33
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I need general advice on assigning permission to user roles.
In my Java Swing application I want to assign different permission levels to different users.

Ex : Admin - has permission to access all forms and perform all functions such as Add, Delete, Update and Search
User1 - has Permission to access all forms and perform Add, Update and search functions.

User2 - has permission to access some forms and perform only Add and search functions.

In Order to do this I want to enable and disable some forms and some buttons(Ex. Add, Delete )according to user group.
I guess there should be many different ways to do this. I would like to know whats the best way to develop user permission levels according to my application.
I found the code given below. But im not sure how to use this code in my application.

 
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
rayan alex wrote:I would like to know whats the best way to develop user permission levels according to my application.


There isn't any one best way, and nobody here knows enough about your requirements to even provide much in the way of suggestions.

I found the code given below. But im not sure how to use this code in my application.


What in particular do you not understand about it? One thing I can say is that this deals with fixed set of actions, whereas you're talking about not only fixed actions, but also allowing specific combinations of action+object on which the action is performed. You can still use this approach, but instead of a user having just one set of permissions, he'll need something like a Map<Form, Set<Permission>>, or perhaps you control access by form rather than by user, in which case a form might have a Map<User, Set<Permission>>.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!