spring security 配置看不明,求助!!!

fondOfJava 2009-07-30 03:32:03
security.xml配置文件如下:
<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns="http://www.springframework.org/schema/security" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:beans="http://www.springframework.org/schema/beans"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-2.0.1.xsd">

<http auto-config="true" lowercase-comparisons="false">
<!--intercept-url pattern="/images/*" filters="none"/>
<intercept-url pattern="/styles/*" filters="none"/>
<intercept-url pattern="/scripts/*" filters="none"/-->
<intercept-url pattern="/admin/*" access="ROLE_ADMIN"/>
<intercept-url pattern="/passwordHint.html*" access="ROLE_ANONYMOUS,ROLE_ADMIN,ROLE_USER,ROLE_MANAGER"/>
<intercept-url pattern="/signup.html*" access="ROLE_ANONYMOUS,ROLE_ADMIN,ROLE_USER,ROLE_MANAGER"/>
<intercept-url pattern="/a4j.res/*.html*" access="ROLE_ANONYMOUS,ROLE_ADMIN,ROLE_USER,ROLE_MANAGER"/>
<intercept-url pattern="/bank*.html*" access="ROLE_ADMIN,ROLE_MANAGER"/>
<intercept-url pattern="/charge*.html*" access="ROLE_ADMIN,ROLE_MANAGER"/>
<!-- APF-737, OK to remove line below if you're not using JSF -->
<intercept-url pattern="/**/*.html*" access="ROLE_ADMIN,ROLE_USER,ROLE_MANAGER"/>
<form-login login-page="/login.jsp" authentication-failure-url="/login.jsp?error=true" login-processing-url="/j_security_check"/>
<remember-me user-service-ref="userDao" key="e37f4b31-0c45-11dd-bd0b-0800200c9a66"/>
</http>


<!--关键是这里看不明,spring是将form里的j_username和j_password传递给userDao吗???-->
<authentication-provider user-service-ref="userDao">
<password-encoder ref="passwordEncoder"/>
</authentication-provider>



<!-- Override the default password-encoder (SHA) by uncommenting the following and changing the class -->
<!-- <bean id="passwordEncoder" class="org.springframework.security.providers.encoding.ShaPasswordEncoder"/> -->


<global-method-security>
<protect-pointcut expression="execution(* *..service.UserManager.getUsers(..))" access="ROLE_ADMIN"/>
<protect-pointcut expression="execution(* *..service.UserManager.removeUser(..))" access="ROLE_ADMIN"/>
</global-method-security>
</beans:beans>
###########################################################################################################
<!--关键是这里看不明,spring是将form里的j_username和j_password传递给userDao吗???-->
<authentication-provider user-service-ref="userDao">
<password-encoder ref="passwordEncoder"/>
</authentication-provider>
...全文
479 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
SINCE1978 2009-08-01
  • 打赏
  • 举报
回复
<authentication-provider user-service-ref="userDao">
<password-encoder ref="passwordEncoder"/>
</authentication-provider>

SS2里一个普遍用法是manager轮询provider,当有一个provider可以验证或授权即可。
这里配置了自定义的userDao用于认证、根据登录提交的用户名查询到用户信息然后比较提交密码和数据库存储的密码。好的方式是将提交密码在页面上提交前用js加密,对付点的直接提交明文,这样比较密码就需要密码编解码器,也就是注入的passwordEncoder,看看它继承了什么就明白了。
floger 2009-07-31
  • 打赏
  • 举报
回复
[Quote=引用 8 楼 xblue3 的回复:]
<!--关键是这里看不明,spring是将form里的j_username和j_password传递给userDao吗???-->
<authentication-provider user-service-ref="userDao">
<password-encoder ref="passwordEncoder"/>
</authentication-provider>
[/Quote]
这里不是spRING 将form 参数传递给这个UserDao的,而是 secrty的里封装好的方法根据你添加的这个dao自动对应实现的
meadking 2009-07-31
  • 打赏
  • 举报
回复
[Quote=引用 7 楼 yangxuebao123 的回复:]
不知道你这里面有没有MD5加密,注意的事要把密码变为小写(全部)
[/Quote]

可以设定为md5加密的哦
yangxuebao123 2009-07-30
  • 打赏
  • 举报
回复
<!--关键是这里看不明,spring是将form里的j_username和j_password传递给userDao吗???-->
<authentication-provider user-service-ref="userDao">
<password-encoder ref="passwordEncoder"/>
</authentication-provider>


我虽然只做过acegi但是这我还是明白滴。


<!-- 进行简单的基于数据库的身份验证。
DaoAuthenticationProvider获取数据库中的账号密码并进行匹配,
若成功则在通过用户身份的同时返回一个包含授权信息的Authentication对象,
否则身份验证失败,抛出一个AuthenticatiionException。 -->

j_username和j_password是默认的传进去比较/

不知道你这里面有没有MD5加密,注意的事要把密码变为小写(全部)

flyxxxxx 2009-07-30
  • 打赏
  • 举报
回复
<authentication-provider user-service-ref="userDao">
<password-encoder ref="passwordEncoder"/>
</authentication-provider>

通过userDao和j_username查出用户的密码,再和j_password比较。如果密码是加密的,先用passwordEncoder对j_password加密,再与查出的密码比较。
meadking 2009-07-30
  • 打赏
  • 举报
回复
在这里回答比较复杂,代码很长.
给你一个网站吧.

http://www.javaeye.com/topic/319965

应该是Acegi2.0吧?
1.0可复杂多了,我也不明白
beanj 2009-07-30
  • 打赏
  • 举报
回复
不明白,帮你顶一下。
紫炎圣骑 2009-07-30
  • 打赏
  • 举报
回复
学习,知道的来说一下
NJL_ILY_2009 2009-07-30
  • 打赏
  • 举报
回复
我也想知道 学习
yuanchangyuan2125 2009-07-30
  • 打赏
  • 举报
回复
学习

67,515

社区成员

发帖
与我相关
我的任务
社区描述
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
  • Java EE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧