| | |
| | | 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; |
| | |
| | | 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); |
| | | } |
| | | |
| | |
| | | // 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 { |
| | |
| | | } |
| | | |
| | | // security对象中存入登陆者信息 |
| | | return new UsernamePasswordAuthenticationToken(userId,authToken,authorities); |
| | | return new UsernamePasswordAuthenticationToken(contextCacheUser,authToken,authorities); |
| | | |
| | | } |
| | | |