login and security system with Mysql

Go To StackoverFlow.com

0

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.

2012-04-05 20:02
by Darth Blue Ray


0

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.

2012-04-05 20:12
by barsju
through the security system I had in mind that a user could have just one role, because the "higher" you go in securitylevel the more stuff you can do. So I can just integrate the one table in the other ... - Darth Blue Ray 2012-04-05 20:16
I would do that yes - barsju 2012-04-05 20:17
But the global idea is about right ... - Darth Blue Ray 2012-04-05 20:43
Yes. Just look into how to store passwords in a secure way and how to avoid SQL injection - barsju 2012-04-05 20:52
Ads