Class UserTokenAPI

java.lang.Object
de.xima.fc.api.ASubAPI
de.xima.fc.api.entity.UserTokenAPI

public class UserTokenAPI extends ASubAPI
API class for reading and writing UserRefreshToken entities.
Since:
8.0.0
Author:
XIMA Media GmbH
  • Method Details

    • getInstance

      public static UserTokenAPI getInstance()
      Returns the singleton instance of this class.
      Returns:
      The singleton instance.
    • getTokenConfiguration

      public TokenConfiguration getTokenConfiguration(UserContext uc)
      Returns the token configuration for the given user context.
      Parameters:
      uc - The user context.
      Returns:
      The token configuration.
    • isValidRefreshToken

      public boolean isValidRefreshToken(UserContext uc, @NotNull @NotNull UUID refreshTokenId)
      Validates the given refresh token.
      Parameters:
      uc - The user context.
      refreshTokenId - The refresh token id.
      Returns:
      True if the refresh token is valid, false otherwise.
    • updateRefreshToken

      public UserRefreshToken updateRefreshToken(UserContext uc, @NotBlank @NotBlank String refreshToken, @NotNull @NotNull IClientDescriptor clientDescriptor) throws InvalidTokenException, UnknownTokenException
      Updates the refresh token.
      Parameters:
      uc - The user context.
      refreshToken - The refresh token.
      clientDescriptor - The client descriptor.
      Returns:
      The updated refresh token.
      Throws:
      InvalidTokenException - If the token is invalid.
      UnknownTokenException - If the token is unknown.
    • createRefreshToken

      public UserRefreshToken createRefreshToken(UserContext uc, @NotNull @NotNull RefreshTokenUserDataDTO refreshTokenUserDataDTO, String issuer, @NotNull @NotNull IClientDescriptor clientDescriptor) throws TokenCreateException
      Creates a refresh token.
      Parameters:
      uc - The user context.
      refreshTokenUserDataDTO - The refresh token user data.
      issuer - The issuer.
      clientDescriptor - The client descriptor.
      Returns:
      The created refresh token.
      Throws:
      TokenCreateException - If the token creation fails.
    • removeRefreshToken

      public boolean removeRefreshToken(UserContext uc, String refreshToken)
      Removes the refresh token.
      Parameters:
      uc - The user context.
      refreshToken - The refresh token.
      Returns:
      True if the refresh token was removed, false otherwise.
    • removeRefreshToken

      public boolean removeRefreshToken(UserContext uc, UserRefreshToken token)
      Removes the refresh token.
      Parameters:
      uc - The user context.
      token - The refresh token.
      Returns:
      True if the refresh token was removed, false otherwise.
    • getUserRefreshTokens

      public List<UserRefreshToken> getUserRefreshTokens(UserContext uc, IUser user)
      Get all refresh tokens for the given user.
      Parameters:
      uc - The user context.
      user - The user.
      Returns:
      The list of refresh tokens.
    • getRefreshTokenUserData

      public RefreshTokenUserDataDTO getRefreshTokenUserData(UserContext uc, @NotNull @NotNull UUID refreshTokenId) throws InvalidTokenException
      Get the refresh token user data.
      Parameters:
      uc - The user context.
      refreshTokenId - The refresh token id.
      Returns:
      The refresh token user data.
      Throws:
      InvalidTokenException - If the token is invalid.
    • getRefreshTokenUserData

      public RefreshTokenUserDataDTO getRefreshTokenUserData(UserContext uc, @NotNull @NotNull String refreshToken) throws InvalidTokenException
      Get the refresh token user data.
      Parameters:
      uc - The user context.
      refreshToken - The refresh token.
      Returns:
      The refresh token user data.
      Throws:
      InvalidTokenException - If the token is invalid.