Package org.localify.user.support
Class AccountLinkToken
java.lang.Object
org.localify.user.support.AccountLinkToken
Represents a token used to link a user's account to an external service.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumThe service that is expected to be linked. -
Constructor Summary
ConstructorsConstructorDescriptionDefault constructor.AccountLinkToken(User user, AccountLinkToken.ExpectedService expectedService) Creates a new account link token. -
Method Summary
Modifier and TypeMethodDescriptionvoidcomplete()Marks the token as completed.Gets the creation timestamp of the token.Gets the expected service for the token.getId()Gets the ID of the token.Gets the JWT state representation of the token.Gets the last update timestamp of the token.getUser()Gets the user associated with the token.booleanChecks if the token has been completed.booleanisValid()Checks if the token is still valid.static UUIDmaybeParseAccountStateUuid(String state) Attempts to parse the state for an account link token UUID from the given state string.voidsetCompleted(boolean completed) Sets whether the token has been completed.voidsetCreatedAt(Instant createdAt) Sets the creation timestamp of the token.voidsetExpectedService(AccountLinkToken.ExpectedService expectedService) Sets the expected service for the token.voidSets the ID of the token.voidsetUpdatedAt(Instant updatedAt) Sets the last update timestamp of the token.voidSets the user associated with the token.
-
Constructor Details
-
AccountLinkToken
public AccountLinkToken()Default constructor. -
AccountLinkToken
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
Gets the JWT state representation of the token.- Returns:
- The JWT state representation.
-
maybeParseAccountStateUuid
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
Gets the ID of the token.- Returns:
- The ID.
-
setId
Sets the ID of the token.- Parameters:
id- The ID.
-
getUser
Gets the user associated with the token.- Returns:
- The user.
-
setUser
Sets the user associated with the token.- Parameters:
user- The user.
-
getCreatedAt
Gets the creation timestamp of the token.- Returns:
- The creation timestamp.
-
setCreatedAt
Sets the creation timestamp of the token.- Parameters:
createdAt- The creation timestamp.
-
getUpdatedAt
Gets the last update timestamp of the token.- Returns:
- The last update timestamp.
-
setUpdatedAt
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
Gets the expected service for the token.- Returns:
- The expected service.
-
setExpectedService
Sets the expected service for the token.- Parameters:
expectedService- The expected service.
-