Class TimeDriftTotp


  • public final class TimeDriftTotp
    extends Object
    • Constructor Detail

      • TimeDriftTotp

        public TimeDriftTotp​(String secret)
      • TimeDriftTotp

        public TimeDriftTotp​(String secret,
                             Clock clock)
      • TimeDriftTotp

        public TimeDriftTotp​(String secret,
                             int lookAheadInterval,
                             int lookBehindInterval)
      • TimeDriftTotp

        public TimeDriftTotp​(String secret,
                             int lookAheadInterval,
                             int lookBehindInterval,
                             int timeDriftCorrection)
      • TimeDriftTotp

        public TimeDriftTotp​(String secret,
                             Clock clock,
                             int lookAheadInterval,
                             int lookBehindInterval)
      • TimeDriftTotp

        public TimeDriftTotp​(String secret,
                             Clock clock,
                             int lookAheadInterval,
                             int lookBehindInterval,
                             int timeDriftCorrection)
    • Method Detail

      • verify

        public boolean verify​(String otp)
        Verifier - To be used only on the server side Taken from Google Authenticator with small modifications from PasscodeGenerator.java Verify a timeout code. The timeout code will be valid for a time determined by the interval period and the number of adjacent intervals checked.
        Parameters:
        otp - Timeout code
        Returns:
        True if the timeout code is valid Author: sweis@google.com (Steve Weis)
      • train

        public boolean train​(String otp)
      • getLookAheadInterval

        public int getLookAheadInterval()
      • getLookBehindInterval

        public int getLookBehindInterval()
      • getTimeDriftCorrection

        public int getTimeDriftCorrection()
      • uri

        public String uri​(String name)
        Prover - To be used only on the client side Retrieves the encoded URI to generated the QRCode required by Google Authenticator
        Parameters:
        name - Account name
        Returns:
        Encoded URI
      • now

        public String now()
        Retrieves the current OTP
        Returns:
        OTP
      • generate

        protected int generate​(String secret,
                               long interval)