问题描述
cas服务器是5.3.14
依赖性为:shiro-web 1.4.1
,shiro-spring 1.4.1
,buji-pac4j 4.1.1
和pac4j-cas 3.8.3
。
此网络应用是struts2 + spring
我添加了
<filter>
<filter-name>shiroFilter</filter-name>
<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
<init-param>
<param-name>targetBeanName</param-name>
<param-value>shiroFilter</param-value>
</init-param>
</filter>
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.Filterdispatcher</filter-class>
</filter>
<filter-mapping>
<filter-name>shiroFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
到web.xml
。
CasRealm
扩展了Pac4jRealm
:
public class CasRealm extends Pac4jRealm {
private String clientName;
@Override
protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken authenticationToken) throws AuthenticationException {
final Pac4jToken pac4jToken = (Pac4jToken) authenticationToken;
final List<CommonProfile> commonProfileList = pac4jToken.getProfiles();
final CommonProfile commonProfile = commonProfileList.get(0);
final Pac4jPrincipal principal = new Pac4jPrincipal(commonProfileList,getPrincipalNameAttribute());
final PrincipalCollection principalCollection = new SimplePrincipalCollection(principal,getName());
return new SimpleAuthenticationInfo(principalCollection,commonProfileList.hashCode());
}
@Override
protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection principals) {
...
}
public String getClientName() {
return clientName;
}
public void setClientName(String clientName) {
this.clientName = clientName;
}
}
cas server
的本地json文件是:
{
"@class": "org.apereo.cas.services.RegexRegisteredService","serviceId": "^(http)://192.168.0.14.*","name": "local service","id": 10000003,"description": "","evaluationorder": 1
}
application.properties
中的 cas server
如下:
cas.authn.jdbc.query[0].url=jdbc:MysqL://localhost:3306/test
cas.authn.jdbc.query[0].user=root
cas.authn.jdbc.query[0].password=123456
cas.authn.jdbc.query[0].sql=select * from user where staff_no = ?
cas.authn.jdbc.query[0].fieldPassword=password
cas.authn.jdbc.query[0].driverClass=com.MysqL.cj.jdbc.Driver
cas.authn.jdbc.query[0].passwordEncoder.type=DEFAULT
cas.authn.jdbc.query[0].passwordEncoder.characterEncoding=UTF-8
cas.authn.jdbc.query[0].passwordEncoder.encodingalgorithm=MD5
表user
包含列user_id,user_no,email,..
等
我想要的是在cas服务器身份验证成功后在java code
中获取详细的用户信息(例如user_id,user_no等),例如,在cas服务器身份验证成功后,它将重定向到test.action
,我需要在test.action
,。
我该怎么做?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)