Class JwtAuthorityManagedObjectSource
java.lang.Object
net.officefloor.frame.api.managedobject.source.impl.AbstractAsyncManagedObjectSource<O,F>
net.officefloor.frame.api.managedobject.source.impl.AbstractManagedObjectSource<None,JwtAuthorityManagedObjectSource.Flows>
net.officefloor.web.jwt.authority.JwtAuthorityManagedObjectSource
- All Implemented Interfaces:
ManagedObjectSource<None,JwtAuthorityManagedObjectSource.Flows>
public class JwtAuthorityManagedObjectSource
extends AbstractManagedObjectSource<None,JwtAuthorityManagedObjectSource.Flows>
JwtAuthority ManagedObjectSource.
Key activation period is as follows:
- Access/Refresh token - expire period
- Encode access/refresh token keys - refreshed every expire period and key must be active for minimum number of expire periods
- Author:
- Daniel Sagenschneider
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumFlowkeys.protected static classTime window to determine appropriate token.Nested classes/interfaces inherited from class net.officefloor.frame.api.managedobject.source.impl.AbstractAsyncManagedObjectSource
AbstractAsyncManagedObjectSource.DependencyLabeller<K extends Enum<K>>, AbstractAsyncManagedObjectSource.ExecutionLabeller, AbstractAsyncManagedObjectSource.Labeller<K extends Enum<K>>, AbstractAsyncManagedObjectSource.MetaDataContext<O extends Enum<O>,F extends Enum<F>>, AbstractAsyncManagedObjectSource.SpecificationContext -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final longDefault expiration period forJwtAccessKey.static final longDefault expiration period for access tokens.static final StringDefaultJwtAccessKeyAsynchronousKeyFactory.static final intDefault wait time for theJwtRefreshKeyandJwtAccessKeyinstances to be available.static final longDefault expiration period forJwtRefreshKey.static final StringDefaultJwtRefreshKeyCipherFactory.static final longDefault expiration period for refresh tokens.static final StringDefaultJwtRefreshKeySynchronousKeyFactory.static final intMinimum number of overlap access token periods for heJwtAccessKeyinstances.static final intMinimum number of overlap refresh token periods for heJwtRefreshKeyinstances.static final StringPropertyname for the expiration period for theJwtAccessKey.static final StringPropertyname for number of overlap access token periods for theJwtAccessKeyinstances.static final StringPropertyname for the expiration period for access token.static final Stringstatic final Stringstatic final Stringstatic final StringPropertyname for the expiration period for theJwtRefreshKey.static final StringPropertyname for number of overlap refresh token periods for theJwtRefreshKeyinstances.static final Stringstatic final StringPropertyname for the expiration period for refresh token.static final String -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic Stringdecrypt(Key key, byte[] initVector, byte[] startSalt, byte[] laceBytes, byte[] endSalt, String cipherText, CipherFactory cipherFactory) Decrypts the value.static Stringencrypt(Key key, byte[] initVector, byte[] startSalt, byte[] laceBytes, byte[] endSalt, String value, CipherFactory cipherFactory) Encrypts the value.protected ManagedObjectSynchronously obtains theManagedObject.protected voidloadMetaData(AbstractAsyncManagedObjectSource.MetaDataContext<None, JwtAuthorityManagedObjectSource.Flows> context) Overridden to load meta-data.protected voidOverridden to load specifications.static StringrandomString(int minLength, int maxLength) Generates a random string.voidCalled once afterManagedObjectSource.init(ManagedObjectSourceContext)to indicate thisManagedObjectSourceshould start execution.Methods inherited from class net.officefloor.frame.api.managedobject.source.impl.AbstractManagedObjectSource
sourceManagedObjectMethods inherited from class net.officefloor.frame.api.managedobject.source.impl.AbstractAsyncManagedObjectSource
getSpecification, init, stop
-
Field Details
-
PROPERTY_IDENTITY_CLASS
- See Also:
-
PROPERTY_ACCESS_TOKEN_EXPIRATION_PERIOD
Propertyname for the expiration period for access token. Period measured in seconds.- See Also:
-
DEFAULT_ACCESS_TOKEN_EXPIRATION_PERIOD
public static final long DEFAULT_ACCESS_TOKEN_EXPIRATION_PERIODDefault expiration period for access tokens. -
PROPERTY_ACCESS_KEY_OVERLAP_PERIODS
Propertyname for number of overlap access token periods for theJwtAccessKeyinstances.- See Also:
-
MINIMUM_ACCESS_KEY_OVERLAP_PERIODS
public static final int MINIMUM_ACCESS_KEY_OVERLAP_PERIODSMinimum number of overlap access token periods for heJwtAccessKeyinstances.- See Also:
-
PROPERTY_ACCESS_KEY_EXPIRATION_PERIOD
Propertyname for the expiration period for theJwtAccessKey. Period measured in seconds.- See Also:
-
DEFAULT_ACCESS_KEY_EXPIRATION_PERIOD
public static final long DEFAULT_ACCESS_KEY_EXPIRATION_PERIODDefault expiration period forJwtAccessKey. -
PROPERTY_ACCESS_TOKEN_KEY_FACTORY
- See Also:
-
DEFAULT_ACCESS_TOKEN_KEY_FACTORY
DefaultJwtAccessKeyAsynchronousKeyFactory. -
PROPERTY_REFRESH_TOKEN_EXPIRATION_PERIOD
Propertyname for the expiration period for refresh token. Period measured in seconds.- See Also:
-
DEFAULT_REFRESH_TOKEN_EXPIRATION_PERIOD
public static final long DEFAULT_REFRESH_TOKEN_EXPIRATION_PERIODDefault expiration period for refresh tokens. -
PROPERTY_REFRESH_KEY_OVERLAP_PERIODS
Propertyname for number of overlap refresh token periods for theJwtRefreshKeyinstances.- See Also:
-
MINIMUM_REFRESH_KEY_OVERLAP_PERIODS
public static final int MINIMUM_REFRESH_KEY_OVERLAP_PERIODSMinimum number of overlap refresh token periods for heJwtRefreshKeyinstances.- See Also:
-
PROPERTY_REFRESH_KEY_EXPIRATION_PERIOD
Propertyname for the expiration period for theJwtRefreshKey. Period measured in seconds.- See Also:
-
DEFAULT_REFRESH_KEY_EXPIRATION_PERIOD
public static final long DEFAULT_REFRESH_KEY_EXPIRATION_PERIODDefault expiration period forJwtRefreshKey. -
PROPERTY_REFRESH_TOKEN_CIPHER_FACTORY
- See Also:
-
DEFAULT_REFRESH_TOKEN_CIPHER_FACTORY
DefaultJwtRefreshKeyCipherFactory. -
PROPERTY_REFRESH_TOKEN_KEY_FACTORY
- See Also:
-
DEFAULT_REFRESH_TOKEN_KEY_FACTORY
DefaultJwtRefreshKeySynchronousKeyFactory. -
PROPERTY_KEY_LOAD_WAIT_TIME
Propertyfor the wait time for loadingJwtRefreshKeyandJwtAccessKeyinstances. Time measured in seconds.- See Also:
-
DEFAULT_KEY_LOAD_WAIT_TIME
public static final int DEFAULT_KEY_LOAD_WAIT_TIMEDefault wait time for theJwtRefreshKeyandJwtAccessKeyinstances to be available.- See Also:
-
-
Constructor Details
-
JwtAuthorityManagedObjectSource
public JwtAuthorityManagedObjectSource()
-
-
Method Details
-
randomString
Generates a random string.- Parameters:
minLength- Minimum length of the string.maxLength- Maximum length of the string.- Returns:
- Random string.
-
encrypt
public static String encrypt(Key key, byte[] initVector, byte[] startSalt, byte[] laceBytes, byte[] endSalt, String value, CipherFactory cipherFactory) throws Exception Encrypts the value.- Parameters:
key-Key.initVector- Initialise vector.startSalt- Start salt.laceBytes- Lace.endSalt- End salt.value- Value.cipherFactory-CipherFactory.- Returns:
- Encrypted value.
- Throws:
Exception- If fails to encrypt value.
-
decrypt
public static String decrypt(Key key, byte[] initVector, byte[] startSalt, byte[] laceBytes, byte[] endSalt, String cipherText, CipherFactory cipherFactory) throws Exception Decrypts the value.- Parameters:
key-Key.initVector- Initialise vector.startSalt- Start salt.laceBytes- Lace.endSalt- End salt.cipherText- Encrypted value.cipherFactory-CipherFactory.- Returns:
- Plaintext value.
- Throws:
Exception- If fails to decrypt value.
-
loadSpecification
Description copied from class:AbstractAsyncManagedObjectSourceOverridden to load specifications.- Specified by:
loadSpecificationin classAbstractAsyncManagedObjectSource<None,JwtAuthorityManagedObjectSource.Flows> - Parameters:
context- Specifications.
-
loadMetaData
protected void loadMetaData(AbstractAsyncManagedObjectSource.MetaDataContext<None, JwtAuthorityManagedObjectSource.Flows> context) throws ExceptionDescription copied from class:AbstractAsyncManagedObjectSourceOverridden to load meta-data.- Specified by:
loadMetaDatain classAbstractAsyncManagedObjectSource<None,JwtAuthorityManagedObjectSource.Flows> - Parameters:
context- Meta-data.- Throws:
Exception- If fails to load the meta-data.
-
start
public void start(ManagedObjectExecuteContext<JwtAuthorityManagedObjectSource.Flows> context) throws Exception Description copied from interface:ManagedObjectSourceCalled once after
ManagedObjectSource.init(ManagedObjectSourceContext)to indicate thisManagedObjectSourceshould start execution.On invocation of this method,
ProcessStateinstances may be invoked via theManagedObjectExecuteContext.- Specified by:
startin interfaceManagedObjectSource<None,JwtAuthorityManagedObjectSource.Flows> - Overrides:
startin classAbstractAsyncManagedObjectSource<None,JwtAuthorityManagedObjectSource.Flows> - Parameters:
context-ManagedObjectExecuteContextto use in starting thisManagedObjectSource.- Throws:
Exception- Should theManagedObjectSourcefail to start execution.
-
getManagedObject
Description copied from class:AbstractManagedObjectSourceSynchronously obtains theManagedObject.- Specified by:
getManagedObjectin classAbstractManagedObjectSource<None,JwtAuthorityManagedObjectSource.Flows> - Returns:
ManagedObject.- Throws:
Throwable- If fails to obtain theManagedObject.
-