Class EmbeddedJetty

java.lang.Object
net.shibboleth.shared.testing.EmbeddedJetty
All Implemented Interfaces:
Closeable, AutoCloseable

public class EmbeddedJetty extends Object implements Closeable
Testing fixture using Jetty to server a specified handler.
  • Field Details

    • jettyListenAddrs

      private List<InetAddress> jettyListenAddrs
      Addresses to listen on.
    • port

      private int port
      Non-TLS port
    • securePort

      private int securePort
      TLS port
    • jettyServer

      @Nullable org.eclipse.jetty.server.Server jettyServer
      Captures server.
  • Constructor Details

    • EmbeddedJetty

      public EmbeddedJetty()
  • Method Details

    • setPort

      public void setPort(int p)
      Sets the non-TLS port to listen on.

      Defaults to 8080.

      Parameters:
      p - port
    • setSecurePort

      public void setSecurePort(int p)
      Sets the TLS port to listen on.

      Defaults to 8443.

      Parameters:
      p - port
    • startServer

      public void startServer(org.eclipse.jetty.server.Handler handler) throws IOException
      Starts embedded server to serve specified test content.

      The caller is expected to call stopServer() when finished.

      Parameters:
      handler - handler to install
      Throws:
      IOException - if startup fails
    • stopServer

      public void stopServer()
      Stop the server if started.
    • close

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

      @Nonnull public static Resource getServerCertficateResource()
      Returns the TLS certificate used by the server as a resource in PEM format
      Returns:
      TLS server certificate resource
    • getServerKeystoreResource

      @Nonnull public static Resource getServerKeystoreResource()
      Returns the TLS keystore used by the server as a resource in PKCS12 format
      Returns:
      TLS server keystore resource
    • getServerKeystorePassword

      @Nonnull public static String getServerKeystorePassword()
      Returns the TLS server keystore password.
      Returns:
      keystore password
    • resolveListenAddresses

      private void resolveListenAddresses() throws IOException
      Resolve all applicable localhost interfaces.
      Throws:
      IOException - if unable to resolve localhost address or interfaces