Package anbxj

Class Crypto_TimeStampValidator

java.lang.Object
anbxj.Crypto_TimeStampValidator

public class Crypto_TimeStampValidator extends Object
A class for time stamp validation
  • 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:
    • DEFAULT_TIMESTAMP_WINDOW

      public static final long DEFAULT_TIMESTAMP_WINDOW
      The default time stamp window
      See Also:
    • 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:
    • 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