Package org.forgerock.android.auth
Class OathTokenCode
- java.lang.Object
-
- org.forgerock.android.auth.OathTokenCode
-
public class OathTokenCode extends java.lang.ObjectRepresents a currently active OTP token.
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedOathTokenCode(TimeKeeper timeKeeper, java.lang.String code, long start, long until, OathMechanism.TokenType tokenType)Creates a OathTokenCode wrap with given data
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.StringgetCurrentCode()Gets the code which is currently active.OathMechanism.TokenTypegetOathType()Returns the token type (HOTP, TOTP)intgetProgress()Get the current percent progress of the code forTOTPMechanism.longgetStart()Get the started timestamp of current Oath token.longgetUntil()Get the expiration timestamp for TOTP tokens.booleanisValid()Indicates whether the current OathTokenCode is valid or not.java.lang.StringtoJson()Creates a JSON string representation ofOathTokenCodeobject.
-
-
-
Constructor Detail
-
OathTokenCode
protected OathTokenCode(TimeKeeper timeKeeper, java.lang.String code, long start, long until, OathMechanism.TokenType tokenType)
Creates a OathTokenCode wrap with given data- Parameters:
timeKeeper- class containing timekeeping functionalitycode- OTP code with 6 or 8 digitsstart- start timestamp for current Oath codeuntil- expiration timestamp for current Oath code
-
-
Method Detail
-
getCurrentCode
public java.lang.String getCurrentCode()
Gets the code which is currently active.- Returns:
- The currently active token.
-
getStart
public long getStart()
Get the started timestamp of current Oath token.- Returns:
- The start time in milliseconds.
-
getUntil
public long getUntil()
Get the expiration timestamp for TOTP tokens. For HOTP, it returns0as it does not expires.- Returns:
- The expiration time in milliseconds.
-
isValid
public boolean isValid()
Indicates whether the current OathTokenCode is valid or not. For HOTP, isValid always returns 'true'. For TOTP, this property computes, start and end timestamp of OathTokenCode and determines its validity.- Returns:
trueif the OathTokenCode is still valid,falseotherwise.
-
getOathType
public OathMechanism.TokenType getOathType()
Returns the token type (HOTP, TOTP)- Returns:
- The token type.
-
getProgress
public int getProgress()
Get the current percent progress of the code forTOTPMechanism. This is a number between 0 and 1000, and represents the amount of time that has passed between the start and end times of the code. ForHOTPMechanism, progress always returns 0.- Returns:
- The percentage progress, a number between 0 and 1000.
-
toJson
public java.lang.String toJson()
Creates a JSON string representation ofOathTokenCodeobject.- Returns:
- a JSON string object
-
-