use of org.eclipse.jetty.server.ConnectionFactory in project cxf by apache.
the class JettyHTTPServerEngine method createConnectorJetty.
AbstractConnector createConnectorJetty(SslContextFactory sslcf, String hosto, int porto, int major, int minor) {
AbstractConnector result = null;
try {
HttpConfiguration httpConfig = new HttpConfiguration();
httpConfig.setSendServerVersion(getSendServerVersion());
HttpConnectionFactory httpFactory = new HttpConnectionFactory(httpConfig);
Collection<ConnectionFactory> connectionFactories = new ArrayList<>();
result = new org.eclipse.jetty.server.ServerConnector(server);
if (tlsServerParameters != null) {
httpConfig.addCustomizer(new org.eclipse.jetty.server.SecureRequestCustomizer());
SslConnectionFactory scf = new SslConnectionFactory(sslcf, "HTTP/1.1");
connectionFactories.add(scf);
String proto = (major > 9 || (major == 9 && minor >= 3)) ? "SSL" : "SSL-HTTP/1.1";
result.setDefaultProtocol(proto);
}
connectionFactories.add(httpFactory);
result.setConnectionFactories(connectionFactories);
if (getMaxIdleTime() > 0) {
result.setIdleTimeout(Long.valueOf(getMaxIdleTime()));
}
} catch (RuntimeException rex) {
throw rex;
} catch (Exception ex) {
throw new RuntimeException(ex);
}
return result;
}
use of org.eclipse.jetty.server.ConnectionFactory in project steve by RWTH-i5-IDSG.
the class JettyServer method getConnectorPath.
private static String getConnectorPath(Connector c) {
ServerConnector sc = (ServerConnector) c;
String prefix = "http";
String host = sc.getHost();
int port = sc.getPort();
ConnectionFactory cf = sc.getDefaultConnectionFactory();
if (cf instanceof SslConnectionFactory) {
prefix = "https";
}
if (host == null || host.equals("0.0.0.0")) {
try {
host = InetAddress.getLocalHost().getHostAddress();
} catch (UnknownHostException e) {
// Well, we failed to read from system, fall back to main.properties.
// Better than nothing
host = CONFIG.getJetty().getServerHost();
}
}
String layout = "%s://%s:%d" + CONFIG.getContextPath();
return String.format(layout, prefix, host, port);
}
use of org.eclipse.jetty.server.ConnectionFactory in project zookeeper by apache.
the class UnifiedConnectionFactory method newConnection.
@Override
public Connection newConnection(Connector connector, EndPoint realEndPoint) {
ReadAheadEndpoint aheadEndpoint = new ReadAheadEndpoint(realEndPoint, 1);
byte[] bytes = aheadEndpoint.getBytes();
boolean isSSL;
if (bytes == null || bytes.length == 0) {
isSSL = false;
LOG.warn("Incoming connection has no data");
} else {
// TLS first byte is 0x16, let's not support SSLv3 and below
byte b = bytes[0];
// matches SSL detection in NettyServerCnxnFactory.java
isSSL = b == 0x16;
}
LOG.debug(String.format("UnifiedConnectionFactory: newConnection() with SSL = %b", isSSL));
EndPoint plainEndpoint;
SslConnection sslConnection;
if (isSSL) {
SSLEngine engine = this.sslContextFactory.newSSLEngine(aheadEndpoint.getRemoteAddress());
engine.setUseClientMode(false);
sslConnection = this.newSslConnection(connector, aheadEndpoint, engine);
sslConnection.setRenegotiationAllowed(this.sslContextFactory.isRenegotiationAllowed());
this.configure(sslConnection, connector, aheadEndpoint);
plainEndpoint = sslConnection.getDecryptedEndPoint();
} else {
sslConnection = null;
plainEndpoint = aheadEndpoint;
ServerMetrics.getMetrics().INSECURE_ADMIN.add(1);
}
ConnectionFactory next = connector.getConnectionFactory(nextProtocol);
Connection connection = next.newConnection(connector, plainEndpoint);
plainEndpoint.setConnection(connection);
return (sslConnection == null) ? connection : sslConnection;
}
use of org.eclipse.jetty.server.ConnectionFactory in project spring-boot by spring-projects.
the class JettyServletWebServerFactory method createConnector.
private AbstractConnector createConnector(InetSocketAddress address, Server server) {
HttpConfiguration httpConfiguration = new HttpConfiguration();
httpConfiguration.setSendServerVersion(false);
List<ConnectionFactory> connectionFactories = new ArrayList<>();
connectionFactories.add(new HttpConnectionFactory(httpConfiguration));
if (getHttp2() != null && getHttp2().isEnabled()) {
connectionFactories.add(new HTTP2CServerConnectionFactory(httpConfiguration));
}
ServerConnector connector = new ServerConnector(server, this.acceptors, this.selectors, connectionFactories.toArray(new ConnectionFactory[0]));
connector.setHost(address.getHostString());
connector.setPort(address.getPort());
return connector;
}
use of org.eclipse.jetty.server.ConnectionFactory in project spring-boot by spring-projects.
the class JettyReactiveWebServerFactory method createConnector.
private AbstractConnector createConnector(InetSocketAddress address, Server server) {
HttpConfiguration httpConfiguration = new HttpConfiguration();
httpConfiguration.setSendServerVersion(false);
List<ConnectionFactory> connectionFactories = new ArrayList<>();
connectionFactories.add(new HttpConnectionFactory(httpConfiguration));
if (getHttp2() != null && getHttp2().isEnabled()) {
connectionFactories.add(new HTTP2CServerConnectionFactory(httpConfiguration));
}
JettyResourceFactory resourceFactory = getResourceFactory();
ServerConnector connector;
if (resourceFactory != null) {
connector = new ServerConnector(server, resourceFactory.getExecutor(), resourceFactory.getScheduler(), resourceFactory.getByteBufferPool(), this.acceptors, this.selectors, connectionFactories.toArray(new ConnectionFactory[0]));
} else {
connector = new ServerConnector(server, this.acceptors, this.selectors, connectionFactories.toArray(new ConnectionFactory[0]));
}
connector.setHost(address.getHostString());
connector.setPort(address.getPort());
return connector;
}
Aggregations