Package com.alpaca.model
Class UserPrincipal
java.lang.Object
com.alpaca.model.UserPrincipal
- All Implemented Interfaces:
Serializable,org.springframework.security.core.AuthenticatedPrincipal,org.springframework.security.core.userdetails.UserDetails,org.springframework.security.oauth2.core.OAuth2AuthenticatedPrincipal,org.springframework.security.oauth2.core.user.OAuth2User
public class UserPrincipal
extends Object
implements org.springframework.security.oauth2.core.user.OAuth2User, org.springframework.security.core.userdetails.UserDetails
Represents the Principal User Details in the security context. This class implements both
OAuth2User and UserDetails to support authentication via OAuth2 and traditional login
mechanisms.- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate booleanIndicates whether the User's entity is not expired.private booleanIndicates whether the User's entity is not locked.private UUIDUnique identifier for the associated advertiser account, if available.Additional attributes provided by an OAuth2 authentication provider.private Collection<? extends org.springframework.security.core.GrantedAuthority> The authorities granted to the user for authorization purposes.private booleanIndicates whether the User's credentials are not expired.private booleanIndicates whether the User's entity is enabled.private UUIDUnique identifier for the user.private StringThe encrypted password of the user.private UUIDUnique identifier for the associated profile, if available.private StringThe username of the user, typically the email address. -
Constructor Summary
ConstructorsConstructorDescriptionUserPrincipal(User user, Map<String, Object> attributes) Constructs a newUserPrincipalinstance using aUserentity.UserPrincipal(UUID userId, UUID profileId, UUID advertiserId, String username, String password, Collection<? extends org.springframework.security.core.GrantedAuthority> authoritiesList, Map<String, Object> attributes) Constructs a newUserPrincipalinstance using a decoded JWT token values. -
Method Summary
Methods inherited from class java.lang.Object
clone, getClass, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.springframework.security.oauth2.core.OAuth2AuthenticatedPrincipal
getAttribute, getAuthoritiesMethods inherited from interface org.springframework.security.core.userdetails.UserDetails
getAuthorities, getPassword, getUsername
-
Field Details
-
id
Unique identifier for the user. -
profileId
Unique identifier for the associated profile, if available. -
advertiserId
Unique identifier for the associated advertiser account, if available. -
username
The username of the user, typically the email address. -
password
The encrypted password of the user. -
enabled
private boolean enabledIndicates whether the User's entity is enabled. Defaults totrue. -
accountNoExpired
private boolean accountNoExpiredIndicates whether the User's entity is not expired. Defaults totrue. -
accountNoLocked
private boolean accountNoLockedIndicates whether the User's entity is not locked. Defaults totrue. -
credentialNoExpired
private boolean credentialNoExpiredIndicates whether the User's credentials are not expired. Defaults totrue. -
authorities
The authorities granted to the user for authorization purposes. -
attributes
Additional attributes provided by an OAuth2 authentication provider.
-
-
Constructor Details
-
UserPrincipal
Constructs a newUserPrincipalinstance using aUserentity. This constructor extracts relevant information from theUserobject and assigns it to the corresponding fields inUserPrincipal.- Parameters:
user- theUserentity containing user details.attributes- additional attributes obtained from an OAuth2 authentication provider.
-
UserPrincipal
public UserPrincipal(UUID userId, UUID profileId, UUID advertiserId, String username, String password, Collection<? extends org.springframework.security.core.GrantedAuthority> authoritiesList, Map<String, Object> attributes) Constructs a newUserPrincipalinstance using a decoded JWT token values. This constructor extracts relevant information from theUserobject and assigns it to the corresponding fields inUserPrincipal.- Parameters:
userId- theUUIDid of the User.profileId- theUUIDid of the Profile.advertiserId- theUUIDid of the Advertiser.username- the username of the User.password- the encoded password of the User.authoritiesList- the list of authorities of the User.attributes- additional attributes obtained from an OAuth2 authentication provider.
-
-
Method Details
-
getAttributes
Retrieves the attributes associated with the user from an OAuth2 provider.- Specified by:
getAttributesin interfaceorg.springframework.security.oauth2.core.OAuth2AuthenticatedPrincipal- Returns:
- a map of user attributes.
-
getName
Retrieves the name of the user.- Specified by:
getNamein interfaceorg.springframework.security.core.AuthenticatedPrincipal- Returns:
- the username of the user.
-
isAccountNonExpired
public boolean isAccountNonExpired()- Specified by:
isAccountNonExpiredin interfaceorg.springframework.security.core.userdetails.UserDetails
-
isAccountNonLocked
public boolean isAccountNonLocked()- Specified by:
isAccountNonLockedin interfaceorg.springframework.security.core.userdetails.UserDetails
-
isCredentialsNonExpired
public boolean isCredentialsNonExpired()- Specified by:
isCredentialsNonExpiredin interfaceorg.springframework.security.core.userdetails.UserDetails
-
isEnabled
public boolean isEnabled()- Specified by:
isEnabledin interfaceorg.springframework.security.core.userdetails.UserDetails
-
hashCode
public int hashCode() -
equals
-