package net.hoyland.angel.sample;
import net.hoyland.angel.Angel;
import net.hoyland.angel.Branch;
import net.hoyland.angel.BranchRole;
import net.hoyland.angel.Function;
import net.hoyland.angel.FunctionComparator;
import net.hoyland.angel.Resource;
import net.hoyland.angel.Role;
import net.hoyland.angel.User;
public class Tester {
/**
* @param args
*/
public static void main(String[] args) {
// 定义受保护资源
Resource res = new Resource("保险柜");
// 定于受保护资源上的功能
Function fun = new Function(res, "withdraw", new FunctionComparator(){
private int max = 20;
public boolean compare(Object[] args) {
if(args.length==1&&args[0] instanceof Integer){
if(((Integer)(args[0])).intValue() <= max){
return true;
}else{
return false;
}
}
return false;
}
});
Function fun2 = new Function(res, "withdraw", new FunctionComparator(){
private int max = 30;
public boolean compare(Object[] args) {
if(args.length==1&&args[0] instanceof Integer){
if(((Integer)(args[0])).intValue() <= max){
return true;
}else{
return false;
}
}
return false;
}
});
// 定义角色
Role role = new Role("系统管理员");
// 设置角色具有此功能验证能力
role.getFunctions().add(fun); // 此角色具有<20的取款权限
//role.getFunctions().add(fun2); // 此角色具有<30的取款权限
// 定义用户
User me = new User();
// 用户加入角色
me.getRoles().add(role);
// 机构相关测试
Branch branch = new Branch("财务部");
BranchRole branchRole = new BranchRole("财务部人员");
branch.setRole(branchRole);
branchRole.getFunctions().add(fun2); // 此角色具有<30的取款权限
//hoy.setBranch(branch);
////////////////////////////////
//以上为系统预定义,以下开始验证//
////////////////////////////////
Angel angel = Angel.getInstance();
System.out.println(angel.auth(me, res, "withdraw", new Object[]{new Integer(30)}));
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
angel-20090811.rar (28个子文件)
.project 381B
bin
net
hoyland
angel
Branch.class 1KB
User.class 1KB
Function.class 1KB
BranchRole.class 358B
FunctionComparator.class 178B
Angel.class 2KB
Role.class 997B
IRole.class 109B
Resource.class 982B
Organization.class 513B
sample
Tester$2.class 749B
Tester$1.class 749B
Tester.class 2KB
test
net
hoyland
angel
sample
Tester.java 2KB
.settings
org.eclipse.jdt.core.prefs 629B
src
net
hoyland
angel
Branch.java 722B
IRole.java 61B
Resource.java 584B
Role.java 530B
User.java 683B
BranchRole.java 228B
FunctionComparator.java 116B
Organization.java 229B
Function.java 734B
Angel.java 988B
.classpath 342B
doc
README 148B
lib
共 28 条
- 1
hoyzhang
- 粉丝: 3
- 资源: 8
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
- 1
- 2
- 3
- 4
- 5
前往页