Package anbxj
Class Crypto_TimeStampValidator
java.lang.Object
anbxj.Crypto_TimeStampValidator
A class for time stamp validation
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final long
The default maximum age of time stamps is 15 minutes.static final long
The default time stamp windowprotected final long
Tha maximum timestamp age in ms -
Constructor Summary
ConstructorsConstructorDescriptionConstruct a validator that rejects messages more than five minutes oldCrypto_TimeStampValidator
(long maxTimestampAgeMsec) Public constructor. -
Method Summary
Modifier and TypeMethodDescriptionprotected long
Get the number of milliseconds since midnight, January 1, 1970 UTC.boolean
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.
-
Field Details
-
DEFAULT_MAX_TIMESTAMP_AGE
public static final long DEFAULT_MAX_TIMESTAMP_AGEThe default maximum age of time stamps is 15 minutes.- See Also:
-
DEFAULT_TIMESTAMP_WINDOW
public static final long DEFAULT_TIMESTAMP_WINDOWThe default time stamp window- See Also:
-
maxTimestampAgeMsec
protected final long maxTimestampAgeMsecTha 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
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 validatedtimestamp
- 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 noncesIOException
- 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
-