Ariyan
Ariyan

Reputation: 15158

Method for storing access rights of user

I'm creating an application in Java (& using Mysql as DBMS).
My app. has users and each user can be permitted or not permitted for each feature of app. there are 8 different static permissions.
How can I store these permissions for each user?
Is it a good idea to store it like Unix file mode bits (e.g. 0775)?

Thanks

Upvotes: 1

Views: 987

Answers (3)

Raveesh Sharma
Raveesh Sharma

Reputation: 1486

3 of the many many approaches:

1) database : define roles like admin, manager etc. so that they can have viewing, writing roles. the tables will contain the users and the roles assigned to them.

2) xml files for storing the names and the roles. (Tomcat is a good example. u can store the roles in conf.xml)

3) if u want to chuck out db and xml.. simple bit operations can also help u. http://vipan.com/htdocs/bitwisehelp.html

this site explains how to use permissions using bit operations.

Upvotes: 2

Matthias Bruns
Matthias Bruns

Reputation: 900

You could do it in the database.

Users_Table

ID

FIRSTNAME

LASTNAME

Users_RIGHTS

USER_ID

RIGHT_ID

RIGHTS_TALBE

ID

NAME

Upvotes: 1

Bhavik Ambani
Bhavik Ambani

Reputation: 6657

You can store in values in bit format like

for Permission 1 you can store value as 00000001 For Permission 2 you can store value as 00000010

and so on

And you use bitwise And(&) operation for mapping or validating the permissions of the users

Upvotes: 2

Related Questions