Class JdkJwksHandler
java.lang.Object
uk.co.spudsoft.jwtvalidatorvertx.jdk.JdkJwksHandler
- All Implemented Interfaces:
HttpHandler
,Closeable
,AutoCloseable
,JwksHandler
An implementation of JwksHandler as a JDK HttpHandler.
This provides the simplest (and easiest to deploy) implementation of JwksHandler, but it is not very compatible with a Vertx application.
- Author:
- jtalbut
-
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
static JdkJwksHandler
create()
Factory method to create a new JdkJwsHandler on a random port.Return the base URL that the JwksHandler is listening on.void
handle
(HttpExchange exchange) void
setKeyCache
(com.google.common.cache.Cache<String, AlgorithmAndKeyPair> keyCache) Set the key cache that the JwksHandler should use.void
start()
Start listening.
-
Method Details
-
setKeyCache
Description copied from interface:JwksHandler
Set the key cache that the JwksHandler should use. In production use this method should be called once, in a test environment it may be called repeatedly. A JwksHandler must only access the keyCache (or anything derived from it) whilst serving an HTTP request. Between requests the JwkHandler may only hold a reference to the keyCache.- Specified by:
setKeyCache
in interfaceJwksHandler
- Parameters:
keyCache
- the key cache that the JwksHandler should use.
-
getBaseUrl
Description copied from interface:JwksHandler
Return the base URL that the JwksHandler is listening on. This value may be used directly as the issuer claim in a token.- Specified by:
getBaseUrl
in interfaceJwksHandler
- Returns:
- the base URL that the JwksHandler is listening on.
-
create
Factory method to create a new JdkJwsHandler on a random port. Thestart()
method must still be called on the returned object.- Returns:
- A newly created (but not yet active) JdkJwsHandler.
- Throws:
IOException
- If the server cannot be created or started.
-
start
public void start()Description copied from interface:JwksHandler
Start listening.- Specified by:
start
in interfaceJwksHandler
-
close
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Throws:
IOException
-
handle
- Specified by:
handle
in interfaceHttpHandler
- Throws:
IOException
-