Class UserMfaTempTokenDao
java.lang.Object
de.xima.fc.dao.impl.UserMfaTempTokenDao
- All Implemented Interfaces:
IUserMfaTempTokenDao
Default implementation of the
IUserMfaTempTokenDao interface for reading and writing- Since:
- 8.4.0
- Author:
- Norman Lorenz
-
Method Summary
Modifier and TypeMethodDescriptionintDeletes all expired temporary MFA tokens from the database.createNewToken(IEntityContext ec, IUser user) Creates a new temporary MFA token for the specified user.voidbooleandeleteToken(IEntityContext ec, String tokenValue) Deletes a temporary MFA token by its value.static UserMfaTempTokenDaoReturns the singleton instance of the UserMfaTokenDao.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.incrementVerifyAttempts(IEntityContext ec, String tokenValue) Increments the verification attempts for a given temporary MFA token by one.refreshToken(IEntityContext ec, String token)
-
Method Details
-
getInstance
Returns the singleton instance of the UserMfaTokenDao.- Returns:
- the singleton instance of UserMfaTokenDao
-
cleanUpExpiredTokens
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
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
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
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
- Specified by:
deleteAllTokensin interfaceIUserMfaTempTokenDao
-