
File name
Commit message
Commit date
File name
Commit message
Commit date
File name
Commit message
Commit date
File name
Commit message
Commit date
File name
Commit message
Commit date
File name
Commit message
Commit date
package com.takensoft.common.oauth.vo;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import java.util.Map;
/**
* @author takensoft
* @since 2025.05.22
* @modification
* since | author | description
* 2025.05.22 | takensoft | 최초 등록
*
* OAuth2 사용자 정보 통합 VO
*/
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
public class OAuth2UserInfoVO {
private Map<String, Object> attributes; // OAuth2 응답 전체 데이터
private String provider; // 제공업체 (kakao, naver, google 등)
private String id; // 사용자 ID
private String name; // 사용자 이름
private String email; // 이메일
private String imageUrl; // 프로필 이미지 URL
// 제공업체별 데이터를 통일된 형태로 변환하는 생성자
public OAuth2UserInfoVO(String provider, Map<String, Object> attributes) {
this.provider = provider;
this.attributes = attributes;
switch (provider.toLowerCase()) {
case "kakao":
setKakaoUserInfo(attributes);
break;
case "naver":
setNaverUserInfo(attributes);
break;
case "google":
setGoogleUserInfo(attributes);
break;
}
}
private void setKakaoUserInfo(Map<String, Object> attributes) {
Map<String, Object> kakaoAccount = (Map<String, Object>) attributes.get("kakao_account");
Map<String, Object> profile = (Map<String, Object>) kakaoAccount.get("profile");
this.id = String.valueOf(attributes.get("id"));
this.name = (String) profile.get("nickname");
this.email = (String) kakaoAccount.get("email");
this.imageUrl = (String) profile.get("profile_image_url");
}
private void setNaverUserInfo(Map<String, Object> attributes) {
Map<String, Object> response = (Map<String, Object>) attributes.get("response");
this.id = (String) response.get("id");
this.name = (String) response.get("name");
this.email = (String) response.get("email");
this.imageUrl = (String) response.get("profile_image");
}
private void setGoogleUserInfo(Map<String, Object> attributes) {
this.id = (String) attributes.get("sub");
this.name = (String) attributes.get("name");
this.email = (String) attributes.get("email");
this.imageUrl = (String) attributes.get("picture");
}
}