Class DynamicPropertyPublicKey
java.lang.Object
com.broadleafcommerce.auth.user.autoconfigure.support.keys.AbstractDynamicPropertyKey<RSAPublicKey>
com.broadleafcommerce.auth.user.autoconfigure.support.keys.DynamicPropertyPublicKey
- All Implemented Interfaces:
Serializable
,RSAKey
,RSAPublicKey
,Key
,PublicKey
public class DynamicPropertyPublicKey
extends AbstractDynamicPropertyKey<RSAPublicKey>
implements RSAPublicKey
This is a special 'smart key' bean that will always present the latest public key for
AuthenticationServices based on
AuthorizationServerProperties.OAuth2.getEncodedPublicKey()
. 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.RSAPublicKey
serialVersionUID
-
Constructor Summary
ConstructorDescriptionDynamicPropertyPublicKey
(AuthorizationServerProperties authorizationServerProperties) -
Method Summary
Modifier and TypeMethodDescriptionprotected boolean
atomicSetKeyInRequestContextIfUnset
(RSAPublicKey key, DynamicPropertyKeysRequestContext requestContext) Implementations must be atomic and only set the given key instance value in the request context if unset.protected RSAPublicKey
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.protected AuthorizationServerProperties
byte[]
protected RSAPublicKey
getExistingKeyFromRequestContext
(DynamicPropertyKeysRequestContext requestContext) protected String
AuthorizationServerProperties
will always contain the latest refreshed property value.protected org.slf4j.Logger
getLog()
Methods inherited from class com.broadleafcommerce.auth.user.autoconfigure.support.keys.AbstractDynamicPropertyKey
getDelegate, getDynamicPropertyKeysRequestContext, getOrComputeKeyFromRequestContext, getOrComputeLatestKeyFromProperties, setDynamicPropertyKeysRequestContext
-
Constructor Details
-
DynamicPropertyPublicKey
-
-
Method Details
-
getLog
protected org.slf4j.Logger getLog()- Specified by:
getLog
in classAbstractDynamicPropertyKey<RSAPublicKey>
- Returns:
- the logger that should be used for log messages
-
getExistingKeyFromRequestContext
@Nullable protected RSAPublicKey getExistingKeyFromRequestContext(DynamicPropertyKeysRequestContext requestContext) - Specified by:
getExistingKeyFromRequestContext
in classAbstractDynamicPropertyKey<RSAPublicKey>
- 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(RSAPublicKey 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<RSAPublicKey>
- 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<RSAPublicKey>
- Returns:
- the latest property value for
AuthorizationServerProperties.OAuth2.getEncodedPublicKey()
-
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<RSAPublicKey>
- Parameters:
rawKeyValue
- the raw key value to construct the instance from- Returns:
- the constructed key instance
-
getPublicExponent
- Specified by:
getPublicExponent
in interfaceRSAPublicKey
-
getAlgorithm
- Specified by:
getAlgorithm
in interfaceKey
-
getFormat
-
getEncoded
public byte[] getEncoded()- Specified by:
getEncoded
in interfaceKey
-
getModulus
- Specified by:
getModulus
in interfaceRSAKey
-
getParams
-
getAuthorizationServerProperties
-