Class JdkJwksHandler

java.lang.Object
uk.co.spudsoft.jwtvalidatorvertx.jdk.JdkJwksHandler
All Implemented Interfaces:
HttpHandler, Closeable, AutoCloseable, JwksHandler

public class JdkJwksHandler extends Object implements HttpHandler, Closeable, 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 Details

    • setKeyCache

      public void setKeyCache(com.google.common.cache.Cache<String,AlgorithmAndKeyPair> keyCache)
      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 interface JwksHandler
      Parameters:
      keyCache - the key cache that the JwksHandler should use.
    • getBaseUrl

      public String 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 interface JwksHandler
      Returns:
      the base URL that the JwksHandler is listening on.
    • create

      public static JdkJwksHandler create() throws IOException
      Factory method to create a new JdkJwsHandler on a random port. The start() 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 interface JwksHandler
    • close

      public void close() throws IOException
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Throws:
      IOException
    • handle

      public void handle(HttpExchange exchange) throws IOException
      Specified by:
      handle in interface HttpHandler
      Throws:
      IOException