CAS client 端添加初始化参数传到server端

1. 修改client 端web应用的web.xml,如下:
<filter>
<filter-name>CAS Authentication Filter</filter-name>
<filter-class>org.jasig.cas.client.authentication.AuthenticationFilter</filter-class>
<init-param>
<param-name>casServerLoginUrl</param-name>
<!-- CAS服务端地址-->
<param-value>http://192.168.104.123:8080/cas/login</param-value>
</init-param>
<init-param>
<param-name>service</param-name>
<!-- 本地地址-->
<param-value>http://192.168.104.101:8080/*</param-value>
</init-param>
<init-param>
<param-name>renew</param-name>
<param-value>false</param-value>
<!-- 这个如果为true 每次登录子系统都要验证,就不能实现登陆一次,可以访问其他子系统的需求 -->
</init-param>
<init-param>
<param-name>webRootKey</param-name>
<param-value>test</param-value>
</init-param>
</filter>

其中webRootKey参数为client添加的初始化参数,想传到server端

2. 修改org.jasig.cas.client.authentication.AuthenticationFilter.java如下:
添加属性webRootKey
/**
* the web app root key
*/
private String webRootKey;

提供set方法
public final  void setWebRootKey(final String webRootKey){
this.webRootKey = webRootKey;
}

修改initInternal方法,添加
setWebRootKey(getPropertyFromInitParams(filterConfig, "webRootKey", null));
log.trace("Loaded WebRootKey parameter: " + this.webRootKey);

修改init方法,添加
 CommonUtils.assertNotNull(this.webRootKey, "webRootKey cannot be null.");



3 自定义Credentials类继承UsernamePasswordCredentials,内容如下:
private static final long serialVersionUID = 179318697348051866L;

/** the web root key */
private String webRootKey;

public String getWebRootKey() {
return webRootKey;
}

public void setWebRootKey(String webRootKey) {
this.webRootKey = webRootKey;
}


4 修改自定义验证类(继承 AbstractJdbcUsernamePasswordAuthenticationHandler)的authenticateUsernamePasswordInternal方法如下:
FinalUserCredentials finalUserCredentials = (FinalUserCredentials) credentials;
String username = finalUserCredentials.getUsername();
String password = finalUserCredentials.getPassword();

/** get web root key */
String webRootKey = finalUserCredentials.getWebRootKey();
既可以获得webRootKey扩展参数。
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值