forked from kookmin-sw/cap-template
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor kookmin-sw#2 - package constructor
시큐리티 패키지 내의 파일구조를 좀 더 세분화하여 패키징 하였습니다.
- Loading branch information
1 parent
2836108
commit ff8c17b
Showing
5 changed files
with
51 additions
and
1 deletion.
There are no files selected for viewing
File renamed without changes.
File renamed without changes.
50 changes: 50 additions & 0 deletions
50
src/main/java/org/capstone/maru/security/response/NaverOAuth2Response.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.