Package ai.yda.framework.channel.shared
Class TokenAuthentication
java.lang.Object
org.springframework.security.authentication.AbstractAuthenticationToken
ai.yda.framework.channel.shared.TokenAuthentication
- All Implemented Interfaces:
Serializable,Principal,org.springframework.security.core.Authentication,org.springframework.security.core.CredentialsContainer
public class TokenAuthentication
extends org.springframework.security.authentication.AbstractAuthenticationToken
implements Serializable
Represents a bearer token based Authentication.
- Since:
- 0.1.0
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionConstructs a newTokenAuthenticationinstance with the specified key.TokenAuthentication(String key, Object principal, Collection<? extends org.springframework.security.core.GrantedAuthority> authorities) Constructs newTokenAuthenticationinstance with the specified key, principal, and authorities. -
Method Summary
Modifier and TypeMethodDescriptionbooleanstatic IntegerextractKeyHash(String key) Extracts the hash code of the specified key.inthashCode()Methods inherited from class org.springframework.security.authentication.AbstractAuthenticationToken
eraseCredentials, getAuthorities, getDetails, getName, isAuthenticated, setAuthenticated, setDetails, toStringMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.springframework.security.core.Authentication
getPrincipal
-
Constructor Details
-
TokenAuthentication
Constructs a newTokenAuthenticationinstance with the specified key. The token itself is not stored in this instance; instead, only its hash is stored. The principal is set to "anonymousUser" and the authorities are set to "ROLE_ANONYMOUS".- Parameters:
key- the authentication key.
-
TokenAuthentication
public TokenAuthentication(String key, Object principal, Collection<? extends org.springframework.security.core.GrantedAuthority> authorities) Constructs newTokenAuthenticationinstance with the specified key, principal, and authorities.- Parameters:
key- the authentication key.principal- the principal (e.g., username).authorities- the authorities granted to the principal.
-
-
Method Details
-
equals
-
hashCode
public int hashCode() -
getCredentials
- Specified by:
getCredentialsin interfaceorg.springframework.security.core.Authentication
-
extractKeyHash
Extracts the hash code of the specified key.- Parameters:
key- the key for which to extract the hash code.- Returns:
- the hash code of the key.
-