Package net.shibboleth.shared.testing

# Class EmbeddedJetty

java.lang.Object
net.shibboleth.shared.testing.EmbeddedJetty

public class EmbeddedJetty extends Object
Testing fixture using Jetty to server a specified handler.

## Nested Class Summary

Nested Classes
Modifier and Type
Class
Description
`static class`
`EmbeddedJetty.ResourceHandler`
Jetty handler to server content.

## Field Summary

Fields
Modifier and Type
Field
Description
`private List<InetAddress>`
`jettyListenAddrs`
Addresses to listen on.
`(package private) org.eclipse.jetty.server.Server`
`jettyServer`
Captures server.
`private int`
`port`
TLS port

## Constructor Summary

Constructors
Constructor
Description
`EmbeddedJetty()`

## Method Summary

Modifier and Type
Method
Description
`static Resource`
`getServerCertficateResource()`
Returns the TLS certificate used by the server as a resource in PEM format
`private void`
`resolveListenAddresses()`
Resolve all applicable localhost interfaces.
`void`
`setPort(int p)`
Sets the TLS port to listen on.
`void`
`startServer(org.eclipse.jetty.server.Handler handler)`
Starts embedded server to serve specified test content.
`void`
`stopServer()`
Stop the server if started.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Field Details

### jettyListenAddrs

private List<InetAddress> jettyListenAddrs
Addresses to listen on.

### port

private int port
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 TLS port to listen on.

Defaults to 8443.

Parameters:
  `p` - port

### startServer

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

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

Parameters:
  `handler` -
Throws:
  `UnknownHostException`
  `SocketException`

### stopServer

public void stopServer()
Stop the server if started.

### 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

### resolveListenAddresses

private void resolveListenAddresses() throws UnknownHostException, SocketException
Resolve all applicable localhost interfaces.

Throws:
  `UnknownHostException`
  `SocketException`