Skip to content

Commit

Permalink
refactor kookmin-sw#2 - package constructor
Browse files Browse the repository at this point in the history
시큐리티 패키지 내의 파일구조를 좀 더 세분화하여 패키징 하였습니다.
  • Loading branch information
cheesecrust committed Mar 10, 2024
1 parent 2836108 commit ff8c17b
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -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<String, Object> 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<String, Object> attributes) {
return new NaverOAuth2Response(
Response.from((Map<String, Object>) attributes.get("response")));
}

@Override
public String id() {
return response.id();
}

@Override
public String email() {
return response.email();
}

@Override
public String nickname() {
return response.name();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ private static OAuth2Response ofKakao(Map<String, Object> attributes) {
}

public static OAuth2Response ofNaver(Map<String, Object> attributes) {
return null;
return NaverOAuth2Response.from(attributes);
}

public abstract String id();
Expand Down

0 comments on commit ff8c17b

Please sign in to comment.