OAM与spring的form方式SSO

1.修改org.springframework.security.ui.webapp.AuthenticationProcessingFilter类中的两个如下方法:
protected String obtainPassword(HttpServletRequest request) {
System.out.println("in my filter set password to BPS");
return "BPS";
}
protected String obtainUsername(HttpServletRequest request) {
String userName=request.getHeader("EMPID");
return userName;
}
见修改文件AuthenticationProcessingFilter.java
2.扩展类org.springframework.security.providers.dao.DaoAuthenticationProvider覆盖方法additionalAuthenticationChecks:
protected void additionalAuthenticationChecks(UserDetails userDetails, UsernamePasswordAuthenticationToken authentication) throws AuthenticationException { }
3.配置spring
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:s="http://www.springframework.org/schema/security"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-2.0.4.xsd"
default-autowire="byType" default-lazy-init="true">
<s:http auto-config='true'>
<s:intercept-url pattern="/*" access="ROLE_USER" /><!--拦截哪些URL-->
</s:http>
<bean id="bpsProcessingFilter" class="cn.com.bps.security.AuthenticationProcessingFilter">
<s:custom-filter before="AUTHENTICATION_PROCESSING_FILTER" />
<property name="defaultTargetUrl" value="/"></property>
</bean>
<bean id="oamAuthenticationProvider" class="cn.com.bps.security.OamDaoAuthenticationProvider">
<s:custom-authentication-provider />
<property name="userDetailsService" ref="userDetailsService" /><!--引用到spring-security.xml文件中定义的userService-->
</bean>
<s:user-service id="userDetailsService">
<s:user name="tim.doyle" password="abcd1234"
authorities="ROLE_USER" />
</s:user-service>
</beans>
4.配置OAM
OAM需要配置如附件所示的参数:
我们是通过EMPID来获取用户名的.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值