简体   繁体   English

使用 Mysql 登录和安全系统

[英]login and security system with Mysql

I need to make a java program with a security and a login system for a project at school我需要为学校的项目制作一个带有安全和登录系统的 java 程序

I was thinking of using a enum for the security role in java with a security level:我正在考虑使用枚举作为 java 中具有安全级别的安全角色:

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在 mysql 我想做两个表

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.将其保留在单独的表中的唯一原因是用户是否可以拥有多个角色。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM