Package net.officefloor.web.jwt.validate
Class JwtValidateKey
- java.lang.Object
-
- net.officefloor.web.jwt.validate.JwtValidateKey
-
- All Implemented Interfaces:
java.io.Serializable
public class JwtValidateKey extends java.lang.Object implements java.io.SerializableJWT validate key.- Author:
- Daniel Sagenschneider
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description JwtValidateKey(long startTime, long expireTime, java.security.Key key)Instantiate.JwtValidateKey(java.security.Key key)Instantiates to (effectively) never expire.JwtValidateKey(Clock<java.lang.Long> timeInSeconds, long periodToExpire, java.util.concurrent.TimeUnit unit, java.security.Key key)Instantiate to become active immediately and expire within the specified time.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description longgetExpireTime()Obtains the milliseconds since Epoch for expiry of thisJwtValidateKey.java.security.KeygetKey()Obtains theKey.longgetStartTime()Obtains the milliseconds since Epoch for when thisJwtValidateKeybecomes active.
-
-
-
Constructor Detail
-
JwtValidateKey
public JwtValidateKey(long startTime, long expireTime, java.security.Key key) throws java.lang.IllegalArgumentExceptionInstantiate.- Parameters:
startTime- Seconds since Epoch for when thisJwtValidateKeybecomes active.expireTime- Seconds since Epoch for expiry of thisJwtValidateKey.key-Keyto validate the JWT.- Throws:
java.lang.IllegalArgumentException- If invalid arguments.
-
JwtValidateKey
public JwtValidateKey(Clock<java.lang.Long> timeInSeconds, long periodToExpire, java.util.concurrent.TimeUnit unit, java.security.Key key) throws java.lang.IllegalArgumentException
Instantiate to become active immediately and expire within the specified time.- Parameters:
timeInSeconds-Clockto obtain the seconds since Epoch.periodToExpire- Period to expire theKey.unit-TimeUnitfor period.key-Keyto validate the JWT.- Throws:
java.lang.IllegalArgumentException- If invalid arguments.
-
JwtValidateKey
public JwtValidateKey(java.security.Key key) throws java.lang.IllegalArgumentExceptionInstantiates to (effectively) never expire.
This should only be used for testing. Within production environments,
Keyinstances should be rotated at a semi-regular basis to reduce impact of compromised keys.- Parameters:
key-Key.- Throws:
java.lang.IllegalArgumentException- If missingKey.
-
-
Method Detail
-
getStartTime
public long getStartTime()
Obtains the milliseconds since Epoch for when thisJwtValidateKeybecomes active.- Returns:
- Milliseconds since Epoch for when this
JwtValidateKeybecomes active.
-
getExpireTime
public long getExpireTime()
Obtains the milliseconds since Epoch for expiry of thisJwtValidateKey.- Returns:
- Milliseconds since Epoch for expiry of this
JwtValidateKey.
-
getKey
public java.security.Key getKey()
Obtains theKey.- Returns:
Keyto validate the JWT.
-
-