APIdia Launch Partner
Top Description Fields Constructors Methods
com.sun.net.httpserver

public Class HttpsConfigurator

extends Object
Class Inheritance
Imports
javax.net.ssl.SSLContext, .SSLParameters

This class is used to configure the https parameters for each incoming https connection on a HttpsServer. Applications need to override the configure(HttpsParameters) method in order to change the default configuration.

The following example shows how this may be done:

SSLContext sslContext = SSLContext.getInstance(....);
HttpsServer server = HttpsServer.create();

server.setHttpsConfigurator(new HttpsConfigurator(sslContext) {
    public void configure(HttpsParameters params) {

        // get the remote address if needed
        InetSocketAddress remote = params.getClientAddress();

        SSLContext c = getSSLContext();

        // get the default parameters
        SSLParameters sslparams = c.getDefaultSSLParameters();
        if (remote.equals(...)) {
            // modify the default set for client x
        }

        params.setSSLParameters(sslparams);
    }
});
Since
1.6

Field Summary

Modifier and TypeField and Description
private SSLContext

Constructor Summary

AccessConstructor and Description
public
HttpsConfigurator(SSLContext
the SSLContext to use for this configurator
context
)

Creates a Https configuration, with the given SSLContext.

Method Summary

Modifier and TypeMethod and Description
public void
configure(HttpsParameters
the HttpsParameters to be configured
params
)

Called by the HttpsServer to configure the parameters for a https connection currently being established.

public SSLContext

Returns:

the SSLContext
getSSLContext
()

Returns the SSLContext for this HttpsConfigurator.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

contextback to summary
private SSLContext context

Constructor Detail

HttpsConfiguratorback to summary
public HttpsConfigurator(SSLContext context)

Creates a Https configuration, with the given SSLContext.

Parameters
context:SSLContext

the SSLContext to use for this configurator

Exceptions
NullPointerException:
if no SSLContext supplied

Method Detail

configureback to summary
public void configure(HttpsParameters params)

Called by the HttpsServer to configure the parameters for a https connection currently being established. The implementation of configure() must call HttpsParameters#setSSLParameters(SSLParameters) in order to set the SSL parameters for the connection.

The default implementation of this method uses the SSLParameters returned from:

getSSLContext().getDefaultSSLParameters()

configure() may be overridden in order to modify this behavior. See example above.

Parameters
params:HttpsParameters

the HttpsParameters to be configured

Since
1.6
getSSLContextback to summary
public SSLContext getSSLContext()

Returns the SSLContext for this HttpsConfigurator.

Returns:SSLContext

the SSLContext