|
|
|
@ -19,6 +19,8 @@ package org.springframework.security.oauth2.core.oidc; |
|
|
|
import java.time.Instant; |
|
|
|
import java.time.Instant; |
|
|
|
import java.util.Map; |
|
|
|
import java.util.Map; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import org.jspecify.annotations.Nullable; |
|
|
|
|
|
|
|
|
|
|
|
import org.springframework.security.oauth2.core.ClaimAccessor; |
|
|
|
import org.springframework.security.oauth2.core.ClaimAccessor; |
|
|
|
import org.springframework.util.CollectionUtils; |
|
|
|
import org.springframework.util.CollectionUtils; |
|
|
|
|
|
|
|
|
|
|
|
@ -41,152 +43,166 @@ import org.springframework.util.CollectionUtils; |
|
|
|
public interface StandardClaimAccessor extends ClaimAccessor { |
|
|
|
public interface StandardClaimAccessor extends ClaimAccessor { |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Returns the Subject identifier {@code (sub)}. |
|
|
|
* Returns the Subject identifier {@code (sub)}, or {@code null} if it does not exist. |
|
|
|
* @return the Subject identifier |
|
|
|
* @return the Subject identifier, or {@code null} if it does not exist |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
default String getSubject() { |
|
|
|
default @Nullable String getSubject() { |
|
|
|
return this.getClaimAsString(StandardClaimNames.SUB); |
|
|
|
return this.getClaimAsString(StandardClaimNames.SUB); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Returns the user's full name {@code (name)} in displayable form. |
|
|
|
* Returns the user's full name {@code (name)} in displayable form, or {@code null} if |
|
|
|
* @return the user's full name |
|
|
|
* it does not exist. |
|
|
|
|
|
|
|
* @return the user's full name, or {@code null} if it does not exist |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
default String getFullName() { |
|
|
|
default @Nullable String getFullName() { |
|
|
|
return this.getClaimAsString(StandardClaimNames.NAME); |
|
|
|
return this.getClaimAsString(StandardClaimNames.NAME); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Returns the user's given name(s) or first name(s) {@code (given_name)}. |
|
|
|
* Returns the user's given name(s) or first name(s) {@code (given_name)}, or |
|
|
|
* @return the user's given name(s) |
|
|
|
* {@code null} if it does not exist. |
|
|
|
|
|
|
|
* @return the user's given name(s), or {@code null} if it does not exist |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
default String getGivenName() { |
|
|
|
default @Nullable String getGivenName() { |
|
|
|
return this.getClaimAsString(StandardClaimNames.GIVEN_NAME); |
|
|
|
return this.getClaimAsString(StandardClaimNames.GIVEN_NAME); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Returns the user's surname(s) or last name(s) {@code (family_name)}. |
|
|
|
* Returns the user's surname(s) or last name(s) {@code (family_name)}, or |
|
|
|
* @return the user's family names(s) |
|
|
|
* {@code null} if it does not exist. |
|
|
|
|
|
|
|
* @return the user's family names(s), or {@code null} if it does not exist |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
default String getFamilyName() { |
|
|
|
default @Nullable String getFamilyName() { |
|
|
|
return this.getClaimAsString(StandardClaimNames.FAMILY_NAME); |
|
|
|
return this.getClaimAsString(StandardClaimNames.FAMILY_NAME); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Returns the user's middle name(s) {@code (middle_name)}. |
|
|
|
* Returns the user's middle name(s) {@code (middle_name)}, or {@code null} if it does |
|
|
|
* @return the user's middle name(s) |
|
|
|
* not exist. |
|
|
|
|
|
|
|
* @return the user's middle name(s), or {@code null} if it does not exist |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
default String getMiddleName() { |
|
|
|
default @Nullable String getMiddleName() { |
|
|
|
return this.getClaimAsString(StandardClaimNames.MIDDLE_NAME); |
|
|
|
return this.getClaimAsString(StandardClaimNames.MIDDLE_NAME); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Returns the user's nick name {@code (nickname)} that may or may not be the same as |
|
|
|
* Returns the user's nick name {@code (nickname)} that may or may not be the same as |
|
|
|
* the {@code (given_name)}. |
|
|
|
* the {@code (given_name)}, or {@code null} if it does not exist. |
|
|
|
* @return the user's nick name |
|
|
|
* @return the user's nick name, or {@code null} if it does not exist |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
default String getNickName() { |
|
|
|
default @Nullable String getNickName() { |
|
|
|
return this.getClaimAsString(StandardClaimNames.NICKNAME); |
|
|
|
return this.getClaimAsString(StandardClaimNames.NICKNAME); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Returns the preferred username {@code (preferred_username)} that the user wishes to |
|
|
|
* Returns the preferred username {@code (preferred_username)} that the user wishes to |
|
|
|
* be referred to. |
|
|
|
* be referred to, or {@code null} if it does not exist. |
|
|
|
* @return the user's preferred user name |
|
|
|
* @return the user's preferred user name, or {@code null} if it does not exist |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
default String getPreferredUsername() { |
|
|
|
default @Nullable String getPreferredUsername() { |
|
|
|
return this.getClaimAsString(StandardClaimNames.PREFERRED_USERNAME); |
|
|
|
return this.getClaimAsString(StandardClaimNames.PREFERRED_USERNAME); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Returns the URL of the user's profile page {@code (profile)}. |
|
|
|
* Returns the URL of the user's profile page {@code (profile)}, or {@code null} if it |
|
|
|
* @return the URL of the user's profile page |
|
|
|
* does not exist. |
|
|
|
|
|
|
|
* @return the URL of the user's profile page, or {@code null} if it does not exist |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
default String getProfile() { |
|
|
|
default @Nullable String getProfile() { |
|
|
|
return this.getClaimAsString(StandardClaimNames.PROFILE); |
|
|
|
return this.getClaimAsString(StandardClaimNames.PROFILE); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Returns the URL of the user's profile picture {@code (picture)}. |
|
|
|
* Returns the URL of the user's profile picture {@code (picture)}, or {@code null} if |
|
|
|
* @return the URL of the user's profile picture |
|
|
|
* it does not exist. |
|
|
|
|
|
|
|
* @return the URL of the user's profile picture, or {@code null} if it does not exist |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
default String getPicture() { |
|
|
|
default @Nullable String getPicture() { |
|
|
|
return this.getClaimAsString(StandardClaimNames.PICTURE); |
|
|
|
return this.getClaimAsString(StandardClaimNames.PICTURE); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Returns the URL of the user's web page or blog {@code (website)}. |
|
|
|
* Returns the URL of the user's web page or blog {@code (website)}, or {@code null} |
|
|
|
* @return the URL of the user's web page or blog |
|
|
|
* if it does not exist. |
|
|
|
|
|
|
|
* @return the URL of the user's web page or blog, or {@code null} if it does not |
|
|
|
|
|
|
|
* exist |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
default String getWebsite() { |
|
|
|
default @Nullable String getWebsite() { |
|
|
|
return this.getClaimAsString(StandardClaimNames.WEBSITE); |
|
|
|
return this.getClaimAsString(StandardClaimNames.WEBSITE); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Returns the user's preferred e-mail address {@code (email)}. |
|
|
|
* Returns the user's preferred e-mail address {@code (email)}, or {@code null} if it |
|
|
|
* @return the user's preferred e-mail address |
|
|
|
* does not exist. |
|
|
|
|
|
|
|
* @return the user's preferred e-mail address, or {@code null} if it does not exist |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
default String getEmail() { |
|
|
|
default @Nullable String getEmail() { |
|
|
|
return this.getClaimAsString(StandardClaimNames.EMAIL); |
|
|
|
return this.getClaimAsString(StandardClaimNames.EMAIL); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Returns {@code true} if the user's e-mail address has been verified |
|
|
|
* Returns {@code true} if the user's e-mail address has been verified |
|
|
|
* {@code (email_verified)}, otherwise {@code false}. |
|
|
|
* {@code (email_verified)}, otherwise {@code false}, or {@code null} if it does not |
|
|
|
|
|
|
|
* exist. |
|
|
|
* @return {@code true} if the user's e-mail address has been verified, otherwise |
|
|
|
* @return {@code true} if the user's e-mail address has been verified, otherwise |
|
|
|
* {@code false} |
|
|
|
* {@code false}, or {@code null} if it does not exist |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
default Boolean getEmailVerified() { |
|
|
|
default @Nullable Boolean getEmailVerified() { |
|
|
|
return this.getClaimAsBoolean(StandardClaimNames.EMAIL_VERIFIED); |
|
|
|
return this.getClaimAsBoolean(StandardClaimNames.EMAIL_VERIFIED); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Returns the user's gender {@code (gender)}. |
|
|
|
* Returns the user's gender {@code (gender)}, or {@code null} if it does not exist. |
|
|
|
* @return the user's gender |
|
|
|
* @return the user's gender, or {@code null} if it does not exist |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
default String getGender() { |
|
|
|
default @Nullable String getGender() { |
|
|
|
return this.getClaimAsString(StandardClaimNames.GENDER); |
|
|
|
return this.getClaimAsString(StandardClaimNames.GENDER); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Returns the user's birth date {@code (birthdate)}. |
|
|
|
* Returns the user's birth date {@code (birthdate)}, or {@code null} if it does not |
|
|
|
* @return the user's birth date |
|
|
|
* exist. |
|
|
|
|
|
|
|
* @return the user's birth date, or {@code null} if it does not exist |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
default String getBirthdate() { |
|
|
|
default @Nullable String getBirthdate() { |
|
|
|
return this.getClaimAsString(StandardClaimNames.BIRTHDATE); |
|
|
|
return this.getClaimAsString(StandardClaimNames.BIRTHDATE); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Returns the user's time zone {@code (zoneinfo)}. |
|
|
|
* Returns the user's time zone {@code (zoneinfo)}, or {@code null} if it does not |
|
|
|
* @return the user's time zone |
|
|
|
* exist. |
|
|
|
|
|
|
|
* @return the user's time zone, or {@code null} if it does not exist |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
default String getZoneInfo() { |
|
|
|
default @Nullable String getZoneInfo() { |
|
|
|
return this.getClaimAsString(StandardClaimNames.ZONEINFO); |
|
|
|
return this.getClaimAsString(StandardClaimNames.ZONEINFO); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Returns the user's locale {@code (locale)}. |
|
|
|
* Returns the user's locale {@code (locale)}, or {@code null} if it does not exist. |
|
|
|
* @return the user's locale |
|
|
|
* @return the user's locale, or {@code null} if it does not exist |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
default String getLocale() { |
|
|
|
default @Nullable String getLocale() { |
|
|
|
return this.getClaimAsString(StandardClaimNames.LOCALE); |
|
|
|
return this.getClaimAsString(StandardClaimNames.LOCALE); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Returns the user's preferred phone number {@code (phone_number)}. |
|
|
|
* Returns the user's preferred phone number {@code (phone_number)}, or {@code null} |
|
|
|
* @return the user's preferred phone number |
|
|
|
* if it does not exist. |
|
|
|
|
|
|
|
* @return the user's preferred phone number, or {@code null} if it does not exist |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
default String getPhoneNumber() { |
|
|
|
default @Nullable String getPhoneNumber() { |
|
|
|
return this.getClaimAsString(StandardClaimNames.PHONE_NUMBER); |
|
|
|
return this.getClaimAsString(StandardClaimNames.PHONE_NUMBER); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Returns {@code true} if the user's phone number has been verified |
|
|
|
* Returns {@code true} if the user's phone number has been verified |
|
|
|
* {@code (phone_number_verified)}, otherwise {@code false}. |
|
|
|
* {@code (phone_number_verified)}, otherwise {@code false}, or {@code null} if it |
|
|
|
|
|
|
|
* does not exist. |
|
|
|
* @return {@code true} if the user's phone number has been verified, otherwise |
|
|
|
* @return {@code true} if the user's phone number has been verified, otherwise |
|
|
|
* {@code false} |
|
|
|
* {@code false}, or {@code null} if it does not exist |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
default Boolean getPhoneNumberVerified() { |
|
|
|
default @Nullable Boolean getPhoneNumberVerified() { |
|
|
|
return this.getClaimAsBoolean(StandardClaimNames.PHONE_NUMBER_VERIFIED); |
|
|
|
return this.getClaimAsBoolean(StandardClaimNames.PHONE_NUMBER_VERIFIED); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -201,10 +217,12 @@ public interface StandardClaimAccessor extends ClaimAccessor { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Returns the time the user's information was last updated {@code (updated_at)}. |
|
|
|
* Returns the time the user's information was last updated {@code (updated_at)}, or |
|
|
|
* @return the time the user's information was last updated |
|
|
|
* {@code null} if it does not exist. |
|
|
|
|
|
|
|
* @return the time the user's information was last updated, or {@code null} if it |
|
|
|
|
|
|
|
* does not exist |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
default Instant getUpdatedAt() { |
|
|
|
default @Nullable Instant getUpdatedAt() { |
|
|
|
return this.getClaimAsInstant(StandardClaimNames.UPDATED_AT); |
|
|
|
return this.getClaimAsInstant(StandardClaimNames.UPDATED_AT); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|