权限控制要做得好的话,是个很复杂的东西,也是不三言两语可以说清如果你只有一些简单的角色,那就用if ...else...去判断就是了.比方:
1.权限的授与<%
验证用户名及密码if (bSuccessed){
从数据库中查询取得用户的权限角色 request.getSession().setAttribute("UserRole") = "guest" //还比方可以为admin,user之类,依业务情况而定
}%>2.权限的鉴别
<%
String sRole = request.getSession().getAttribute("UserRole");//针对不同的权限给予不同的许可
if ("admin".equals(sRole))
....
else if (....)
....%>
1.权限的授与<%
验证用户名及密码if (bSuccessed){
从数据库中查询取得用户的权限角色 request.getSession().setAttribute("UserRole") = "guest" //还比方可以为admin,user之类,依业务情况而定
}%>2.权限的鉴别
<%
String sRole = request.getSession().getAttribute("UserRole");//针对不同的权限给予不同的许可
if ("admin".equals(sRole))
....
else if (....)
....%>
/* Table: Application */
/*==============================================================*/
create table Application (
ApplicationID VARCHAR2(20) not null,
ApplicationName VARCHAR2(100),
ApplicationLink VARCHAR2(200),
constraint PK_APPLICATION primary key (ApplicationID)
)
/
/*==============================================================*/
/* Table: Counter */
/*==============================================================*/
create table Counter (
value DECIMAL
)
/
/*==============================================================*/
/* Table: Permission */
/*==============================================================*/
create table Permission (
PermissionID DECIMAL not null,
ApplicationID VARCHAR2(20),
PermissionName VARCHAR2(50),
PermissionDesc VARCHAR2(100),
constraint PK_PERMISSION primary key (PermissionID),
constraint FK_PERMISSI_REFERENCE_APPLICAT foreign key (ApplicationID)
references Application (ApplicationID)
)
/
/*==============================================================*/
/* Table: Role */
/*==============================================================*/
create table Role (
RoleID DECIMAL not null,
RoleDesc VARCHAR(100),
constraint PK_ROLE primary key (RoleID)
)
/
/*==============================================================*/
/* Table: RolePermission */
/*==============================================================*/
create table RolePermission (
RoleID DECIMAL,
PermissionID DECIMAL,
constraint FK_ROLEPERM_REFERENCE_ROLE foreign key (RoleID)
references Role (RoleID),
constraint FK_ROLEPERM_REFERENCE_PERMISSI foreign key (PermissionID)
references Permission (PermissionID)
)
/
/*==============================================================*/
/* Table: UserInfo */
/*==============================================================*/
create table UserInfo (
UserID VARCHAR2(20) not null,
UserName VARCHAR2(20),
Password VARCHAR2(20),
constraint PK_USERINFO primary key (UserID)
)
/
/*==============================================================*/
/* Table: UserRole */
/*==============================================================*/
create table UserRole (
UserID VARCHAR2(20) not null,
RoleID DECIMAL not null,
constraint PK_USERROLE primary key (UserID, RoleID),
constraint FK_USERROLE_REFERENCE_USERINFO foreign key (UserID)
references UserInfo (UserID),
constraint FK_USERROLE_REFERENCE_ROLE foreign key (RoleID)
references Role (RoleID)
)
/
总感觉利用jsp来完成校验的安全性不够,不知道实际上是不是存在这些问题?
关于权限我觉得session仅仅是提供一个该用户id的标识。
真正的权限管理还是和session没有关系的。但是可以通过用户的id来从数据库获得他对某一操作的具体权限