public interface IGoogleAuthenticator
| Modifier and Type | Method and Description |
|---|---|
boolean |
authorize(String secret,
int verificationCode)
Checks a verification code against a secret key using the current time.
|
boolean |
authorize(String secret,
int verificationCode,
long time)
Checks a verification code against a secret key using the specified time.
|
boolean |
authorizeUser(String userName,
int verificationCode)
This method validates a verification code of the specified user whose
private key is retrieved from the configured credential repository using
the current time.
|
boolean |
authorizeUser(String userName,
int verificationCode,
long time)
This method validates a verification code of the specified user whose
private key is retrieved from the configured credential repository.
|
GoogleAuthenticatorKey |
createCredentials()
This method generates a new set of credentials including:
Secret key.
Validation code.
A list of scratch codes.
The user must register this secret on their device.
|
GoogleAuthenticatorKey |
createCredentials(String userName)
This method generates a new set of credentials invoking the
#createCredentials method with no arguments. |
ICredentialRepository |
getCredentialRepository()
This method returns the credential repository used by this instance, or
null if none is set or none can be found using the ServiceLoader
API. |
int |
getTotpPassword(String secret)
This method generates the current TOTP password.
|
int |
getTotpPassword(String secret,
long time)
This method generates the TOTP password at the specified time.
|
int |
getTotpPasswordOfUser(String userName)
This method generates the current TOTP password.
|
int |
getTotpPasswordOfUser(String userName,
long time)
This method generates the TOTP password at the specified time.
|
void |
setCredentialRepository(ICredentialRepository repository)
This method sets the credential repository used by this instance.
|
GoogleAuthenticatorKey createCredentials()
GoogleAuthenticatorKey createCredentials(String userName)
#createCredentials method with no arguments. The generated
credentials are then saved using the configured
#ICredentialRepository service.
The user must register this secret on their device.userName - the user name.int getTotpPassword(String secret)
secret - the encoded secret key.int getTotpPassword(String secret, long time)
secret - The encoded secret key.time - The time to use to calculate the password.int getTotpPasswordOfUser(String userName)
userName - The user whose password must be created.int getTotpPasswordOfUser(String userName, long time)
userName - The user whose password must be created.time - The time to use to calculate the password.boolean authorize(String secret, int verificationCode) throws GoogleAuthenticatorException
secret - the encoded secret key.verificationCode - the verification code.true if the validation code is valid,
false otherwise.GoogleAuthenticatorException - if a failure occurs during the
calculation of the validation code.
The only failures that should occur
are related with the cryptographic
functions provided by the JCE.authorize(String, int, long)boolean authorize(String secret, int verificationCode, long time) throws GoogleAuthenticatorException
windowSize property of this class.
The default value of 30 seconds recommended by RFC 6238 is used for the
interval size.secret - The encoded secret key.verificationCode - The verification code.time - The time to use to calculate the TOTP password..true if the validation code is valid, false
otherwise.GoogleAuthenticatorException - if a failure occurs during the
calculation of the validation code.
The only failures that should occur
are related with the cryptographic
functions provided by the JCE.boolean authorizeUser(String userName, int verificationCode) throws GoogleAuthenticatorException
authorizeUser(String, int, long).userName - The user whose verification code is to be
validated.verificationCode - The validation code.true if the validation code is valid,
false otherwise.GoogleAuthenticatorException - if an unexpected error occurs.authorize(String, int)boolean authorizeUser(String userName, int verificationCode, long time) throws GoogleAuthenticatorException
authorize(String, int, long) method.userName - The user whose verification code is to be
validated.verificationCode - The validation code.time - The time to use to calculate the TOTP password.true if the validation code is valid,
false otherwise.GoogleAuthenticatorException - if an unexpected error occurs.authorize(String, int)ICredentialRepository getCredentialRepository()
null if none is set or none can be found using the ServiceLoader
API.void setCredentialRepository(ICredentialRepository repository)
null is passed to this method, no credential repository will be
used, nor discovered using the ServiceLoader API.repository - The credential repository to use, or null to
disable this feature.Copyright © 2018. All rights reserved.