Class GoogleTOTPAuthenticator
java.lang.Object
net.shibboleth.shared.component.AbstractInitializableComponent
net.shibboleth.idp.plugin.authn.totp.impl.GoogleTOTPAuthenticator
- All Implemented Interfaces:
TOTPAuthenticator,Component,DestructableComponent,InitializableComponent
@ThreadSafeAfterInit
public class GoogleTOTPAuthenticator
extends AbstractInitializableComponent
implements TOTPAuthenticator
A TOTP implementation based on Google Authenticator code.
-
Nested Class Summary
Nested classes/interfaces inherited from interface net.shibboleth.idp.plugin.authn.totp.impl.TOTPAuthenticator
TOTPAuthenticator.TOTPCredential -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate com.warrenstrange.googleauth.GoogleAuthenticatorConfigGoogle Authenticator config.private com.warrenstrange.googleauth.GoogleAuthenticatorThe implementation. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncreateCredential(String issuer, String accountName) Generate a new credential.protected voidvoidsetGoogleAuthenticatorConfig(com.warrenstrange.googleauth.GoogleAuthenticatorConfig config) Set theGoogleAuthenticatorConfigto use.booleanvalidate(byte[] secret, int code) Validate a secret and code.Methods inherited from class net.shibboleth.shared.component.AbstractInitializableComponent
checkComponentActive, checkSetterPreconditions, destroy, doDestroy, ifDestroyedThrowDestroyedComponentException, ifInitializedThrowUnmodifiabledComponentException, ifNotInitializedThrowUninitializedComponentException, initialize, isDestroyed, isInitialized
-
Field Details
-
authconfig
Google Authenticator config. -
authenticator
The implementation.
-
-
Constructor Details
-
GoogleTOTPAuthenticator
public GoogleTOTPAuthenticator()
-
-
Method Details
-
setGoogleAuthenticatorConfig
public void setGoogleAuthenticatorConfig(@Nonnull com.warrenstrange.googleauth.GoogleAuthenticatorConfig config) Set theGoogleAuthenticatorConfigto use.- Parameters:
config- configuration to use
-
doInitialize
- Overrides:
doInitializein classAbstractInitializableComponent- Throws:
ComponentInitializationException
-
createCredential
@Nonnull public TOTPAuthenticator.TOTPCredential createCredential(@Nullable @NotEmpty String issuer, @Nullable @NotEmpty String accountName) throws GeneralSecurityException Generate a new credential.- Specified by:
createCredentialin interfaceTOTPAuthenticator- Parameters:
issuer- TOTP credential issueraccountName- TOTP account holder- Returns:
- a new credential
- Throws:
GeneralSecurityException- if unable to generate the credential
-
validate
Validate a secret and code.- Specified by:
validatein interfaceTOTPAuthenticator- Parameters:
secret- token secret/seed, unencodedcode- token code to validate- Returns:
- true iff the code is valid
-