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 boolean
Indicates whether the User's entity is not expired.private boolean
Indicates whether the User's entity is not locked.private UUID
Unique 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 boolean
Indicates whether the User's credentials are not expired.private boolean
Indicates whether the User's entity is enabled.private UUID
Unique identifier for the user.private String
The encrypted password of the user.private UUID
Unique identifier for the associated profile, if available.private String
The username of the user, typically the email address. -
Constructor Summary
ConstructorsConstructorDescriptionUserPrincipal
(User user, Map<String, Object> attributes) Constructs a newUserPrincipal
instance using aUser
entity.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 newUserPrincipal
instance using a decoded JWT token values. -
Method Summary
Methods inherited from class java.lang.Object
clone, getClass, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.springframework.security.oauth2.core.OAuth2AuthenticatedPrincipal
getAttribute, getAuthorities
Methods 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 newUserPrincipal
instance using aUser
entity. This constructor extracts relevant information from theUser
object and assigns it to the corresponding fields inUserPrincipal
.- Parameters:
user
- theUser
entity 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 newUserPrincipal
instance using a decoded JWT token values. This constructor extracts relevant information from theUser
object and assigns it to the corresponding fields inUserPrincipal
.- Parameters:
userId
- theUUID
id of the User.profileId
- theUUID
id of the Profile.advertiserId
- theUUID
id 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:
getAttributes
in interfaceorg.springframework.security.oauth2.core.OAuth2AuthenticatedPrincipal
- Returns:
- a map of user attributes.
-
getName
Retrieves the name of the user.- Specified by:
getName
in interfaceorg.springframework.security.core.AuthenticatedPrincipal
- Returns:
- the username of the user.
-
isAccountNonExpired
public boolean isAccountNonExpired()- Specified by:
isAccountNonExpired
in interfaceorg.springframework.security.core.userdetails.UserDetails
-
isAccountNonLocked
public boolean isAccountNonLocked()- Specified by:
isAccountNonLocked
in interfaceorg.springframework.security.core.userdetails.UserDetails
-
isCredentialsNonExpired
public boolean isCredentialsNonExpired()- Specified by:
isCredentialsNonExpired
in interfaceorg.springframework.security.core.userdetails.UserDetails
-
isEnabled
public boolean isEnabled()- Specified by:
isEnabled
in interfaceorg.springframework.security.core.userdetails.UserDetails
-
hashCode
public int hashCode() -
equals
-