Package tech.lastbox.jwt
Record Class Token
java.lang.Object
java.lang.Record
tech.lastbox.jwt.Token
public record Token(String token, String subject, LocalDateTime issuedAt, LocalDateTime expiresIn, String issuer, List<String> scope, boolean isRevoked)
extends Record
Represents a JWT (JSON Web Token) in the system.
This record encapsulates information related to the token,
including its value, subject, issue and expiration times, issuer, scope,
and revocation status.
This class is typically used for transferring JWT-related data and is ideal for scenarios where immutable data structures are required. It encapsulates the following fields:
token: The string representation of the token itself.subject: The subject associated with the token (typically the user or entity).issuedAt: The timestamp representing when the token was issued.expiresIn: The timestamp representing when the token will expire.issuer: The entity that issued the token.scope: A list of string values representing the scopes/permissions granted by the token.isRevoked: A boolean flag indicating whether the token has been revoked.
This record is designed for use in scenarios where tokens are immutable, such as when tokens are validated or stored for reference. The fields provided allow for detailed tracking of token properties and status.
-
Constructor Summary
ConstructorsConstructorDescriptionToken(String token, String subject, LocalDateTime issuedAt, LocalDateTime expiresIn, String issuer, List<String> scope, boolean isRevoked) Creates an instance of aTokenrecord class. -
Method Summary
Modifier and TypeMethodDescriptionfinal booleanIndicates whether some other object is "equal to" this one.Returns the value of theexpiresInrecord component.final inthashCode()Returns a hash code value for this object.booleanReturns the value of theisRevokedrecord component.issuedAt()Returns the value of theissuedAtrecord component.issuer()Returns the value of theissuerrecord component.scope()Returns the value of thescoperecord component.subject()Returns the value of thesubjectrecord component.token()Returns the value of thetokenrecord component.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
Token
public Token(String token, String subject, LocalDateTime issuedAt, LocalDateTime expiresIn, String issuer, List<String> scope, boolean isRevoked) Creates an instance of aTokenrecord class.- Parameters:
token- the value for thetokenrecord componentsubject- the value for thesubjectrecord componentissuedAt- the value for theissuedAtrecord componentexpiresIn- the value for theexpiresInrecord componentissuer- the value for theissuerrecord componentscope- the value for thescoperecord componentisRevoked- the value for theisRevokedrecord component
-
-
Method Details
-
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared withObjects::equals(Object,Object); primitive components are compared with '=='. -
token
Returns the value of thetokenrecord component.- Returns:
- the value of the
tokenrecord component
-
subject
Returns the value of thesubjectrecord component.- Returns:
- the value of the
subjectrecord component
-
issuedAt
Returns the value of theissuedAtrecord component.- Returns:
- the value of the
issuedAtrecord component
-
expiresIn
Returns the value of theexpiresInrecord component.- Returns:
- the value of the
expiresInrecord component
-
issuer
Returns the value of theissuerrecord component.- Returns:
- the value of the
issuerrecord component
-
scope
Returns the value of thescoperecord component.- Returns:
- the value of the
scoperecord component
-
isRevoked
public boolean isRevoked()Returns the value of theisRevokedrecord component.- Returns:
- the value of the
isRevokedrecord component
-