use of org.apache.knox.gateway.services.security.SSLService in project knox by apache.
the class GatewayServer method createConnector.
/**
* Create a connector for Gateway Server to listen on.
*
* @param server Jetty server
* @param config GatewayConfig
* @param port If value is > 0 then the given value is used else we
* use the port provided in GatewayConfig.
* @param topologyName Connector name, only used when not null
* @return
* @throws IOException
* @throws CertificateException
* @throws NoSuchAlgorithmException
* @throws KeyStoreException
*/
private static Connector createConnector(final Server server, final GatewayConfig config, final int port, final String topologyName) throws IOException, CertificateException, NoSuchAlgorithmException, KeyStoreException {
ServerConnector connector;
// Determine the socket address and check availability.
InetSocketAddress address = config.getGatewayAddress();
checkAddressAvailability(address);
final int connectorPort = port > 0 ? port : address.getPort();
checkPortConflict(connectorPort, topologyName, config);
HttpConfiguration httpConfig = new HttpConfiguration();
httpConfig.setRequestHeaderSize(config.getHttpServerRequestHeaderBuffer());
// httpConfig.setRequestBufferSize( config.getHttpServerRequestBuffer() );
httpConfig.setResponseHeaderSize(config.getHttpServerResponseHeaderBuffer());
httpConfig.setOutputBufferSize(config.getHttpServerResponseBuffer());
if (config.isSSLEnabled()) {
HttpConfiguration httpsConfig = new HttpConfiguration(httpConfig);
httpsConfig.setSecureScheme("https");
httpsConfig.setSecurePort(connectorPort);
httpsConfig.addCustomizer(new SecureRequestCustomizer());
SSLService ssl = services.getService("SSLService");
String keystoreFileName = config.getGatewaySecurityDir() + File.separatorChar + "keystores" + File.separatorChar + "gateway.jks";
SslContextFactory sslContextFactory = (SslContextFactory) ssl.buildSslContextFactory(keystoreFileName);
connector = new ServerConnector(server, sslContextFactory, new HttpConnectionFactory(httpsConfig));
} else {
connector = new ServerConnector(server);
}
connector.setHost(address.getHostName());
connector.setPort(connectorPort);
if (!StringUtils.isBlank(topologyName)) {
connector.setName(topologyName);
}
long idleTimeout = config.getGatewayIdleTimeout();
if (idleTimeout > 0l) {
connector.setIdleTimeout(idleTimeout);
}
return connector;
}
use of org.apache.knox.gateway.services.security.SSLService in project knox by apache.
the class DefaultGatewayServices method start.
public void start() throws ServiceLifecycleException {
ms.start();
ks.start();
DefaultAliasService alias = (DefaultAliasService) services.get(ALIAS_SERVICE);
alias.start();
SSLService ssl = (SSLService) services.get(SSL_SERVICE);
ssl.start();
ServerInfoService sis = (ServerInfoService) services.get(SERVER_INFO_SERVICE);
sis.start();
RemoteConfigurationRegistryClientService clientService = (RemoteConfigurationRegistryClientService) services.get(REMOTE_REGISTRY_CLIENT_SERVICE);
clientService.start();
(services.get(CLUSTER_CONFIGURATION_MONITOR_SERVICE)).start();
DefaultTopologyService tops = (DefaultTopologyService) services.get(TOPOLOGY_SERVICE);
tops.start();
DefaultMetricsService metricsService = (DefaultMetricsService) services.get(METRICS_SERVICE);
metricsService.start();
}
use of org.apache.knox.gateway.services.security.SSLService in project knox by apache.
the class DefaultGatewayServices method stop.
public void stop() throws ServiceLifecycleException {
ms.stop();
ks.stop();
(services.get(CLUSTER_CONFIGURATION_MONITOR_SERVICE)).stop();
DefaultAliasService alias = (DefaultAliasService) services.get(ALIAS_SERVICE);
alias.stop();
SSLService ssl = (SSLService) services.get(SSL_SERVICE);
ssl.stop();
ServerInfoService sis = (ServerInfoService) services.get(SERVER_INFO_SERVICE);
sis.stop();
DefaultTopologyService tops = (DefaultTopologyService) services.get(TOPOLOGY_SERVICE);
tops.stop();
DefaultMetricsService metricsService = (DefaultMetricsService) services.get(METRICS_SERVICE);
metricsService.stop();
}
Aggregations