Java开发网 Java开发网
注册 | 登录 | 帮助 | 搜索 | 排行榜 | 发帖统计  

您没有登录

» Java开发网 » Architecture & Framework  

按打印兼容模式打印这个话题 打印话题    把这个话题寄给朋友 寄给朋友    该主题的所有更新都将Email到你的邮箱 订阅主题
flat modethreaded modego to previous topicgo to next topicgo to back
作者 使用STRUTS,做权限验证的时候,大家都用什么方法???
uu_snow



发贴: 0
积分: 0
于 2003-07-01 09:33 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
我的一个项目,除了首页和一个登陆页以外,其他所有的页面都要进行
权限验证,我用的是STRUTS做的
为了方便进行权限验证,而不是在每个页面里都写一段类似的权限验证代码
有两种方式:
1、利用SERVLET2.3中的Filter来做
2、是不是可以继承ActionServlet,然后在它里面加上权限验证的代码

大家都是怎么做?或者我说的这两种方式那种更可行?



作者 Re:使用STRUTS,做权限验证的时候,大家都用什么方法??? [Re:uu_snow]
灯泡



发贴: 0
积分: 0
于 2003-07-01 11:03 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
我也正在做类似地东西,我觉得没有必要继承,先交给过滤器处理,通过后在交给actionServlet处理。
探讨一下!



作者 Re:使用STRUTS,做权限验证的时候,大家都用什么方法??? [Re:uu_snow]
uu_snow



发贴: 0
积分: 0
于 2003-07-01 12:06 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
是不是在web.xml里写类似:
<filter-mapping>
  <filter-name>AclFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
这就表示整个网站的页面都要过这个Filter?

如果是这样,那我想实现只对网站的/下的a.jsp和b.jsp做FILTER
对网站下某几个目录做FILTER
应该怎么写呢?



作者 Re:使用STRUTS,做权限验证的时候,大家都用什么方法??? [Re:uu_snow]
灯泡



发贴: 0
积分: 0
于 2003-07-01 14:05 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
<filter-mapping>
<filter-name>AclFilter</filter-name>
<url-pattern>/a.jsp</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>AclFilter</filter-name>
<url-pattern>/b.jsp</url-pattern>
</filter-mapping>

please try !



作者 Re:使用STRUTS,做权限验证的时候,大家都用什么方法??? [Re:uu_snow]
noodle



发贴: 0
积分: 0
于 2003-07-01 14:14 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
使用filter是一个比较好的解决方案,sourceforge里的securityfilter应用的很广,在很多开放代码的项目中都有应用。


作者 Re:使用STRUTS,做权限验证的时候,大家都用什么方法??? [Re:uu_snow]
Johnny

I will rock you



发贴: 87
积分: 10
于 2003-07-02 12:45 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
servlet2.2是不是还不支持filter,要到2.3才支持?


作者 Re:使用STRUTS,做权限验证的时候,大家都用什么方法??? [Re:Johnny]
floater

Java Jedi

总版主


发贴: 3233
积分: 421
于 2003-07-02 23:02 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
Johnny wrote:
servlet2.2是不是还不支持filter,要到2.3才支持?

yea, you need >=2.3



"Any fool can write code that a computer can understand. Good programmers write code that humans can understand."
- Martin Fowler, Refactoring - Improving the Design of Existing Code
作者 Re:使用STRUTS,做权限验证的时候,大家都用什么方法??? [Re:uu_snow]
yuan





发贴: 114
积分: 20
于 2003-07-03 09:39 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
如果每个页面都要用过滤器,会不会影响速度?

我暂时是在每个页面上用一个JavaBean,然后用<logic:equal>标签来判断。
这样做怎么样了?



作者 Re:使用STRUTS,做权限验证的时候,大家都用什么方法??? [Re:uu_snow]
uu_snow



发贴: 0
积分: 0
于 2003-07-03 14:52 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
当然会影响速度了

但是在在每个页面都判断一次,又嫌太麻烦



作者 Re:使用STRUTS,做权限验证的时候,大家都用什么方法??? [Re:uu_snow]
floater

Java Jedi

总版主


发贴: 3233
积分: 421
于 2003-07-04 04:25 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
1. dont worry about speed.
2. always always seperate AA(Authorization & Authentication) from your applications code.
3. always always seperate authorization from authentication, they are related, but 2 different subjects.
4. On top of the above, your infrastructure has an impact on this too.



"Any fool can write code that a computer can understand. Good programmers write code that humans can understand."
- Martin Fowler, Refactoring - Improving the Design of Existing Code
作者 Re:使用STRUTS,做权限验证的时候,大家都用什么方法??? [Re:uu_snow]
cashtang





发贴: 2
积分: 0
于 2003-07-30 16:53 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
struts 1.1 有一个<controller>标签,你可以使用自己的RequestProcessor,这样的话你就可以subclass RequestProcessor,然后写你自己的processRoles()方法,这个方法会在进行请求时被调用。


作者 Re:使用STRUTS,做权限验证的时候,大家都用什么方法??? [Re:uu_snow]
l_walker





发贴: 43
积分: 10
于 2003-08-05 10:59 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
www.chinaxp.org里的xpform中就有filter做权限验证的类,下来看看就知道了,很简单

还可以用J2EE应用服务器来做权限验证,在web.xml中配置相应的secutriy就可以了,具体请参见J2EE相关手册:)

给你段例子:
====================
那么在web.xml中配置:
<security-constraint>
<display-name>admin</display-name>
<Web-resource-collection>
<Web-resource-name>Admin Area</Web-resource-name>
<!-- admin路径下所有资源 -->
<url-pattern>/admin/*</url-pattern>
<!-- protected路径下所有资源 -->
<url-pattern>/account/auth/*</url-pattern>
</Web-resource-collection>
<auth-constraint>
<!-- 定义角色为admin -->
<role-name>admin</role-name>
</auth-constraint>
<user-data-constraint>
<transport-guarantee>NONE</transport-guarantee>
</user-data-constraint>
</security-constraint>
这样,如果用户以网址http://localhost:8080/admin/访问时,容器将检验通过登陆验证用户的角色,如果是admin角色,将会正常访问,否则会被拒绝。
=========================



作者 Re:使用STRUTS,做权限验证的时候,大家都用什么方法??? [Re:uu_snow]
jackzhuo





发贴: 102
积分: 40
于 2003-08-07 22:41 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
我现在在做的项目,我想采用的方法是:
在登录成功后,将与该用户相关的所有信息保存在一个对象中,然后将此对象保存在session中,以后的每个页面都从session中找到这个对象检查一下就可以了.不过我不太清楚session在struts中怎么使用,所以已经在此区中发了一个贴子询问,不知道我的想法对不对?




flat modethreaded modego to previous topicgo to next topicgo to back
  已读帖子
  新的帖子
  被删除的帖子
Jump to the top of page

   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923