Interface PasscodeService<P extends PasswordToken,U extends User> 
- All Known Implementing Classes:
- DefaultPasscodeService
public interface PasscodeService<P extends PasswordToken,U extends User> 
This service provides methods for creating and consuming random passcodes.
- Author:
- Cade Rea (cade-rea)
- 
Method SummaryModifier and TypeMethodDescriptionConsume a passcode.createPasscode(U user, String purpose) Create a new token for a User with a specific purpose.Generate a new random token String with only letters and numbers.generateSecureToken(boolean includeSpecialCharacters) Generate a new random token String that may special characters.booleaninvalidate(String passcodeId) Invalidate an active passcode.readTokensForUser(U user, String purpose) Return all of a user's tokens for a particular purpose.booleanGet the status of aPasswordToken.
- 
Method Details- 
createPasscodeCreate a new token for a User with a specific purpose.- Parameters:
- user- The User who will own the token.
- purpose- The purpose for this token.
- Returns:
- A new PasswordTokenobject with the new plaintext passcode on the token field.
 
- 
consumeConsume a passcode.- Parameters:
- user- The User that owns the token.
- purpose- The purpose of the token. This will be validated against the purpose stored with the token.
- passcode- The passcode String to consume.
- Returns:
- An optional containing the used token if successful, empty if unsuccessful.
 
- 
statusGet the status of aPasswordToken.- Parameters:
- passcodeId- The id of the- PasswordToken.
- Returns:
- True if the token is valid, false otherwise.
 
- 
invalidateInvalidate an active passcode.- Parameters:
- passcodeId- The id of the- PasswordToken.
- Returns:
- True if the passcode was invalidated, false otherwise.
 
- 
readTokensForUserReturn all of a user's tokens for a particular purpose. The token fields of the returned objects will contain the encoded passcode.- Parameters:
- user- The User that owns the tokens.
- purpose- The purpose of the tokens.
- Returns:
- A List of PasswordToken.
 
- 
generateSecureTokenString generateSecureToken()Generate a new random token String with only letters and numbers. This String is not persisted.- Returns:
- A secure random String.
 
- 
generateSecureTokenGenerate a new random token String that may special characters. The String is not persisted.- Parameters:
- includeSpecialCharacters- True if special characters should be included in the token. If false, only letters and numbers will be used.
- Returns:
- A secure random String.
 
 
-