From f7ff919f5ca84e299ab3feaad721cd31d5b0ffa8 Mon Sep 17 00:00:00 2001 From: zhouhao Date: Mon, 25 Dec 2017 10:17:24 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Doauth2=20token=20=E6=97=A0?= =?UTF-8?q?=E6=B3=95=E6=9B=B4=E6=96=B0=E7=BC=93=E5=AD=98=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../client/simple/SimpleOAuth2SessionBuilder.java | 8 ++++---- .../client/simple/SimpleOAuth2UserTokenService.java | 12 ++++++++++-- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/hsweb-authorization/hsweb-authorization-oauth2/hsweb-authorization-oauth2-client/src/main/java/org/hswebframework/web/authorization/oauth2/client/simple/SimpleOAuth2SessionBuilder.java b/hsweb-authorization/hsweb-authorization-oauth2/hsweb-authorization-oauth2-client/src/main/java/org/hswebframework/web/authorization/oauth2/client/simple/SimpleOAuth2SessionBuilder.java index d6abcb3eb..588ffdc1c 100644 --- a/hsweb-authorization/hsweb-authorization-oauth2/hsweb-authorization-oauth2-client/src/main/java/org/hswebframework/web/authorization/oauth2/client/simple/SimpleOAuth2SessionBuilder.java +++ b/hsweb-authorization/hsweb-authorization-oauth2/hsweb-authorization-oauth2-client/src/main/java/org/hswebframework/web/authorization/oauth2/client/simple/SimpleOAuth2SessionBuilder.java @@ -82,15 +82,15 @@ public class SimpleOAuth2SessionBuilder implements OAuth2SessionBuilder { readWriteLock.writeLock().lock(); AccessTokenInfo tokenInfo = tokenGetter.get(); try { + token.setGrantType(grantType); + token.setServerId(serverConfig.getId()); if (tokenInfo != null) { token.setId(tokenInfo.getId()); - tokenInfo.setUpdateTime(System.currentTimeMillis()); + token.setUpdateTime(System.currentTimeMillis()); oAuth2UserTokenRepository.update(tokenInfo.getId(), token); } else { - token.setGrantType(grantType); token.setCreateTime(System.currentTimeMillis()); token.setUpdateTime(System.currentTimeMillis()); - token.setServerId(serverConfig.getId()); oAuth2UserTokenRepository.insert(token); } } finally { @@ -112,7 +112,7 @@ public class SimpleOAuth2SessionBuilder implements OAuth2SessionBuilder { } - private Supplier tokenGetter = () -> { + private Supplier tokenGetter = () -> { readWriteLock.readLock().lock(); try { return getClientCredentialsToken(); diff --git a/hsweb-system/hsweb-system-oauth2-client/hsweb-system-oauth2-client-service/hsweb-system-oauth2-client-service-simple/src/main/java/org/hswebframework/web/service/oauth2/client/simple/SimpleOAuth2UserTokenService.java b/hsweb-system/hsweb-system-oauth2-client/hsweb-system-oauth2-client-service/hsweb-system-oauth2-client-service-simple/src/main/java/org/hswebframework/web/service/oauth2/client/simple/SimpleOAuth2UserTokenService.java index f9c388bbb..f2cb3a412 100644 --- a/hsweb-system/hsweb-system-oauth2-client/hsweb-system-oauth2-client-service/hsweb-system-oauth2-client-service-simple/src/main/java/org/hswebframework/web/service/oauth2/client/simple/SimpleOAuth2UserTokenService.java +++ b/hsweb-system/hsweb-system-oauth2-client/hsweb-system-oauth2-client-service/hsweb-system-oauth2-client-service-simple/src/main/java/org/hswebframework/web/service/oauth2/client/simple/SimpleOAuth2UserTokenService.java @@ -87,6 +87,9 @@ public class SimpleOAuth2UserTokenService extends GenericEntityService