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
ConstructorDescriptionDynamicPropertyPrivateKey
(AuthorizationServerProperties authorizationServerProperties) -
Method Summary
Modifier and TypeMethodDescriptionprotected boolean
atomicSetKeyInRequestContextIfUnset
(RSAPrivateKey key, DynamicPropertyKeysRequestContext requestContext) Implementations must be atomic and only set the given key instance value in the request context if unset.protected RSAPrivateKey
constructKeyInstance
(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.void
destroy()
protected AuthorizationServerProperties
byte[]
protected RSAPrivateKey
getExistingKeyFromRequestContext
(DynamicPropertyKeysRequestContext requestContext) protected String
AuthorizationServerProperties
will always contain the latest refreshed property value.protected org.slf4j.Logger
getLog()
boolean
Methods 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:
getLog
in classAbstractDynamicPropertyKey<RSAPrivateKey>
- Returns:
- the logger that should be used for log messages
-
getExistingKeyFromRequestContext
@Nullable protected RSAPrivateKey getExistingKeyFromRequestContext(DynamicPropertyKeysRequestContext requestContext) - Specified by:
getExistingKeyFromRequestContext
in 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
null
if none is set
-
atomicSetKeyInRequestContextIfUnset
protected boolean atomicSetKeyInRequestContextIfUnset(RSAPrivateKey key, DynamicPropertyKeysRequestContext requestContext) Description copied from class:AbstractDynamicPropertyKey
Implementations 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:
atomicSetKeyInRequestContextIfUnset
in 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
AuthorizationServerProperties
will always contain the latest refreshed property value.- Specified by:
getLatestPropertyValueForKey
in 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 likeinstanceof
checks against this class (ex: such as those done inRSAKey
) will go through the right code flows based on the specific interface type.- Specified by:
constructKeyInstance
in classAbstractDynamicPropertyKey<RSAPrivateKey>
- Parameters:
rawKeyValue
- the raw key value to construct the instance from- Returns:
- the constructed key instance
-
getPrivateExponent
- Specified by:
getPrivateExponent
in interfaceRSAPrivateKey
-
getAlgorithm
- Specified by:
getAlgorithm
in interfaceKey
-
getFormat
-
getEncoded
public byte[] getEncoded()- Specified by:
getEncoded
in interfaceKey
-
getModulus
- Specified by:
getModulus
in interfaceRSAKey
-
getParams
-
destroy
- Specified by:
destroy
in interfaceDestroyable
- Throws:
DestroyFailedException
-
isDestroyed
public boolean isDestroyed()- Specified by:
isDestroyed
in interfaceDestroyable
-
getAuthorizationServerProperties
-