Package dev.uni_hamburg.security.otp
Class TimeDriftTotp
- java.lang.Object
-
- dev.uni_hamburg.security.otp.TimeDriftTotp
-
public final class TimeDriftTotp extends Object
-
-
Constructor Summary
Constructors Constructor Description TimeDriftTotp(String secret)TimeDriftTotp(String secret, int lookAheadInterval, int lookBehindInterval)TimeDriftTotp(String secret, int lookAheadInterval, int lookBehindInterval, int timeDriftCorrection)TimeDriftTotp(String secret, Clock clock)TimeDriftTotp(String secret, Clock clock, int lookAheadInterval, int lookBehindInterval)TimeDriftTotp(String secret, Clock clock, int lookAheadInterval, int lookBehindInterval, int timeDriftCorrection)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected intgenerate(String secret, long interval)intgetLookAheadInterval()intgetLookBehindInterval()intgetTimeDriftCorrection()Stringnow()Retrieves the current OTPbooleantrain(String otp)Stringuri(String name)Prover - To be used only on the client side Retrieves the encoded URI to generated the QRCode required by Google Authenticatorbooleanverify(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.
-
-
-
Constructor Detail
-
TimeDriftTotp
public TimeDriftTotp(String secret)
-
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)
-
-
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)
-
-