* @return A new internal Jetty connector.
*/
@Override
protected AbstractConnector createConnector() {
AbstractConnector result = null;
final SslContextFactory sslContextFactory = HttpsUtils
.getSslContextFactory(this);
final String[] excludedCipherSuites = HttpsUtils
.getDisabledCipherSuites(this);
// Create and configure the Jetty HTTP connector
switch (getType()) {
case 1:
// Selecting NIO connector
/*
* If an SslContextFactory has been set up, its settings take
* priority over the other parameters (which would otherwise be used
* to build and initialise an SSLContext internally). Jetty's
* SslSelectChannelConnector does not have a setSslContext method
* yet, so we override its createSSLContext() method for this
* purpose.
*/
SslSelectChannelConnector nioResult;
if (sslContextFactory == null) {
nioResult = new SslSelectChannelConnector();
nioResult.setKeyPassword(getKeyPassword());
nioResult.setKeystore(getKeystorePath());
nioResult.setKeystoreType(getKeystoreType());
nioResult.setPassword(getKeystorePassword());
nioResult.setProtocol(getSslProtocol());
nioResult.setProvider(getSecurityProvider());
nioResult.setSecureRandomAlgorithm(getSecureRandomAlgorithm());
nioResult.setSslKeyManagerFactoryAlgorithm(getCertAlgorithm());
nioResult
.setSslTrustManagerFactoryAlgorithm(getCertAlgorithm());
nioResult.setTrustPassword(getKeystorePassword());
} else {
nioResult = new SslSelectChannelConnector() {
@Override
protected SSLContext createSSLContext() throws Exception {
return sslContextFactory.createSslContext();
}
};
}
if (isNeedClientAuthentication()) {
nioResult.setNeedClientAuth(true);
} else if (isWantClientAuthentication()) {
nioResult.setWantClientAuth(true);
}
if (excludedCipherSuites != null) {
nioResult.setExcludeCipherSuites(excludedCipherSuites);
}
result = nioResult;
break;
case 2:
// Blocking BIO connector
/*
* If an SslContextFactory has been set up, its settings take
* priority over the other parameters (which would otherwise be used
* to build and initialise an SSLContext internally). Jetty's
* SslSocketConnector does not have a setSslContext method yet, so
* we override its createFactory() method for this purpose.
*/
SslSocketConnector bioResult;
if (sslContextFactory == null) {
bioResult = new SslSocketConnector();
bioResult.setKeyPassword(getKeyPassword());
bioResult.setKeystore(getKeystorePath());
bioResult.setKeystoreType(getKeystoreType());
bioResult.setPassword(getKeystorePassword());
bioResult.setProtocol(getSslProtocol());
bioResult.setProvider(getSecurityProvider());
bioResult.setSecureRandomAlgorithm(getSecureRandomAlgorithm());
bioResult.setSslKeyManagerFactoryAlgorithm(getCertAlgorithm());
bioResult
.setSslTrustManagerFactoryAlgorithm(getCertAlgorithm());
bioResult.setTrustPassword(getKeystorePassword());
} else {
bioResult = new SslSocketConnector() {
@Override
protected SSLServerSocketFactory createFactory()
throws Exception {
final SSLContext sslContext = sslContextFactory
.createSslContext();
return sslContext.getServerSocketFactory();
}
};