Class DynamicPropertyKeyJWKSource
- All Implemented Interfaces:
com.nimbusds.jose.jwk.source.JWKSource<com.nimbusds.jose.proc.SecurityContext>
JWKSource
is used by components like NimbusJwtEncoder
to obtain JWK
instances for operations.
Elsewhere, we have 'smart' dynamic key implementations such as DynamicPropertyPrivateKey
and DynamicPropertyPublicKey
whose values can change at any time. However, we need to
convert them to JWK
before they can be successfully used by JWKSource
.
Unfortunately, JWK
implementations such as RSAKey
are marked final, and therefore
we cannot introduce a 'smart' extension of them.
This represents a custom implementation of JWKSource
that will internally construct/use
JWK
instances on each method call that match the current 'latest' value in
DynamicPropertyPublicKey
/DynamicPropertyPrivateKey
.
-
Constructor Summary
ConstructorDescriptionDynamicPropertyKeyJWKSource
(int cacheSize, KeyPair dynamicPropertyKeyPair) DynamicPropertyKeyJWKSource
(KeyPair dynamicPropertyKeyPair) -
Method Summary
Modifier and TypeMethodDescriptionprotected com.nimbusds.jose.jwk.source.JWKSource<com.nimbusds.jose.proc.SecurityContext>
By default, construct a simpleRSAKey
from the key values and wrap it inImmutableJWKSet
.List<com.nimbusds.jose.jwk.JWK>
get
(com.nimbusds.jose.jwk.JWKSelector jwkSelector, com.nimbusds.jose.proc.SecurityContext context) protected Map<String,
com.nimbusds.jose.jwk.source.JWKSource<com.nimbusds.jose.proc.SecurityContext>> protected String
The dynamic keys guarantee that when we obtain values from them, they represent either the latest values from properties or the stable values that should be used for the duration of a request lifecycle (if in a request lifecycle).protected com.nimbusds.jose.jwk.source.JWKSource<com.nimbusds.jose.proc.SecurityContext>
protected KeyPair
-
Constructor Details
-
DynamicPropertyKeyJWKSource
-
DynamicPropertyKeyJWKSource
-
-
Method Details
-
getDelegate
protected com.nimbusds.jose.jwk.source.JWKSource<com.nimbusds.jose.proc.SecurityContext> getDelegate()- Returns:
- the delegate
JWKSource
to use for allJWKSource
method calls on this instance
-
getCacheKeyForKeyValues
The dynamic keys guarantee that when we obtain values from them, they represent either the latest values from properties or the stable values that should be used for the duration of a request lifecycle (if in a request lifecycle).Thus, we can safely compute the cache key in this step and assume the same values will appear in
constructJWKSourceFromKeyValues()
if in a request lifecycle.- Returns:
- a cache key comprised of the base64-encoded public and private key values
-
constructJWKSourceFromKeyValues
protected com.nimbusds.jose.jwk.source.JWKSource<com.nimbusds.jose.proc.SecurityContext> constructJWKSourceFromKeyValues()By default, construct a simpleRSAKey
from the key values and wrap it inImmutableJWKSet
.- Returns:
- a
JWKSource
based on the current key values
-
get
public List<com.nimbusds.jose.jwk.JWK> get(com.nimbusds.jose.jwk.JWKSelector jwkSelector, com.nimbusds.jose.proc.SecurityContext context) throws com.nimbusds.jose.KeySourceException - Specified by:
get
in interfacecom.nimbusds.jose.jwk.source.JWKSource<com.nimbusds.jose.proc.SecurityContext>
- Throws:
com.nimbusds.jose.KeySourceException
-
getDynamicPropertyKeyPair
-
getCachedJWKSourceByEncodedKeyPairString
-