I need to make a java program with a security and a login system for a project at school
I was thinking of using a enum for the security role in java with a security level:
public enum Role {
lECTOR(0), COORDINATOR(1), ADMINISTRATOR(2);
private int securityLevel;
Role(int securityLevel) {
this.securityLevel = securityLevel;
}
public int returnSecurityLevel() {
return securityLevel;
}
In mysql I'm thinking of making two tables
table users with a userid, username, password and security_id
roles with a security_id, rolename this table I would link to the enum
depending on the securitylevel I would then say what a specific user can or can't do.
Is this a good way to work or not, any suggestions are more then welcome.
You should consider if you really need a separate table for the enum. Maybe just have a column for it in the user table.
The only reason to keep it a separate table is if a user can have multiple roles.