From 108ed1c548b7dc17ce47dcadea80e4c42a2f29e7 Mon Sep 17 00:00:00 2001 From: lyfO_o <764716047@qq.com> Date: 星期六, 16 七月 2022 17:33:17 +0800 Subject: [PATCH] 改造 --- safePlatfrom-out-web/src/main/java/com/gkhy/safePlatform/config/security/TokenAuthenticationFilter.java | 16 ++++++++-------- 1 files changed, 8 insertions(+), 8 deletions(-) diff --git a/safePlatfrom-out-web/src/main/java/com/gkhy/safePlatform/config/security/TokenAuthenticationFilter.java b/safePlatfrom-out-web/src/main/java/com/gkhy/safePlatform/config/security/TokenAuthenticationFilter.java index 8617cb2..1316c2a 100644 --- a/safePlatfrom-out-web/src/main/java/com/gkhy/safePlatform/config/security/TokenAuthenticationFilter.java +++ b/safePlatfrom-out-web/src/main/java/com/gkhy/safePlatform/config/security/TokenAuthenticationFilter.java @@ -4,8 +4,8 @@ import com.alibaba.fastjson.JSONObject; import com.gkhy.safePlatform.account.rpc.apimodel.AccountAuthService; import com.gkhy.safePlatform.account.rpc.apimodel.AccountAuthService; -import com.gkhy.safePlatform.commons.co.CacheAuthority; -import com.gkhy.safePlatform.commons.co.CacheUser; +import com.gkhy.safePlatform.commons.co.ContextCacheAuthority; +import com.gkhy.safePlatform.commons.co.ContextCacheUser; import com.gkhy.safePlatform.commons.enums.RedisKeyEnum; import com.gkhy.safePlatform.commons.enums.ResultCodes; import com.gkhy.safePlatform.commons.exception.BusinessException; @@ -86,9 +86,9 @@ throw new BusinessException(ResultCodes.CLIENT_CREDENTIALS_TOKEN_INVALID); }else{ Long userId = Long.valueOf(loginUserId); - CacheUser cacheUser = JSONObject.parseObject(o.toString(), CacheUser.class); - assert userId.equals(cacheUser.getUserId()); - if ( !authToken.equals(cacheUser.getAccessToken())) { + ContextCacheUser contextCacheUser = JSONObject.parseObject(o.toString(), ContextCacheUser.class); + assert userId.equals(contextCacheUser.getUid()); + if ( !authToken.equals(contextCacheUser.getAccessToken())) { throw new BusinessException(ResultCodes.CLIENT_CREDENTIALS_TOKEN_INVALID); } @@ -99,8 +99,8 @@ // 4.redis中是否存在 if (oo != null) { // 5.存在 - List<CacheAuthority> cacheAuthorities = JSONArray.parseArray(oo.toString(), CacheAuthority.class); - for (CacheAuthority cacheAuthority: cacheAuthorities) { + List<ContextCacheAuthority> cacheAuthorities = JSONArray.parseArray(oo.toString(), ContextCacheAuthority.class); + for (ContextCacheAuthority cacheAuthority: cacheAuthorities) { authorities.add(new SimpleGrantedAuthority(cacheAuthority.getAuthority())); } }else { @@ -146,7 +146,7 @@ } // security对象中存入登陆者信息 - return new UsernamePasswordAuthenticationToken(userId,authToken,authorities); + return new UsernamePasswordAuthenticationToken(contextCacheUser,authToken,authorities); } -- Gitblit v1.9.2