Package org.forgerock.android.auth
Class TOTPMechanism
- java.lang.Object
-
- org.forgerock.android.auth.Mechanism
-
- org.forgerock.android.auth.OathMechanism
-
- org.forgerock.android.auth.TOTPMechanism
-
- All Implemented Interfaces:
java.lang.Comparable<Mechanism>
public class TOTPMechanism extends OathMechanism
Represents Time-based OTP authentication mechanism and is responsible for its related operation.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classTOTPMechanism.TOTPBuilderBuilder class responsible for producing a TOTPMechanism Token.-
Nested classes/interfaces inherited from class org.forgerock.android.auth.OathMechanism
OathMechanism.OathBuilder<T extends OathMechanism.OathBuilder>, OathMechanism.TokenType
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static TOTPMechanism.TOTPBuilderbuilder()Returns a builder for creating a TOTPMechanism Mechanism.static TOTPMechanismdeserialize(java.lang.String jsonString)Deserializes the specified Json into an object of theTOTPMechanismobject.OathTokenCodegetOathTokenCode()Generates a new set of codes for this OathMechanism Token.longgetPeriod()Returns the period of this OathMechanism.java.lang.StringtoJson()Creates a JSON string representation ofModelObjectobject.-
Methods inherited from class org.forgerock.android.auth.OathMechanism
getAlgorithm, getDigits, getOathType
-
Methods inherited from class org.forgerock.android.auth.Mechanism
compareTo, equals, getAccountName, getId, getIssuer, getMechanismUID, getTimeAdded, getType, hashCode, matches
-
-
-
-
Method Detail
-
getPeriod
public long getPeriod()
Returns the period of this OathMechanism. The frequency with which the OTP changes in seconds- Returns:
- period as long value
-
getOathTokenCode
public OathTokenCode getOathTokenCode() throws OathMechanismException
Description copied from class:OathMechanismGenerates a new set of codes for this OathMechanism Token.- Specified by:
getOathTokenCodein classOathMechanism- Returns:
- OathTokenCode object that contains the currently active token code
- Throws:
OathMechanismException- If an error occur on generating the OTP codes
-
toJson
public java.lang.String toJson()
Creates a JSON string representation ofModelObjectobject. Sensitive information are not exposed.- Specified by:
toJsonin classOathMechanism- Returns:
- a JSON string object
-
deserialize
public static TOTPMechanism deserialize(java.lang.String jsonString)
Deserializes the specified Json into an object of theTOTPMechanismobject.- Parameters:
jsonString- the json string representing the object to be deserialized- Returns:
- an
TOTPMechanismobject from the string. ReturnsnullifjsonStringisnull, ifjsonStringis empty or not able to parse it.
-
builder
public static TOTPMechanism.TOTPBuilder builder()
Returns a builder for creating a TOTPMechanism Mechanism.- Returns:
- The OathMechanism builder.
-
-