class name refectoring

dev
Lim Jonguk 3 years ago
parent ddfbd4f5fc
commit 2fa68151d0

@ -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<? extends GrantedAuthority> authorities = ((OidcUser) authentication.getPrincipal()).getAuthorities();
RoleType roleType = hasAuthority(authorities, RoleType.ADMIN.getCode()) ? RoleType.ADMIN : RoleType.USER;

@ -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<String, Object> attributes;
public OAuth2UserInfo(Map<String, Object> attributes) {
public AbstractOAuth2UserInfo(Map<String, Object> attributes) {
this.attributes = attributes;
}

@ -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<String, Object> attributes) {
public static AbstractOAuth2UserInfo getOAuth2UserInfo(ProviderType providerType, Map<String, Object> attributes) {
switch (providerType) {
case GOOGLE: return new GoogleOAuth2UserInfo(attributes);
case FACEBOOK: return new FacebookOAuth2UserInfo(attributes);

@ -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<String, Object> attributes) {
super(attributes);
}

@ -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<String, Object> attributes) {
super(attributes);

@ -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<String, Object> attributes) {
super(attributes);

@ -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<String, Object> attributes) {
super(attributes);

@ -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<CmmUser> 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());
}

Loading…
Cancel
Save