本文关于有没有好的权限控制系统javaweb,据
亚洲金融智库2022-09-07日讯:
java web 项目的系统权限管有两种:
方法一、SpringMVC整合Shiro (Shiro是强大的权限管理框架)
方法二、基于角色的访问权限控制
基于角色的访问权限控制
首先基于角色的访问权限控制,所有的用户访问都会经过过滤,然后分析访问权限加以认证!权限中的重点,表的设计。
普遍三张表,表名自定义。用户表(User),角色表(Role),资源表(Resource)
用户表没有特别,很简单。关键是角色表和资源表。
编写一个完整的Java 程序,包括User和TestUser两个类。
import java.util.Scanner;
public class TestUser {
public static void main(String[] args) {
User user = new User(Zhang san, abcdefg);
System.out.println(user.toString());
Scanner scanner = new Scanner(System.in);
System.out.print(Please input old password:);
String oldPassword = scanner.next();
System.out.print(Please input new password:);
String newPassowd = scanner.next();
user.setPassword(oldPassword, newPassowd);
System.out.println(user.toString());
}
}
class User{
private String userName;
private String password;
private static int userNumber = 0;
public User(){
userNumber += 1;
userName = unknown;
password = 123456;
}
public User(String userName){
userNumber += 1;
this.userName = userName;
password = 123456;
}
public User(String userName, String password){
userNumber+=1;
this.userName = userName;
this.password = password;
}
public void setPassword(String oldPassword,String newPassword){
if(oldPassword.equals(password)){
password = newPassword;
System.out.println(Password set success);
}else{
System.out.println(Password set not success);
}
}
public String toString(){
return Username : + this.userName + , Password: + this.password;
}
}
-----------------------
Username : Zhang san, Password: abcdefg
Please input old password:abcdefg
Please input new password:1234567
Password set success
Username : Zhang san, Password: 1234567
专题推荐:
风险管控系统 开源 java(25)