Package org.forgerock.android.auth
Class OathMechanism
- java.lang.Object
-
- org.forgerock.android.auth.Mechanism
-
- org.forgerock.android.auth.OathMechanism
-
- All Implemented Interfaces:
java.lang.Comparable<Mechanism>
- Direct Known Subclasses:
HOTPMechanism,TOTPMechanism
public abstract class OathMechanism extends Mechanism
Represents an instance of a OATH authentication mechanism.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classOathMechanism.OathBuilder<T extends OathMechanism.OathBuilder>Builder class responsible for producing a Token.static classOathMechanism.TokenType
-
Constructor Summary
Constructors Modifier Constructor Description protectedOathMechanism(java.lang.String mechanismUID, java.lang.String issuer, java.lang.String accountName, java.lang.String type, OathMechanism.TokenType oathType, java.lang.String algorithm, java.lang.String secret, int digits, java.util.Calendar timeCreated)
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description static OathMechanismdeserialize(java.lang.String jsonString)Deserializes the specified Json into an object of theOathMechanismobject.java.lang.StringgetAlgorithm()Returns the algorithm used by this OathMechanism.intgetDigits()Returns the number of digits that are in OTPs generated by this Token.abstract OathTokenCodegetOathTokenCode()Generates a new set of codes for this OathMechanism Token.OathMechanism.TokenTypegetOathType()Returns the token type (HOTPMechanism, TOTPMechanism).abstract java.lang.StringtoJson()Creates a JSON string representation ofModelObjectobject.-
Methods inherited from class org.forgerock.android.auth.Mechanism
compareTo, equals, getAccountName, getId, getIssuer, getMechanismUID, getTimeAdded, getType, hashCode, matches
-
-
-
-
Constructor Detail
-
OathMechanism
protected OathMechanism(java.lang.String mechanismUID, java.lang.String issuer, java.lang.String accountName, java.lang.String type, OathMechanism.TokenType oathType, java.lang.String algorithm, java.lang.String secret, int digits, java.util.Calendar timeCreated)
-
-
Method Detail
-
getDigits
public int getDigits()
Returns the number of digits that are in OTPs generated by this Token.- Returns:
- the OTP length as int
-
getAlgorithm
public java.lang.String getAlgorithm()
Returns the algorithm used by this OathMechanism.- Returns:
- algorithm value as String
-
getOathType
public OathMechanism.TokenType getOathType()
Returns the token type (HOTPMechanism, TOTPMechanism).- Returns:
- The token type
-
getOathTokenCode
public abstract OathTokenCode getOathTokenCode() throws OathMechanismException
Generates a new set of codes for this OathMechanism Token.- Returns:
- OathTokenCode object that contains the currently active token code
- Throws:
OathMechanismException- If an error occur on generating the OTP codes
-
toJson
public abstract java.lang.String toJson()
Creates a JSON string representation ofModelObjectobject. Sensitive information are not exposed.
-
deserialize
public static OathMechanism deserialize(java.lang.String jsonString)
Deserializes the specified Json into an object of theOathMechanismobject.- Parameters:
jsonString- the json string representing the object to be deserialized- Returns:
- an
OathMechanismobject from the string. ReturnsnullifjsonStringisnull, ifjsonStringis empty or not able to parse it
-
-