Class DynamicPropertyPrivateKey
java.lang.Object
com.broadleafcommerce.auth.user.autoconfigure.support.keys.AbstractDynamicPropertyKey<RSAPrivateKey>
com.broadleafcommerce.auth.user.autoconfigure.support.keys.DynamicPropertyPrivateKey
- All Implemented Interfaces:
Serializable,RSAKey,RSAPrivateKey,Key,PrivateKey,Destroyable
public class DynamicPropertyPrivateKey
extends AbstractDynamicPropertyKey<RSAPrivateKey>
implements RSAPrivateKey
This is a special 'smart key' bean that will always present the latest private key for
AuthenticationServices based on
AuthorizationServerProperties.OAuth2.getEncodedPrivateKey(). The only exception is when
this key is used multiple times in a request lifecycle - in that case, the 'latest' value is
computed in the first use of this key, and then that value is used for the remainder of that
request's lifecycle.-
Field Summary
Fields inherited from interface java.security.interfaces.RSAPrivateKey
serialVersionUID -
Constructor Summary
ConstructorsConstructorDescriptionDynamicPropertyPrivateKey(AuthorizationServerProperties authorizationServerProperties) -
Method Summary
Modifier and TypeMethodDescriptionprotected booleanatomicSetKeyInRequestContextIfUnset(RSAPrivateKey key, DynamicPropertyKeysRequestContext requestContext) Implementations must be atomic and only set the given key instance value in the request context if unset.protected RSAPrivateKeyconstructKeyInstance(String rawKeyValue) Note - if this implementation changes, it's important to also ensure the interface declared at the top of this class is made as specific as possible to match.voiddestroy()protected AuthorizationServerPropertiesbyte[]protected RSAPrivateKeygetExistingKeyFromRequestContext(DynamicPropertyKeysRequestContext requestContext) protected StringAuthorizationServerPropertieswill always contain the latest refreshed property value.protected org.slf4j.LoggergetLog()booleanMethods inherited from class com.broadleafcommerce.auth.user.autoconfigure.support.keys.AbstractDynamicPropertyKey
getDelegate, getDynamicPropertyKeysRequestContext, getOrComputeKeyFromRequestContext, getOrComputeLatestKeyFromProperties, setDynamicPropertyKeysRequestContext
-
Constructor Details
-
DynamicPropertyPrivateKey
-
-
Method Details
-
getLog
protected org.slf4j.Logger getLog()- Specified by:
getLogin classAbstractDynamicPropertyKey<RSAPrivateKey>- Returns:
- the logger that should be used for log messages
-
getExistingKeyFromRequestContext
@Nullable protected RSAPrivateKey getExistingKeyFromRequestContext(DynamicPropertyKeysRequestContext requestContext) - Specified by:
getExistingKeyFromRequestContextin classAbstractDynamicPropertyKey<RSAPrivateKey>- Parameters:
requestContext- the request context from which to get the existing key instance- Returns:
- the existing key instance in the request context, or
nullif none is set
-
atomicSetKeyInRequestContextIfUnset
protected boolean atomicSetKeyInRequestContextIfUnset(RSAPrivateKey key, DynamicPropertyKeysRequestContext requestContext) Description copied from class:AbstractDynamicPropertyKeyImplementations must be atomic and only set the given key instance value in the request context if unset.Recommended to use
AtomicReference.compareAndSet(Object, Object)semantics.- Specified by:
atomicSetKeyInRequestContextIfUnsetin classAbstractDynamicPropertyKey<RSAPrivateKey>- Parameters:
key- the key value to set in the request contextrequestContext- the request context in which to set the value- Returns:
- true if the update succeeded (only set if unset), false otherwise
-
getLatestPropertyValueForKey
AuthorizationServerPropertieswill always contain the latest refreshed property value.- Specified by:
getLatestPropertyValueForKeyin classAbstractDynamicPropertyKey<RSAPrivateKey>- Returns:
- the latest property value for
AuthorizationServerProperties.OAuth2.getEncodedPrivateKey()
-
constructKeyInstance
Note - if this implementation changes, it's important to also ensure the interface declared at the top of this class is made as specific as possible to match. This ensures things likeinstanceofchecks against this class (ex: such as those done inRSAKey) will go through the right code flows based on the specific interface type.- Specified by:
constructKeyInstancein classAbstractDynamicPropertyKey<RSAPrivateKey>- Parameters:
rawKeyValue- the raw key value to construct the instance from- Returns:
- the constructed key instance
-
getPrivateExponent
- Specified by:
getPrivateExponentin interfaceRSAPrivateKey
-
getAlgorithm
- Specified by:
getAlgorithmin interfaceKey
-
getFormat
-
getEncoded
public byte[] getEncoded()- Specified by:
getEncodedin interfaceKey
-
getModulus
- Specified by:
getModulusin interfaceRSAKey
-
getParams
-
destroy
- Specified by:
destroyin interfaceDestroyable- Throws:
DestroyFailedException
-
isDestroyed
public boolean isDestroyed()- Specified by:
isDestroyedin interfaceDestroyable
-
getAuthorizationServerProperties
-