Package app.YUP.config
Class UserAuthenticationToken
java.lang.Object
org.springframework.security.authentication.AbstractAuthenticationToken
app.YUP.config.UserAuthenticationToken
- All Implemented Interfaces:
Serializable,Principal,org.springframework.security.core.Authentication,org.springframework.security.core.CredentialsContainer
public class UserAuthenticationToken
extends org.springframework.security.authentication.AbstractAuthenticationToken
Custom authentication token for the application. This class extends Spring's AbstractAuthenticationToken
and is used to represent the authenticated user during the security context.
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionUserAuthenticationToken(User user, Collection<? extends org.springframework.security.core.GrantedAuthority> authorities) Constructor for UserAuthenticationToken. -
Method Summary
Modifier and TypeMethodDescriptionReturns the credentials (usually a password) associated with this token.Returns the principal (usually a User object) associated with this token.Methods inherited from class org.springframework.security.authentication.AbstractAuthenticationToken
equals, eraseCredentials, getAuthorities, getDetails, getName, hashCode, isAuthenticated, setAuthenticated, setDetails, toString
-
Constructor Details
-
UserAuthenticationToken
public UserAuthenticationToken(User user, Collection<? extends org.springframework.security.core.GrantedAuthority> authorities) Constructor for UserAuthenticationToken.- Parameters:
user- The authenticated user.authorities- The authorities (roles) of the user.
-
-
Method Details
-
getCredentials
Returns the credentials (usually a password) associated with this token. In this case, it returns null since we don't have a password in our authentication process.- Returns:
- null
-
getPrincipal
Returns the principal (usually a User object) associated with this token.- Returns:
- The authenticated user.
-