From b7924b9ca8f8162e9aeb13fde750353663a3fba3 Mon Sep 17 00:00:00 2001 From: EightMonth Date: Fri, 11 Oct 2024 14:59:11 +0800 Subject: [PATCH] =?UTF-8?q?Revert=20"=E4=BF=AE=E5=A4=8Dredis=E5=BA=8F?= =?UTF-8?q?=E5=88=97=E5=8C=96=E8=AE=A4=E8=AF=81=E4=BF=A1=E6=81=AF=E9=97=AE?= =?UTF-8?q?=E9=A2=98"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 4aa88189ed899ca4003e39de879e7599c62eda76. --- .../JeecgRedisOAuth2AuthorizationService.java | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/jeecg-boot/jeecg-boot-base-core/src/main/java/org/jeecg/config/security/JeecgRedisOAuth2AuthorizationService.java b/jeecg-boot/jeecg-boot-base-core/src/main/java/org/jeecg/config/security/JeecgRedisOAuth2AuthorizationService.java index 960a20e1..d46ab3ce 100644 --- a/jeecg-boot/jeecg-boot-base-core/src/main/java/org/jeecg/config/security/JeecgRedisOAuth2AuthorizationService.java +++ b/jeecg-boot/jeecg-boot-base-core/src/main/java/org/jeecg/config/security/JeecgRedisOAuth2AuthorizationService.java @@ -43,11 +43,9 @@ public class JeecgRedisOAuth2AuthorizationService implements OAuth2Authorization if (isState(authorization)) { String token = authorization.getAttribute("state"); - RedisSerializer redisSerializer = redisTemplate.getValueSerializer(); redisTemplate.setValueSerializer(RedisSerializer.java()); redisTemplate.opsForValue().set(buildKey(OAuth2ParameterNames.STATE, token), authorization, TIMEOUT, TimeUnit.MINUTES); - redisTemplate.setValueSerializer(redisSerializer); } if (isCode(authorization)) { @@ -56,27 +54,22 @@ public class JeecgRedisOAuth2AuthorizationService implements OAuth2Authorization OAuth2AuthorizationCode authorizationCodeToken = authorizationCode.getToken(); long between = ChronoUnit.MINUTES.between(authorizationCodeToken.getIssuedAt(), authorizationCodeToken.getExpiresAt()); - RedisSerializer redisSerializer = redisTemplate.getValueSerializer(); redisTemplate.setValueSerializer(RedisSerializer.java()); redisTemplate.opsForValue().set(buildKey(OAuth2ParameterNames.CODE, authorizationCodeToken.getTokenValue()), authorization, between, TimeUnit.MINUTES); - redisTemplate.setValueSerializer(redisSerializer); } if (isRefreshToken(authorization)) { OAuth2RefreshToken refreshToken = authorization.getRefreshToken().getToken(); long between = ChronoUnit.SECONDS.between(refreshToken.getIssuedAt(), refreshToken.getExpiresAt()); - RedisSerializer redisSerializer = redisTemplate.getValueSerializer(); redisTemplate.setValueSerializer(RedisSerializer.java()); redisTemplate.opsForValue().set(buildKey(OAuth2ParameterNames.REFRESH_TOKEN, refreshToken.getTokenValue()), authorization, between, TimeUnit.SECONDS); - redisTemplate.setValueSerializer(redisSerializer); } if (isAccessToken(authorization)) { OAuth2AccessToken accessToken = authorization.getAccessToken().getToken(); long between = ChronoUnit.SECONDS.between(accessToken.getIssuedAt(), accessToken.getExpiresAt()); - RedisSerializer redisSerializer = redisTemplate.getValueSerializer(); redisTemplate.setValueSerializer(RedisSerializer.java()); redisTemplate.opsForValue().set(buildKey(OAuth2ParameterNames.ACCESS_TOKEN, accessToken.getTokenValue()), authorization, between, TimeUnit.SECONDS); @@ -84,7 +77,6 @@ public class JeecgRedisOAuth2AuthorizationService implements OAuth2Authorization // 扩展记录 access-token 、username 的关系 1::token::username::admin::xxx String tokenUsername = String.format("%s::%s::%s", AUTHORIZATION, authorization.getPrincipalName(), accessToken.getTokenValue()); redisTemplate.opsForValue().set(tokenUsername, accessToken.getTokenValue(), between, TimeUnit.SECONDS); - redisTemplate.setValueSerializer(redisSerializer); } } @@ -133,11 +125,8 @@ public class JeecgRedisOAuth2AuthorizationService implements OAuth2Authorization public OAuth2Authorization findByToken(String token, @Nullable OAuth2TokenType tokenType) { Assert.hasText(token, "token cannot be empty"); Assert.notNull(tokenType, "tokenType cannot be empty"); - RedisSerializer redisSerializer = redisTemplate.getValueSerializer(); redisTemplate.setValueSerializer(RedisSerializer.java()); - OAuth2Authorization oAuth2Authorization = (OAuth2Authorization) redisTemplate.opsForValue().get(buildKey(tokenType.getValue(), token)); - redisTemplate.setValueSerializer(redisSerializer); - return oAuth2Authorization; + return (OAuth2Authorization) redisTemplate.opsForValue().get(buildKey(tokenType.getValue(), token)); } private String buildKey(String type, String id) {