Package anbxj

# Class Crypto_TimeStampValidator

java.lang.Object
anbxj.Crypto_TimeStampValidator

public class Crypto_TimeStampValidator extends Object
A class for time stamp validation

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `static final long`
  `DEFAULT_MAX_TIMESTAMP_AGE`
  The default maximum age of time stamps is 15 minutes.
  `static final long`
  `DEFAULT_TIMESTAMP_WINDOW`
  The default time stamp window
  `protected final long`
  `maxTimestampAgeMsec`
  Tha maximum timestamp age in ms

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `Crypto_TimeStampValidator()`
  Construct a validator that rejects messages more than five minutes old
  `Crypto_TimeStampValidator(long maxTimestampAgeMsec)`
  Public constructor.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `protected long`
  `currentTimeMsec()`
  Get the number of milliseconds since midnight, January 1, 1970 UTC.
  `boolean`
  `equals(Object that)`
  `Date`
  `releaseGarbage()`
  Allow objects that are no longer useful to become garbage.
  `protected Date`
  `validateNonce(byte[] nx, long timestamp)`
  Throw an exception if the nonce has been validated previously.

  ### Methods inherited from class java.lang.Object

  `clone, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Field Details

  - ### DEFAULT_MAX_TIMESTAMP_AGE

    public static final long DEFAULT_MAX_TIMESTAMP_AGE
    The default maximum age of time stamps is 15 minutes.
    See Also:
      - Constant Field Values

  - ### DEFAULT_TIMESTAMP_WINDOW

    public static final long DEFAULT_TIMESTAMP_WINDOW
    The default time stamp window
    See Also:
      - Constant Field Values

  - ### maxTimestampAgeMsec

    protected final long maxTimestampAgeMsec
    Tha maximum timestamp age in ms

- ## Constructor Details

  - ### Crypto_TimeStampValidator

    public Crypto_TimeStampValidator()
    Construct a validator that rejects messages more than five minutes old

  - ### Crypto_TimeStampValidator

    public Crypto_TimeStampValidator(long maxTimestampAgeMsec)
    Public constructor.
    Parameters:
      `maxTimestampAgeMsec` - the range of valid timestamps, in milliseconds into the past or future. So the total range of valid timestamps is twice this value, rounded to the nearest second.

- ## Method Details

  - ### releaseGarbage

    public Date releaseGarbage()
    Allow objects that are no longer useful to become garbage.
    Returns:
      the earliest point in time at which another call will release some garbage, or null to indicate there's nothing currently stored that will become garbage in future. This value may change, each time releaseGarbage or validateNonce is called.

  - ### validateNonce

    protected Date validateNonce(byte[] nx, long timestamp) throws IOException, Crypto_TimeStampException
    Throw an exception if the nonce has been validated previously.
    Parameters:
      `nx` - the nonce to be validated
      `timestamp` - the timestamp *
    Returns:
      the earliest point in time at which a call to releaseGarbage will actually release some garbage, or null to indicate there's nothing currently stored that will become garbage in future.
    Throws:
      `Crypto_TimeStampException` - for non validated nonces
      `IOException` - if an IO error is detected
    See Also:
      - `Crypto_TimeStampException`
      - `IOException`

  - ### currentTimeMsec

    protected long currentTimeMsec()
    Get the number of milliseconds since midnight, January 1, 1970 UTC.
    Returns:
      number of milliseconds since midnight, January 1, 1970

  - ### equals

    public boolean equals(Object that)
    Overrides:
      `equals` in class `Object`