Enum TimeOneTimePassword

    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
      HMACSHA1  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.String oneTimePassword​(java.lang.String secret)
      Uses the defaults for ping length, start time, time step.
      java.lang.String oneTimePassword​(java.lang.String secret, int pinLength)  
      java.lang.String oneTimePassword​(java.lang.String secret, long startTime, long timeStep, int pinLength)  
      java.lang.String oneTimePassword​(java.lang.String secret, long nowTime, long startTime, long timeStep, int pinLength)
      Control over all attributes.
      static TimeOneTimePassword valueOf​(java.lang.String name)
      Returns the enum constant of this type with the specified name.
      static TimeOneTimePassword[] values()
      Returns an array containing the constants of this enum type, in the order they are declared.
      • Methods inherited from class java.lang.Enum

        clone, compareTo, equals, finalize, getDeclaringClass, hashCode, name, ordinal, toString, valueOf
      • Methods inherited from class java.lang.Object

        getClass, notify, notifyAll, wait, wait, wait
    • Method Detail

      • values

        public static TimeOneTimePassword[] values()
        Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:
        for (TimeOneTimePassword c : TimeOneTimePassword.values())
            System.out.println(c);
        
        Returns:
        an array containing the constants of this enum type, in the order they are declared
      • valueOf

        public static TimeOneTimePassword valueOf​(java.lang.String name)
        Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)
        Parameters:
        name - the name of the enum constant to be returned.
        Returns:
        the enum constant with the specified name
        Throws:
        java.lang.IllegalArgumentException - if this enum type has no constant with the specified name
        java.lang.NullPointerException - if the argument is null
      • oneTimePassword

        public java.lang.String oneTimePassword​(java.lang.String secret)
                                         throws java.lang.Exception

        Uses the defaults for ping length, start time, time step. Uses System.currentTimeMillis() / 1000 to get he right-now-time

        Parameters:
        secret - shared secret between Google Authenticator and Server
        Returns:
        a 6 digit pin, computed for current step of 30 seconds and start time 0
        Throws:
        java.lang.Exception - catch-all Exception related to computePin or ByteBuffer
      • oneTimePassword

        public java.lang.String oneTimePassword​(java.lang.String secret,
                                                int pinLength)
                                         throws java.lang.Exception
        Parameters:
        secret - shared secret between Google Authenticator and Server
        pinLength - length of the pin/password
        Returns:
        the pin with the specified length, computed for current step of 30 seconds and start time 0
        Throws:
        java.lang.Exception - catch-all Exception related to computePin or ByteBuffer
      • oneTimePassword

        public java.lang.String oneTimePassword​(java.lang.String secret,
                                                long startTime,
                                                long timeStep,
                                                int pinLength)
                                         throws java.lang.Exception
        Parameters:
        secret - shared secret between Google Authenticator and Server
        startTime - unix time to start counting time steps, usually it will be 0, see README.md
        timeStep - window between new code generation, in seconds
        pinLength - length of the pin/password
        Returns:
        the pin with the specified length, computed for current step of 30 seconds and start time 0
        Throws:
        java.lang.Exception - catch-all Exception related to computePin or ByteBuffer
      • oneTimePassword

        public java.lang.String oneTimePassword​(java.lang.String secret,
                                                long nowTime,
                                                long startTime,
                                                long timeStep,
                                                int pinLength)
                                         throws java.lang.Exception

        Control over all attributes. May use the nowTime for calculating older values in order to account for network delays or slow entry on demand, without actually storing those values to begin with.

        Parameters:
        secret - shared secret between Google Authenticator and Server
        nowTime - the right now time in Unix; expects seconds, should be in seconds - for ex., System.currentTimeMillis() / 1000
        startTime - unix time to start counting time steps, usually it will be 0, see README.md
        timeStep - window between new code generation, in seconds
        pinLength - length of the pin/password
        Returns:
        the pin with the specified length, computed for current step of 30 seconds and start time 0
        Throws:
        java.lang.Exception - catch-all Exception related to computePin or ByteBuffer