cas服务器是5.3.14
依赖项包括: shiro-web 1.4.1
, shiro-spring 1.4.1
, buji-pac4j 4.1.1
以及 pac4j-cas 3.8.3
.
这个web应用是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;
}
}
的本地json文件 cas server
是:
{
"@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,..` 等
我想要的是在中获取详细的用户信息(用户id、用户no等) `java code` 在cas server authenticate success之后,例如,在cas server authenticate success之后,它将重定向到 `test.action` ,我需要在中获取详细的用户信息 `test.action` , .
我该怎么做?
暂无答案!
目前还没有任何答案,快来回答吧!