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

    Constructors
    Constructor
    Description
    UserAuthenticationToken(User user, Collection<? extends org.springframework.security.core.GrantedAuthority> authorities)
    Constructor for UserAuthenticationToken.
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns 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

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait

    Methods inherited from interface java.security.Principal

    implies
  • 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

      public Object 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

      public Object getPrincipal()
      Returns the principal (usually a User object) associated with this token.
      Returns:
      The authenticated user.