Class 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.
    • Field Detail

      • algorithm

        protected java.lang.String algorithm
        Algorithm of HMAC-based OTP
      • digits

        protected int digits
        Digits as in Int for length of OTP credentials
    • 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 of ModelObject object. Sensitive information are not exposed.
        Specified by:
        toJson in class Mechanism
        Returns:
        a JSON string object
      • deserialize

        public static OathMechanism deserialize​(java.lang.String jsonString)
        Deserializes the specified Json into an object of the OathMechanism object.
        Parameters:
        jsonString - the json string representing the object to be deserialized
        Returns:
        an OathMechanism object from the string. Returns null if jsonString is null, if jsonString is empty or not able to parse it