Package net.shibboleth.shared.testing
Class EmbeddedJetty
java.lang.Object
net.shibboleth.shared.testing.EmbeddedJetty
- All Implemented Interfaces:
Closeable,AutoCloseable
Testing fixture using Jetty to server a specified handler.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classJetty handler to server content. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate List<InetAddress>Addresses to listen on.(package private) org.eclipse.jetty.server.ServerCaptures server.private intNon-TLS portprivate intTLS port -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()static ResourceReturns the TLS certificate used by the server as a resource in PEM formatstatic StringReturns the TLS server keystore password.static ResourceReturns the TLS keystore used by the server as a resource in PKCS12 formatprivate voidResolve all applicable localhost interfaces.voidsetPort(int p) Sets the non-TLS port to listen on.voidsetSecurePort(int p) Sets the TLS port to listen on.voidstartServer(org.eclipse.jetty.server.Handler handler) Starts embedded server to serve specified test content.voidStop the server if started.
-
Field Details
-
jettyListenAddrs
Addresses to listen on. -
port
private int portNon-TLS port -
securePort
private int securePortTLS port -
jettyServer
@Nullable org.eclipse.jetty.server.Server jettyServerCaptures 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
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
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException
-
getServerCertficateResource
Returns the TLS certificate used by the server as a resource in PEM format- Returns:
- TLS server certificate resource
-
getServerKeystoreResource
Returns the TLS keystore used by the server as a resource in PKCS12 format- Returns:
- TLS server keystore resource
-
getServerKeystorePassword
Returns the TLS server keystore password.- Returns:
- keystore password
-
resolveListenAddresses
Resolve all applicable localhost interfaces.- Throws:
IOException- if unable to resolve localhost address or interfaces
-