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 theIUserMfaTempTokenDao
interface 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 int
cleanUpExpiredTokens(IEntityContext ec)
Deletes all expired temporary MFA tokens from the database.UserMfaTempToken
createNewToken(IEntityContext ec, IUser user)
Creates a new temporary MFA token for the specified user.void
deleteAllTokens(IEntityContext ec)
boolean
deleteToken(IEntityContext ec, String tokenValue)
Deletes a temporary MFA token by its value.static UserMfaTempTokenDao
getInstance()
Returns the singleton instance of the UserMfaTokenDao.Optional<UserMfaTempToken>
getToken(IEntityContext ec, String tokenValue)
Retrieves a temporary MFA token by its value.boolean
hasReachedMaxTokenLimit(IEntityContext ec, IUser user)
Returns whether the user has reached the maximum number of temporary MFA tokens allowed.UserMfaTempToken
incrementVerifyAttempts(IEntityContext ec, String tokenValue)
Increments the verification attempts for a given temporary MFA token by one.UserMfaTempToken
refreshToken(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:IUserMfaTempTokenDao
Deletes all expired temporary MFA tokens from the database.- Specified by:
cleanUpExpiredTokens
in 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:IUserMfaTempTokenDao
Creates a new temporary MFA token for the specified user.- Specified by:
createNewToken
in interfaceIUserMfaTempTokenDao
- Parameters:
ec
- the entity contextuser
- the user for whom the token is created- Returns:
- a new
UserMfaTempToken
instance - 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:IUserMfaTempTokenDao
Deletes a temporary MFA token by its value.- Specified by:
deleteToken
in 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:IUserMfaTempTokenDao
Retrieves a temporary MFA token by its value.- Specified by:
getToken
in interfaceIUserMfaTempTokenDao
- Parameters:
ec
- the entity contexttokenValue
- the value of the token to retrieve- Returns:
- an
Optional
containing theUserMfaTempToken
if found, or empty if not found
-
incrementVerifyAttempts
public UserMfaTempToken incrementVerifyAttempts(IEntityContext ec, String tokenValue) throws UserMfaTempTokenNotFoundException
Description copied from interface:IUserMfaTempTokenDao
Increments the verification attempts for a given temporary MFA token by one.- Specified by:
incrementVerifyAttempts
in interfaceIUserMfaTempTokenDao
- Parameters:
ec
- the entity contexttokenValue
- the value of the token for which to increment the attempts- Returns:
- the updated
UserMfaTempToken
instance - Throws:
UserMfaTempTokenNotFoundException
- if no token with the specified value is found
-
hasReachedMaxTokenLimit
public boolean hasReachedMaxTokenLimit(IEntityContext ec, IUser user)
Description copied from interface:IUserMfaTempTokenDao
Returns whether the user has reached the maximum number of temporary MFA tokens allowed.- Specified by:
hasReachedMaxTokenLimit
in 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:
refreshToken
in interfaceIUserMfaTempTokenDao
- Throws:
UserMfaTempTokenNotFoundException
UserMfaTempTokenMaxException
UserMfaTempTokenExpiredException
-
deleteAllTokens
public void deleteAllTokens(IEntityContext ec)
- Specified by:
deleteAllTokens
in interfaceIUserMfaTempTokenDao
-
-