基础包添加cas依赖,新增获取用户信息代码
This commit is contained in:
@@ -199,6 +199,12 @@
|
||||
<artifactId>poi-ooxml</artifactId>
|
||||
<version>4.1.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jasig.cas.client</groupId>
|
||||
<artifactId>cas-client-core</artifactId>
|
||||
<version>3.5.0</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<build>
|
||||
<finalName>hcframe-base</finalName>
|
||||
|
||||
@@ -12,4 +12,5 @@ public class FrameConfig {
|
||||
private Integer loginTimeout = 4;
|
||||
private Boolean showControllerLog = true;
|
||||
private Boolean multiDataSource = true;
|
||||
private Boolean cas = false;
|
||||
}
|
||||
|
||||
@@ -9,6 +9,8 @@ import org.apache.shiro.authc.*;
|
||||
import org.apache.shiro.authz.AuthorizationInfo;
|
||||
import org.apache.shiro.realm.AuthorizingRealm;
|
||||
import org.apache.shiro.subject.PrincipalCollection;
|
||||
import org.jasig.cas.client.authentication.AttributePrincipal;
|
||||
import org.jasig.cas.client.validation.AssertionImpl;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
@@ -40,7 +42,12 @@ public class CustomRealm extends AuthorizingRealm {
|
||||
protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken token) {
|
||||
String accessToken = (String) token.getPrincipal();
|
||||
String userId;
|
||||
if (frameConfig.getIsRedisLogin()) {
|
||||
if (frameConfig.getCas()) {
|
||||
Map<Object,Object> hashMap = (Map<Object, Object>) redisUtil.hget("session",accessToken);
|
||||
AssertionImpl assertion = (AssertionImpl) hashMap.get("_const_cas_assertion_");
|
||||
AttributePrincipal attributePrincipal = assertion.getPrincipal();
|
||||
return new SimpleAuthenticationInfo(attributePrincipal.getAttributes(), accessToken, this.getName());
|
||||
}else if (frameConfig.getIsRedisLogin()) {
|
||||
Map<Object,Object> hashMap = (Map<Object, Object>) redisUtil.hget("tokenSession",accessToken);
|
||||
userId = (String) hashMap.get("userId");
|
||||
if (userId == null) {
|
||||
|
||||
Reference in New Issue
Block a user