From 2fa68151d05132b9ed821ccac4ce5d15319847b1 Mon Sep 17 00:00:00 2001 From: Lim Jonguk Date: Sun, 9 Jan 2022 02:20:54 +0900 Subject: [PATCH] class name refectoring --- .../oauth/handler/OAuth2AuthenticationSuccessHandler.java | 4 ++-- .../{OAuth2UserInfo.java => AbstractOAuth2UserInfo.java} | 4 ++-- .../xit/core/oauth2/oauth/info/OAuth2UserInfoFactory.java | 2 +- .../oauth2/oauth/info/impl/FacebookOAuth2UserInfo.java | 4 ++-- .../core/oauth2/oauth/info/impl/GoogleOAuth2UserInfo.java | 4 ++-- .../core/oauth2/oauth/info/impl/KakaoOAuth2UserInfo.java | 4 ++-- .../core/oauth2/oauth/info/impl/NaverOAuth2UserInfo.java | 4 ++-- .../oauth2/oauth/service/CustomOAuth2UserService.java | 8 ++++---- 8 files changed, 17 insertions(+), 17 deletions(-) rename src/main/java/com/xit/core/oauth2/oauth/info/{OAuth2UserInfo.java => AbstractOAuth2UserInfo.java} (77%) diff --git a/src/main/java/com/xit/core/oauth2/oauth/handler/OAuth2AuthenticationSuccessHandler.java b/src/main/java/com/xit/core/oauth2/oauth/handler/OAuth2AuthenticationSuccessHandler.java index 99a1035..26bb46a 100644 --- a/src/main/java/com/xit/core/oauth2/oauth/handler/OAuth2AuthenticationSuccessHandler.java +++ b/src/main/java/com/xit/core/oauth2/oauth/handler/OAuth2AuthenticationSuccessHandler.java @@ -6,7 +6,7 @@ import com.xit.core.constant.XitConstants; import com.xit.core.oauth2.config.properties.AppProperties; import com.xit.core.oauth2.oauth.entity.ProviderType; import com.xit.core.oauth2.oauth.entity.RoleType; -import com.xit.core.oauth2.oauth.info.OAuth2UserInfo; +import com.xit.core.oauth2.oauth.info.AbstractOAuth2UserInfo; import com.xit.core.oauth2.oauth.info.OAuth2UserInfoFactory; import com.xit.core.oauth2.oauth.repository.OAuth2AuthorizationRequestBasedOnCookieRepository; import com.xit.core.oauth2.oauth.JwtTokenProvider; @@ -67,7 +67,7 @@ public class OAuth2AuthenticationSuccessHandler extends SimpleUrlAuthenticationS ProviderType providerType = ProviderType.valueOf(authToken.getAuthorizedClientRegistrationId().toUpperCase()); OidcUser user = ((OidcUser) authentication.getPrincipal()); - OAuth2UserInfo userInfo = OAuth2UserInfoFactory.getOAuth2UserInfo(providerType, user.getAttributes()); + AbstractOAuth2UserInfo userInfo = OAuth2UserInfoFactory.getOAuth2UserInfo(providerType, user.getAttributes()); Collection authorities = ((OidcUser) authentication.getPrincipal()).getAuthorities(); RoleType roleType = hasAuthority(authorities, RoleType.ADMIN.getCode()) ? RoleType.ADMIN : RoleType.USER; diff --git a/src/main/java/com/xit/core/oauth2/oauth/info/OAuth2UserInfo.java b/src/main/java/com/xit/core/oauth2/oauth/info/AbstractOAuth2UserInfo.java similarity index 77% rename from src/main/java/com/xit/core/oauth2/oauth/info/OAuth2UserInfo.java rename to src/main/java/com/xit/core/oauth2/oauth/info/AbstractOAuth2UserInfo.java index 1ac0d39..299f886 100644 --- a/src/main/java/com/xit/core/oauth2/oauth/info/OAuth2UserInfo.java +++ b/src/main/java/com/xit/core/oauth2/oauth/info/AbstractOAuth2UserInfo.java @@ -2,10 +2,10 @@ package com.xit.core.oauth2.oauth.info; import java.util.Map; -public abstract class OAuth2UserInfo { +public abstract class AbstractOAuth2UserInfo { protected Map attributes; - public OAuth2UserInfo(Map attributes) { + public AbstractOAuth2UserInfo(Map attributes) { this.attributes = attributes; } diff --git a/src/main/java/com/xit/core/oauth2/oauth/info/OAuth2UserInfoFactory.java b/src/main/java/com/xit/core/oauth2/oauth/info/OAuth2UserInfoFactory.java index 772e03b..43c627b 100644 --- a/src/main/java/com/xit/core/oauth2/oauth/info/OAuth2UserInfoFactory.java +++ b/src/main/java/com/xit/core/oauth2/oauth/info/OAuth2UserInfoFactory.java @@ -9,7 +9,7 @@ import com.xit.core.oauth2.oauth.info.impl.NaverOAuth2UserInfo; import java.util.Map; public class OAuth2UserInfoFactory { - public static OAuth2UserInfo getOAuth2UserInfo(ProviderType providerType, Map attributes) { + public static AbstractOAuth2UserInfo getOAuth2UserInfo(ProviderType providerType, Map attributes) { switch (providerType) { case GOOGLE: return new GoogleOAuth2UserInfo(attributes); case FACEBOOK: return new FacebookOAuth2UserInfo(attributes); diff --git a/src/main/java/com/xit/core/oauth2/oauth/info/impl/FacebookOAuth2UserInfo.java b/src/main/java/com/xit/core/oauth2/oauth/info/impl/FacebookOAuth2UserInfo.java index 19a5237..593c5be 100644 --- a/src/main/java/com/xit/core/oauth2/oauth/info/impl/FacebookOAuth2UserInfo.java +++ b/src/main/java/com/xit/core/oauth2/oauth/info/impl/FacebookOAuth2UserInfo.java @@ -1,10 +1,10 @@ package com.xit.core.oauth2.oauth.info.impl; -import com.xit.core.oauth2.oauth.info.OAuth2UserInfo; +import com.xit.core.oauth2.oauth.info.AbstractOAuth2UserInfo; import java.util.Map; -public class FacebookOAuth2UserInfo extends OAuth2UserInfo { +public class FacebookOAuth2UserInfo extends AbstractOAuth2UserInfo { public FacebookOAuth2UserInfo(Map attributes) { super(attributes); } diff --git a/src/main/java/com/xit/core/oauth2/oauth/info/impl/GoogleOAuth2UserInfo.java b/src/main/java/com/xit/core/oauth2/oauth/info/impl/GoogleOAuth2UserInfo.java index f0849d4..62943a7 100644 --- a/src/main/java/com/xit/core/oauth2/oauth/info/impl/GoogleOAuth2UserInfo.java +++ b/src/main/java/com/xit/core/oauth2/oauth/info/impl/GoogleOAuth2UserInfo.java @@ -1,10 +1,10 @@ package com.xit.core.oauth2.oauth.info.impl; -import com.xit.core.oauth2.oauth.info.OAuth2UserInfo; +import com.xit.core.oauth2.oauth.info.AbstractOAuth2UserInfo; import java.util.Map; -public class GoogleOAuth2UserInfo extends OAuth2UserInfo { +public class GoogleOAuth2UserInfo extends AbstractOAuth2UserInfo { public GoogleOAuth2UserInfo(Map attributes) { super(attributes); diff --git a/src/main/java/com/xit/core/oauth2/oauth/info/impl/KakaoOAuth2UserInfo.java b/src/main/java/com/xit/core/oauth2/oauth/info/impl/KakaoOAuth2UserInfo.java index 590808e..756262a 100644 --- a/src/main/java/com/xit/core/oauth2/oauth/info/impl/KakaoOAuth2UserInfo.java +++ b/src/main/java/com/xit/core/oauth2/oauth/info/impl/KakaoOAuth2UserInfo.java @@ -1,10 +1,10 @@ package com.xit.core.oauth2.oauth.info.impl; -import com.xit.core.oauth2.oauth.info.OAuth2UserInfo; +import com.xit.core.oauth2.oauth.info.AbstractOAuth2UserInfo; import java.util.Map; -public class KakaoOAuth2UserInfo extends OAuth2UserInfo { +public class KakaoOAuth2UserInfo extends AbstractOAuth2UserInfo { public KakaoOAuth2UserInfo(Map attributes) { super(attributes); diff --git a/src/main/java/com/xit/core/oauth2/oauth/info/impl/NaverOAuth2UserInfo.java b/src/main/java/com/xit/core/oauth2/oauth/info/impl/NaverOAuth2UserInfo.java index e929fd0..354ca8d 100644 --- a/src/main/java/com/xit/core/oauth2/oauth/info/impl/NaverOAuth2UserInfo.java +++ b/src/main/java/com/xit/core/oauth2/oauth/info/impl/NaverOAuth2UserInfo.java @@ -1,10 +1,10 @@ package com.xit.core.oauth2.oauth.info.impl; -import com.xit.core.oauth2.oauth.info.OAuth2UserInfo; +import com.xit.core.oauth2.oauth.info.AbstractOAuth2UserInfo; import java.util.Map; -public class NaverOAuth2UserInfo extends OAuth2UserInfo { +public class NaverOAuth2UserInfo extends AbstractOAuth2UserInfo { public NaverOAuth2UserInfo(Map attributes) { super(attributes); diff --git a/src/main/java/com/xit/core/oauth2/oauth/service/CustomOAuth2UserService.java b/src/main/java/com/xit/core/oauth2/oauth/service/CustomOAuth2UserService.java index 048d8ef..b2b0801 100644 --- a/src/main/java/com/xit/core/oauth2/oauth/service/CustomOAuth2UserService.java +++ b/src/main/java/com/xit/core/oauth2/oauth/service/CustomOAuth2UserService.java @@ -6,7 +6,7 @@ import com.xit.core.oauth2.oauth.entity.ProviderType; import com.xit.core.oauth2.oauth.entity.RoleType; import com.xit.core.oauth2.oauth.entity.UserPrincipal; import com.xit.core.oauth2.oauth.exception.OAuthProviderMissMatchException; -import com.xit.core.oauth2.oauth.info.OAuth2UserInfo; +import com.xit.core.oauth2.oauth.info.AbstractOAuth2UserInfo; import com.xit.core.oauth2.oauth.info.OAuth2UserInfoFactory; import lombok.RequiredArgsConstructor; import org.springframework.security.authentication.InternalAuthenticationServiceException; @@ -46,7 +46,7 @@ public class CustomOAuth2UserService extends DefaultOAuth2UserService { // TODO :: 적용 여부 파악 필요 ProviderType providerType = ProviderType.valueOf(userRequest.getClientRegistration().getRegistrationId().toUpperCase()); - OAuth2UserInfo userInfo = OAuth2UserInfoFactory.getOAuth2UserInfo(providerType, user.getAttributes()); + AbstractOAuth2UserInfo userInfo = OAuth2UserInfoFactory.getOAuth2UserInfo(providerType, user.getAttributes()); CmmUser savedUser = null; Optional optionalCmmUser = userRepository.findByUserId(userInfo.getId()); @@ -79,7 +79,7 @@ public class CustomOAuth2UserService extends DefaultOAuth2UserService { return UserPrincipal.create(savedUser, user.getAttributes()); } - private CmmUser createUser(OAuth2UserInfo userInfo, ProviderType providerType) { + private CmmUser createUser(AbstractOAuth2UserInfo userInfo, ProviderType providerType) { CmmUser user = new CmmUser( userInfo.getId(), userInfo.getName(), @@ -99,7 +99,7 @@ public class CustomOAuth2UserService extends DefaultOAuth2UserService { return userRepository.saveAndFlush(user); } - private void updateUser(CmmUser user, OAuth2UserInfo userInfo) { + private void updateUser(CmmUser user, AbstractOAuth2UserInfo userInfo) { if (Objects.nonNull(userInfo.getName()) && !Objects.equals(userInfo.getName(), user.getUserName())) { user.setUserName(userInfo.getName()); }