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.Serializable
JWT 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 long
getExpireTime()
Obtains the milliseconds since Epoch for expiry of thisJwtValidateKey
.java.security.Key
getKey()
Obtains theKey
.long
getStartTime()
Obtains the milliseconds since Epoch for when thisJwtValidateKey
becomes active.
-
-
-
Constructor Detail
-
JwtValidateKey
public JwtValidateKey(long startTime, long expireTime, java.security.Key key) throws java.lang.IllegalArgumentException
Instantiate.- Parameters:
startTime
- Seconds since Epoch for when thisJwtValidateKey
becomes active.expireTime
- Seconds since Epoch for expiry of thisJwtValidateKey
.key
-Key
to 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
-Clock
to obtain the seconds since Epoch.periodToExpire
- Period to expire theKey
.unit
-TimeUnit
for period.key
-Key
to validate the JWT.- Throws:
java.lang.IllegalArgumentException
- If invalid arguments.
-
JwtValidateKey
public JwtValidateKey(java.security.Key key) throws java.lang.IllegalArgumentException
Instantiates to (effectively) never expire.
This should only be used for testing. Within production environments,
Key
instances 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 thisJwtValidateKey
becomes active.- Returns:
- Milliseconds since Epoch for when this
JwtValidateKey
becomes 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:
Key
to validate the JWT.
-
-