public class ManagedWebServer
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
(package private) static class |
ManagedWebServer.InputParameters
Defines the managed web server input parameters.
|
Modifier and Type | Field and Description |
---|---|
private java.security.KeyStore |
certStore
The public key store
|
private org.eclipse.jetty.client.HttpClient |
client
The http client
|
private SSLCertFactory |
factory
The certificate factory
|
private boolean |
isReady
Indicates if the server is ready to respond on SNI requests to the subject.
|
private java.security.KeyStore |
keyStore
The private key store
|
private static long |
REQUEST_TIMEOUT
The request timeout
|
private SecureWebServer |
server
The secure web server
|
private static java.lang.String |
SERVER_ALIAS
The server alias
|
private static java.lang.String |
SERVER_CRT_FILE
The file name of the server public certificate
|
private static java.lang.String |
SERVER_KEY_FILE
The file name of the server private certificate
|
private static java.lang.String |
SERVER_STORE
The server key store
|
Constructor and Description |
---|
ManagedWebServer(java.lang.String host,
int port,
java.lang.String subject)
Starts an instance of the managed https web server that responds on SNI requests to the
subject provided by the ACME server in order to prove the ownership of this host.
|
Modifier and Type | Method and Description |
---|---|
private void |
isServerReady(org.eclipse.jetty.client.api.Response.CompleteListener callback,
long timeout)
Tests asynchronously if the target server is ready.
|
static void |
main(java.lang.String[] args)
Starts the managed web server from the given command line arguments following this pattern:
-host "127.0.0.1" -port 8888 -subject "test.acme.invalid".
|
void |
shutdown()
Stops the web server and its client.
|
boolean |
waitUntilReady(long timeout)
Waits if the server is ready or the elapsed time exceeds the given timeout until the first
event occurs.
|
private static final long REQUEST_TIMEOUT
private static final java.lang.String SERVER_KEY_FILE
private static final java.lang.String SERVER_CRT_FILE
private static final java.lang.String SERVER_ALIAS
private static final java.lang.String SERVER_STORE
private final SecureWebServer server
private final java.security.KeyStore keyStore
private final java.security.KeyStore certStore
private SSLCertFactory factory
private org.eclipse.jetty.client.HttpClient client
private boolean isReady
public ManagedWebServer(java.lang.String host, int port, java.lang.String subject) throws java.lang.Exception
host
- The host addressport
- The available host portsubject
- The provided virtual host name by ACME server in order to prove the ownership of
this host. It can be written to follow this host name pattern
"f7ea254ebdbfc4a41637cb08294f3721.772069a9f4ff4bf7cc88bc40ba9f01b2.acme.invalid".java.lang.Exception
- Iff at least one of the web server and its client is failed to start.public boolean waitUntilReady(long timeout)
timeout
- The given timeoutprivate void isServerReady(org.eclipse.jetty.client.api.Response.CompleteListener callback, long timeout)
callback
- The given callbacktimeout
- The https request timeoutpublic void shutdown() throws java.lang.Exception
java.lang.Exception
- iff the shutdown operation is failedpublic static void main(java.lang.String[] args)
args
- The provided parameters