Record Class UserInfo
java.lang.Object
java.lang.Record
cloud.opencode.base.oauth2.oidc.UserInfo
public record UserInfo(String sub, String name, String givenName, String familyName, String middleName, String nickname, String preferredUsername, String profile, String picture, String website, String email, Boolean emailVerified, String gender, String birthdate, String zoneinfo, String locale, String phoneNumber, Boolean phoneNumberVerified, Map<String,Object> claims)
extends Record
OpenID Connect User Info
OpenID Connect 用户信息
Represents user information from the OIDC userinfo endpoint.
表示来自 OIDC userinfo 端点的用户信息。
Standard Claims | 标准声明:
- sub - Subject identifier - 主题标识符
- name - Full name - 全名
- email - Email address - 电子邮件地址
- picture - Profile picture URL - 头像 URL
- And more... - 更多...
Usage Examples | 使用示例:
UserInfo userInfo = client.getUserInfo(token);
String userId = userInfo.sub();
String email = userInfo.email();
String name = userInfo.name();
// Get custom claim
Optional<String> locale = userInfo.getClaim("locale");
Features | 主要功能:
- OIDC UserInfo endpoint response representation - OIDC用户信息端点响应表示
- Standard profile, email, address claims - 标准配置文件、电子邮件、地址声明
Security | 安全性:
- Thread-safe: Yes (immutable record) - 线程安全: 是(不可变记录)
- Null-safe: Yes (validates inputs) - 空值安全: 是(验证输入)
- Since:
- JDK 25, opencode-base-oauth2 V1.0.0
- Author:
- Leon Soo www.LeonSoo.com
- See Also:
-
Nested Class Summary
Nested Classes -
Constructor Summary
ConstructorsConstructorDescriptionUserInfo(String sub, String name, String givenName, String familyName, String middleName, String nickname, String preferredUsername, String profile, String picture, String website, String email, Boolean emailVerified, String gender, String birthdate, String zoneinfo, String locale, String phoneNumber, Boolean phoneNumberVerified, Map<String, Object> claims) Compact constructor 紧凑构造器 -
Method Summary
Modifier and TypeMethodDescriptionReturns the value of thebirthdaterecord component.static UserInfo.Builderbuilder()Create a new builder 创建新的构建器claims()Returns the value of theclaimsrecord component.Get display name (name or preferredUsername or email) 获取显示名称(姓名或首选用户名或电子邮件)email()Returns the value of theemailrecord component.Returns the value of theemailVerifiedrecord component.final booleanIndicates whether some other object is "equal to" this one.Returns the value of thefamilyNamerecord component.static UserInfoParse user info from JSON response 从 JSON 响应解析用户信息gender()Returns the value of thegenderrecord component.Get a custom claim value 获取自定义声明值getClaimAsString(String name) Get a custom claim value as string 获取自定义声明值作为字符串Returns the value of thegivenNamerecord component.final inthashCode()Returns a hash code value for this object.booleanCheck if email is verified 检查电子邮件是否已验证booleanCheck if phone number is verified 检查电话号码是否已验证locale()Returns the value of thelocalerecord component.Returns the value of themiddleNamerecord component.name()Returns the value of thenamerecord component.nickname()Returns the value of thenicknamerecord component.Returns the value of thephoneNumberrecord component.Returns the value of thephoneNumberVerifiedrecord component.picture()Returns the value of thepicturerecord component.Returns the value of thepreferredUsernamerecord component.profile()Returns the value of theprofilerecord component.sub()Returns the value of thesubrecord component.final StringtoString()Returns a string representation of this record class.website()Returns the value of thewebsiterecord component.zoneinfo()Returns the value of thezoneinforecord component.
-
Constructor Details
-
UserInfo
public UserInfo(String sub, String name, String givenName, String familyName, String middleName, String nickname, String preferredUsername, String profile, String picture, String website, String email, Boolean emailVerified, String gender, String birthdate, String zoneinfo, String locale, String phoneNumber, Boolean phoneNumberVerified, Map<String, Object> claims) Compact constructor 紧凑构造器
-
-
Method Details
-
getClaim
-
getClaimAsString
-
isEmailVerified
public boolean isEmailVerified()Check if email is verified 检查电子邮件是否已验证- Returns:
- true if email is verified | 如果电子邮件已验证返回 true
-
isPhoneNumberVerified
public boolean isPhoneNumberVerified()Check if phone number is verified 检查电话号码是否已验证- Returns:
- true if phone number is verified | 如果电话号码已验证返回 true
-
displayName
Get display name (name or preferredUsername or email) 获取显示名称(姓名或首选用户名或电子邮件)- Returns:
- the display name | 显示名称
-
builder
-
fromJson
-
toString
-
hashCode
-
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared withObjects::equals(Object,Object). -
sub
Returns the value of thesubrecord component.- Returns:
- the value of the
subrecord component
-
name
Returns the value of thenamerecord component.- Returns:
- the value of the
namerecord component
-
givenName
Returns the value of thegivenNamerecord component.- Returns:
- the value of the
givenNamerecord component
-
familyName
Returns the value of thefamilyNamerecord component.- Returns:
- the value of the
familyNamerecord component
-
middleName
Returns the value of themiddleNamerecord component.- Returns:
- the value of the
middleNamerecord component
-
nickname
Returns the value of thenicknamerecord component.- Returns:
- the value of the
nicknamerecord component
-
preferredUsername
Returns the value of thepreferredUsernamerecord component.- Returns:
- the value of the
preferredUsernamerecord component
-
profile
Returns the value of theprofilerecord component.- Returns:
- the value of the
profilerecord component
-
picture
Returns the value of thepicturerecord component.- Returns:
- the value of the
picturerecord component
-
website
Returns the value of thewebsiterecord component.- Returns:
- the value of the
websiterecord component
-
email
Returns the value of theemailrecord component.- Returns:
- the value of the
emailrecord component
-
emailVerified
Returns the value of theemailVerifiedrecord component.- Returns:
- the value of the
emailVerifiedrecord component
-
gender
Returns the value of thegenderrecord component.- Returns:
- the value of the
genderrecord component
-
birthdate
Returns the value of thebirthdaterecord component.- Returns:
- the value of the
birthdaterecord component
-
zoneinfo
Returns the value of thezoneinforecord component.- Returns:
- the value of the
zoneinforecord component
-
locale
Returns the value of thelocalerecord component.- Returns:
- the value of the
localerecord component
-
phoneNumber
Returns the value of thephoneNumberrecord component.- Returns:
- the value of the
phoneNumberrecord component
-
phoneNumberVerified
Returns the value of thephoneNumberVerifiedrecord component.- Returns:
- the value of the
phoneNumberVerifiedrecord component
-
claims
-