Class AccountLinkToken

java.lang.Object
org.localify.user.support.AccountLinkToken

@Entity public class AccountLinkToken extends Object
Represents a token used to link a user's account to an external service.
  • Constructor Details

    • AccountLinkToken

      public AccountLinkToken()
      Default constructor.
    • AccountLinkToken

      public AccountLinkToken(User user, AccountLinkToken.ExpectedService expectedService)
      Creates a new account link token.
      Parameters:
      user - The user to link.
      expectedService - The service to link to.
  • Method Details

    • isValid

      public boolean isValid()
      Checks if the token is still valid. A token is valid if it has not been completed and was created within the last 2 hours.
      Returns:
      true if the token is valid, false otherwise.
    • getJwtStateRepresentation

      public String getJwtStateRepresentation()
      Gets the JWT state representation of the token.
      Returns:
      The JWT state representation.
    • maybeParseAccountStateUuid

      public static UUID maybeParseAccountStateUuid(String state)
      Attempts to parse the state for an account link token UUID from the given state string.
      Parameters:
      state - The state string.
      Returns:
      The UUID of the account link token, or null if it cannot be parsed.
    • getId

      public UUID getId()
      Gets the ID of the token.
      Returns:
      The ID.
    • setId

      public void setId(UUID id)
      Sets the ID of the token.
      Parameters:
      id - The ID.
    • getUser

      public User getUser()
      Gets the user associated with the token.
      Returns:
      The user.
    • setUser

      public void setUser(User user)
      Sets the user associated with the token.
      Parameters:
      user - The user.
    • getCreatedAt

      public Instant getCreatedAt()
      Gets the creation timestamp of the token.
      Returns:
      The creation timestamp.
    • setCreatedAt

      public void setCreatedAt(Instant createdAt)
      Sets the creation timestamp of the token.
      Parameters:
      createdAt - The creation timestamp.
    • getUpdatedAt

      public Instant getUpdatedAt()
      Gets the last update timestamp of the token.
      Returns:
      The last update timestamp.
    • setUpdatedAt

      public void setUpdatedAt(Instant updatedAt)
      Sets the last update timestamp of the token.
      Parameters:
      updatedAt - The last update timestamp.
    • isCompleted

      public boolean isCompleted()
      Checks if the token has been completed.
      Returns:
      true if the token has been completed, false otherwise.
    • setCompleted

      public void setCompleted(boolean completed)
      Sets whether the token has been completed.
      Parameters:
      completed - true if the token has been completed, false otherwise.
    • complete

      public void complete()
      Marks the token as completed.
    • getExpectedService

      public AccountLinkToken.ExpectedService getExpectedService()
      Gets the expected service for the token.
      Returns:
      The expected service.
    • setExpectedService

      public void setExpectedService(AccountLinkToken.ExpectedService expectedService)
      Sets the expected service for the token.
      Parameters:
      expectedService - The expected service.