Package io.dialob.security.aws.elb
Class ElbJWKSource<C extends com.nimbusds.jose.proc.SecurityContext>
java.lang.Object
io.dialob.security.aws.elb.ElbJWKSource<C>
- All Implemented Interfaces:
com.nimbusds.jose.jwk.source.JWKSource<C>
@ThreadSafe
public class ElbJWKSource<C extends com.nimbusds.jose.proc.SecurityContext>
extends Object
implements com.nimbusds.jose.jwk.source.JWKSource<C>
Remote JSON Web Key (JWK) source specified by a JWK set URL. The retrieved
JWK set is cached to minimise network calls. The cache is updated whenever
the key selector tries to get a key with an unknown ID.
- Version:
- 2018-10-28
- Author:
- Vladimir Dzhuvinov
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intThe default HTTP connect timeout for JWK set retrieval, in milliseconds.static final intThe default HTTP read timeout for JWK set retrieval, in milliseconds.static final intThe default HTTP entity size limit for JWK set retrieval, in bytes. -
Constructor Summary
ConstructorsConstructorDescriptionElbJWKSource(String jwkSetUriTemplate) Creates a new remote JWK set using thedefault HTTP resource retriever, with a HTTP connect timeout set to 250 ms, HTTP read timeout set to 250 ms and a 50 KByte size limit.ElbJWKSource(String jwkSetUriTemplate, com.nimbusds.jose.util.ResourceRetriever resourceRetriever) Creates a new remote JWK set.ElbJWKSource(String jwkSetUriTemplate, com.nimbusds.jose.util.ResourceRetriever resourceRetriever, com.nimbusds.jose.jwk.source.JWKSetCache jwkSetCache) Creates a new remote JWK set. -
Method Summary
Modifier and TypeMethodDescriptionList<com.nimbusds.jose.jwk.JWK>The security context is ignored.com.nimbusds.jose.jwk.JWKSetReturns the cached JWK set.protected static StringgetFirstSpecifiedKeyID(com.nimbusds.jose.jwk.JWKMatcher jwkMatcher) Returns the first specified key ID (kid) for a JWK matcher.com.nimbusds.jose.jwk.source.JWKSetCacheReturns the configured JWK set cache.org.springframework.web.util.UriTemplateReturns the JWK set URL.com.nimbusds.jose.util.ResourceRetrieverReturns the HTTP resource retriever.
-
Field Details
-
DEFAULT_HTTP_CONNECT_TIMEOUT
public static final int DEFAULT_HTTP_CONNECT_TIMEOUTThe default HTTP connect timeout for JWK set retrieval, in milliseconds. Set to 500 milliseconds.- See Also:
-
DEFAULT_HTTP_READ_TIMEOUT
public static final int DEFAULT_HTTP_READ_TIMEOUTThe default HTTP read timeout for JWK set retrieval, in milliseconds. Set to 500 milliseconds.- See Also:
-
DEFAULT_HTTP_SIZE_LIMIT
public static final int DEFAULT_HTTP_SIZE_LIMITThe default HTTP entity size limit for JWK set retrieval, in bytes. Set to 50 KBytes.- See Also:
-
-
Constructor Details
-
ElbJWKSource
Creates a new remote JWK set using thedefault HTTP resource retriever, with a HTTP connect timeout set to 250 ms, HTTP read timeout set to 250 ms and a 50 KByte size limit.- Parameters:
jwkSetUriTemplate- The JWK set URL. Must not benull.
-
ElbJWKSource
public ElbJWKSource(String jwkSetUriTemplate, com.nimbusds.jose.util.ResourceRetriever resourceRetriever) Creates a new remote JWK set.- Parameters:
jwkSetUriTemplate- The JWK set URL. Must not benull.resourceRetriever- The HTTP resource retriever to use,nullto use thedefault one.
-
ElbJWKSource
public ElbJWKSource(String jwkSetUriTemplate, com.nimbusds.jose.util.ResourceRetriever resourceRetriever, com.nimbusds.jose.jwk.source.JWKSetCache jwkSetCache) Creates a new remote JWK set.- Parameters:
jwkSetUriTemplate- The JWK set URL. Must not benull.resourceRetriever- The HTTP resource retriever to use,nullto use thedefault one.jwkSetCache- The JWK set cache to use,nullto use thedefault one.
-
-
Method Details
-
getJWKSetUriTemplate
public org.springframework.web.util.UriTemplate getJWKSetUriTemplate()Returns the JWK set URL.- Returns:
- The JWK set URL.
-
getResourceRetriever
public com.nimbusds.jose.util.ResourceRetriever getResourceRetriever()Returns the HTTP resource retriever.- Returns:
- The HTTP resource retriever.
-
getJWKSetCache
public com.nimbusds.jose.jwk.source.JWKSetCache getJWKSetCache()Returns the configured JWK set cache.- Returns:
- The JWK set cache.
-
getCachedJWKSet
public com.nimbusds.jose.jwk.JWKSet getCachedJWKSet()Returns the cached JWK set.- Returns:
- The cached JWK set,
nullif none or expired.
-
getFirstSpecifiedKeyID
Returns the first specified key ID (kid) for a JWK matcher.- Parameters:
jwkMatcher- The JWK matcher. Must not benull.- Returns:
- The first key ID,
nullif none.
-
get
public List<com.nimbusds.jose.jwk.JWK> get(com.nimbusds.jose.jwk.JWKSelector jwkSelector, C context) throws com.nimbusds.jose.KeySourceException The security context is ignored.- Specified by:
getin interfacecom.nimbusds.jose.jwk.source.JWKSource<C extends com.nimbusds.jose.proc.SecurityContext>- Throws:
com.nimbusds.jose.KeySourceException
-