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 TypeMethodDescriptionvoidclose()static JdkJwksHandlercreate()Factory method to create a new JdkJwsHandler on a random port.Return the base URL that the JwksHandler is listening on.voidhandle(HttpExchange exchange) voidsetKeyCache(com.google.common.cache.Cache<String, AlgorithmAndKeyPair> keyCache) Set the key cache that the JwksHandler should use.voidstart()Start listening.
-
Method Details
-
setKeyCache
Description copied from interface:JwksHandlerSet 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:
setKeyCachein interfaceJwksHandler- Parameters:
keyCache- the key cache that the JwksHandler should use.
-
getBaseUrl
Description copied from interface:JwksHandlerReturn the base URL that the JwksHandler is listening on. This value may be used directly as the issuer claim in a token.- Specified by:
getBaseUrlin 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:JwksHandlerStart listening.- Specified by:
startin interfaceJwksHandler
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException
-
handle
- Specified by:
handlein interfaceHttpHandler- Throws:
IOException
-