diff --git a/src/main/java/org/capstone/maru/security/SharedPostPrincipal.java b/src/main/java/org/capstone/maru/security/principal/SharedPostPrincipal.java similarity index 100% rename from src/main/java/org/capstone/maru/security/SharedPostPrincipal.java rename to src/main/java/org/capstone/maru/security/principal/SharedPostPrincipal.java diff --git a/src/main/java/org/capstone/maru/security/KakaoOAuth2Response.java b/src/main/java/org/capstone/maru/security/response/KakaoOAuth2Response.java similarity index 100% rename from src/main/java/org/capstone/maru/security/KakaoOAuth2Response.java rename to src/main/java/org/capstone/maru/security/response/KakaoOAuth2Response.java diff --git a/src/main/java/org/capstone/maru/security/response/NaverOAuth2Response.java b/src/main/java/org/capstone/maru/security/response/NaverOAuth2Response.java new file mode 100644 index 0000000000..b645401b3d --- /dev/null +++ b/src/main/java/org/capstone/maru/security/response/NaverOAuth2Response.java @@ -0,0 +1,50 @@ +package org.capstone.maru.security; + +import java.util.Map; +import lombok.Getter; + +@SuppressWarnings("unchecked") +@Getter +public class NaverOAuth2Response extends OAuth2Response { + + private final Response response; + + private record Response( + String id, + String email, + String name + ) { + + public static Response from(Map attributes) { + return new Response( + String.valueOf(attributes.get("id")), + String.valueOf(attributes.get("email")), + String.valueOf(attributes.get("name")) + ); + } + } + + private NaverOAuth2Response(Response response) { + this.response = response; + } + + public static NaverOAuth2Response from(Map attributes) { + return new NaverOAuth2Response( + Response.from((Map) attributes.get("response"))); + } + + @Override + public String id() { + return response.id(); + } + + @Override + public String email() { + return response.email(); + } + + @Override + public String nickname() { + return response.name(); + } +} \ No newline at end of file diff --git a/src/main/java/org/capstone/maru/security/OAuth2Response.java b/src/main/java/org/capstone/maru/security/response/OAuth2Response.java similarity index 96% rename from src/main/java/org/capstone/maru/security/OAuth2Response.java rename to src/main/java/org/capstone/maru/security/response/OAuth2Response.java index 907df47c10..88c1c49456 100644 --- a/src/main/java/org/capstone/maru/security/OAuth2Response.java +++ b/src/main/java/org/capstone/maru/security/response/OAuth2Response.java @@ -34,7 +34,7 @@ private static OAuth2Response ofKakao(Map attributes) { } public static OAuth2Response ofNaver(Map attributes) { - return null; + return NaverOAuth2Response.from(attributes); } public abstract String id(); diff --git a/src/main/java/org/capstone/maru/security/CustomOAuth2UserService.java b/src/main/java/org/capstone/maru/security/service/CustomOAuth2UserService.java similarity index 100% rename from src/main/java/org/capstone/maru/security/CustomOAuth2UserService.java rename to src/main/java/org/capstone/maru/security/service/CustomOAuth2UserService.java