Package de.xima.fc.dao.impl
Class UserMfaTempTokenDao
- java.lang.Object
-
- de.xima.fc.dao.impl.UserMfaTempTokenDao
-
- All Implemented Interfaces:
IUserMfaTempTokenDao
public class UserMfaTempTokenDao extends Object implements IUserMfaTempTokenDao
Default implementation of theIUserMfaTempTokenDaointerface for reading and writing- Since:
- 8.4.0
- Author:
- Norman Lorenz
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description intcleanUpExpiredTokens(IEntityContext ec)Deletes all expired temporary MFA tokens from the database.UserMfaTempTokencreateNewToken(IEntityContext ec, IUser user)Creates a new temporary MFA token for the specified user.voiddeleteAllTokens(IEntityContext ec)booleandeleteToken(IEntityContext ec, String tokenValue)Deletes a temporary MFA token by its value.static UserMfaTempTokenDaogetInstance()Returns the singleton instance of the UserMfaTokenDao.Optional<UserMfaTempToken>getToken(IEntityContext ec, String tokenValue)Retrieves a temporary MFA token by its value.booleanhasReachedMaxTokenLimit(IEntityContext ec, IUser user)Returns whether the user has reached the maximum number of temporary MFA tokens allowed.UserMfaTempTokenincrementVerifyAttempts(IEntityContext ec, String tokenValue)Increments the verification attempts for a given temporary MFA token by one.UserMfaTempTokenrefreshToken(IEntityContext ec, String token)
-
-
-
Method Detail
-
getInstance
public static UserMfaTempTokenDao getInstance()
Returns the singleton instance of the UserMfaTokenDao.- Returns:
- the singleton instance of UserMfaTokenDao
-
cleanUpExpiredTokens
public int cleanUpExpiredTokens(IEntityContext ec)
Description copied from interface:IUserMfaTempTokenDaoDeletes all expired temporary MFA tokens from the database.- Specified by:
cleanUpExpiredTokensin interfaceIUserMfaTempTokenDao- Parameters:
ec- the entity context- Returns:
- the number of tokens that were deleted
-
createNewToken
public UserMfaTempToken createNewToken(IEntityContext ec, IUser user) throws UserMfaTempTokenMaxException
Description copied from interface:IUserMfaTempTokenDaoCreates a new temporary MFA token for the specified user.- Specified by:
createNewTokenin interfaceIUserMfaTempTokenDao- Parameters:
ec- the entity contextuser- the user for whom the token is created- Returns:
- a new
UserMfaTempTokeninstance - Throws:
UserMfaTempTokenMaxException- if the maximum number of temporary tokens for the user is exceeded
-
deleteToken
public boolean deleteToken(IEntityContext ec, String tokenValue)
Description copied from interface:IUserMfaTempTokenDaoDeletes a temporary MFA token by its value.- Specified by:
deleteTokenin interfaceIUserMfaTempTokenDao- Parameters:
ec- the entity contexttokenValue- the value of the token to delete- Returns:
- true if the token was successfully deleted, false if no such token exists
-
getToken
public Optional<UserMfaTempToken> getToken(IEntityContext ec, String tokenValue)
Description copied from interface:IUserMfaTempTokenDaoRetrieves a temporary MFA token by its value.- Specified by:
getTokenin interfaceIUserMfaTempTokenDao- Parameters:
ec- the entity contexttokenValue- the value of the token to retrieve- Returns:
- an
Optionalcontaining theUserMfaTempTokenif found, or empty if not found
-
incrementVerifyAttempts
public UserMfaTempToken incrementVerifyAttempts(IEntityContext ec, String tokenValue) throws UserMfaTempTokenNotFoundException
Description copied from interface:IUserMfaTempTokenDaoIncrements the verification attempts for a given temporary MFA token by one.- Specified by:
incrementVerifyAttemptsin interfaceIUserMfaTempTokenDao- Parameters:
ec- the entity contexttokenValue- the value of the token for which to increment the attempts- Returns:
- the updated
UserMfaTempTokeninstance - Throws:
UserMfaTempTokenNotFoundException- if no token with the specified value is found
-
hasReachedMaxTokenLimit
public boolean hasReachedMaxTokenLimit(IEntityContext ec, IUser user)
Description copied from interface:IUserMfaTempTokenDaoReturns whether the user has reached the maximum number of temporary MFA tokens allowed.- Specified by:
hasReachedMaxTokenLimitin interfaceIUserMfaTempTokenDao- Parameters:
ec- the entity contextuser- the user to check for maximum token limit- Returns:
- true if the user has reached the maximum token limit, false otherwise
-
refreshToken
public UserMfaTempToken refreshToken(IEntityContext ec, String token) throws UserMfaTempTokenNotFoundException, UserMfaTempTokenMaxException, UserMfaTempTokenExpiredException
- Specified by:
refreshTokenin interfaceIUserMfaTempTokenDao- Throws:
UserMfaTempTokenNotFoundExceptionUserMfaTempTokenMaxExceptionUserMfaTempTokenExpiredException
-
deleteAllTokens
public void deleteAllTokens(IEntityContext ec)
- Specified by:
deleteAllTokensin interfaceIUserMfaTempTokenDao
-
-