Package de.xima.fc.api.entity
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 writingUserRefreshTokenentities.- Since:
- 8.0.0
- Author:
- XIMA Media GmbH
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description UserRefreshTokencreateRefreshToken(UserContext uc, @NotNull RefreshTokenUserDataDTO refreshTokenUserDataDTO, String issuer, @NotNull IClientDescriptor clientDescriptor)Creates a refresh token.static UserTokenAPIgetInstance()Returns the singleton instance of this class.RefreshTokenUserDataDTOgetRefreshTokenUserData(UserContext uc, @NotNull String refreshToken)Get the refresh token user data.RefreshTokenUserDataDTOgetRefreshTokenUserData(UserContext uc, @NotNull UUID refreshTokenId)Get the refresh token user data.TokenConfigurationgetTokenConfiguration(UserContext uc)Returns the token configuration for the given user context.List<UserRefreshToken>getUserRefreshTokens(UserContext uc, IUser user)Get all refresh tokens for the given user.booleanisValidRefreshToken(UserContext uc, @NotNull UUID refreshTokenId)Validates the given refresh token.booleanremoveRefreshToken(UserContext uc, UserRefreshToken token)Removes the refresh token.booleanremoveRefreshToken(UserContext uc, String refreshToken)Removes the refresh token.UserRefreshTokenupdateRefreshToken(UserContext uc, @NotNull String refreshToken, @NotNull IClientDescriptor clientDescriptor)Updates the refresh token.-
Methods inherited from class de.xima.fc.api.ASubAPI
getHandlerProvider
-
-
-
-
Method Detail
-
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, @NotNull @NotNull 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.
-
-