Search in sources :

Example 36 with SecureRequestCustomizer

use of org.eclipse.jetty.server.SecureRequestCustomizer in project spring-boot by spring-projects.

the class SslServerCustomizer method createConnector.

private ServerConnector createConnector(Server server, SslContextFactory.Server sslContextFactory, InetSocketAddress address) {
    HttpConfiguration config = new HttpConfiguration();
    config.setSendServerVersion(false);
    config.setSecureScheme("https");
    config.setSecurePort(address.getPort());
    config.addCustomizer(new SecureRequestCustomizer());
    ServerConnector connector = createServerConnector(server, sslContextFactory, config);
    connector.setPort(address.getPort());
    connector.setHost(address.getHostString());
    return connector;
}
Also used : ServerConnector(org.eclipse.jetty.server.ServerConnector) SecureRequestCustomizer(org.eclipse.jetty.server.SecureRequestCustomizer) HttpConfiguration(org.eclipse.jetty.server.HttpConfiguration)

Example 37 with SecureRequestCustomizer

use of org.eclipse.jetty.server.SecureRequestCustomizer in project rest.li by linkedin.

the class HttpsJettyServer method getConnectors.

@Override
protected Connector[] getConnectors(Server server) {
    SslContextFactory sslContextFactory = new SslContextFactory();
    sslContextFactory.setKeyStorePath(_keyStore);
    sslContextFactory.setKeyStorePassword(_keyStorePassword);
    sslContextFactory.setTrustStorePath(_keyStore);
    sslContextFactory.setTrustStorePassword(_keyStorePassword);
    HttpConfiguration configuration = new HttpConfiguration();
    configuration.addCustomizer(new SecureRequestCustomizer());
    ServerConnector sslConnector = new ServerConnector(server, sslContextFactory, new HttpConnectionFactory(configuration, HttpCompliance.RFC2616));
    sslConnector.setPort(_sslPort);
    Connector[] httpConnectors = super.getConnectors(server);
    Connector[] connectors = new Connector[httpConnectors.length + 1];
    int i = 0;
    for (Connector c : httpConnectors) {
        connectors[i++] = c;
    }
    connectors[i++] = sslConnector;
    return connectors;
}
Also used : ServerConnector(org.eclipse.jetty.server.ServerConnector) ServerConnector(org.eclipse.jetty.server.ServerConnector) Connector(org.eclipse.jetty.server.Connector) SslContextFactory(org.eclipse.jetty.util.ssl.SslContextFactory) SecureRequestCustomizer(org.eclipse.jetty.server.SecureRequestCustomizer) HttpConnectionFactory(org.eclipse.jetty.server.HttpConnectionFactory) HttpConfiguration(org.eclipse.jetty.server.HttpConfiguration)

Example 38 with SecureRequestCustomizer

use of org.eclipse.jetty.server.SecureRequestCustomizer in project Openfire by igniterealtime.

the class HttpBindManager method createSSLConnector.

private Connector createSSLConnector(final Server httpBindServer) {
    final int securePort = getHttpBindSecurePort();
    try {
        final IdentityStore identityStore = XMPPServer.getInstance().getCertificateStoreManager().getIdentityStore(ConnectionType.BOSH_C2S);
        if (securePort > 0 && identityStore.getStore().aliases().hasMoreElements()) {
            if (!identityStore.containsDomainCertificate()) {
                Log.warn("HTTP binding: Using certificates but they are not valid for the hosted domain");
            }
            final ConnectionManagerImpl connectionManager = ((ConnectionManagerImpl) XMPPServer.getInstance().getConnectionManager());
            final ConnectionConfiguration configuration = connectionManager.getListener(ConnectionType.BOSH_C2S, true).generateConnectionConfiguration();
            final SslContextFactory sslContextFactory = new EncryptionArtifactFactory(configuration).getSslContextFactory();
            final HttpConfiguration httpsConfig = new HttpConfiguration();
            httpsConfig.setSecureScheme("https");
            httpsConfig.setSecurePort(securePort);
            configureProxiedConnector(httpsConfig);
            httpsConfig.addCustomizer(new SecureRequestCustomizer());
            httpsConfig.setSendServerVersion(false);
            final ServerConnector sslConnector = new ServerConnector(httpBindServer, new SslConnectionFactory(sslContextFactory, "http/1.1"), new HttpConnectionFactory(httpsConfig));
            sslConnector.setHost(getBindInterface());
            sslConnector.setPort(securePort);
            return sslConnector;
        }
    } catch (Exception e) {
        Log.error("Error creating SSL connector for Http bind", e);
    }
    return null;
}
Also used : ServerConnector(org.eclipse.jetty.server.ServerConnector) SslContextFactory(org.eclipse.jetty.util.ssl.SslContextFactory) SecureRequestCustomizer(org.eclipse.jetty.server.SecureRequestCustomizer) HttpConnectionFactory(org.eclipse.jetty.server.HttpConnectionFactory) HttpConfiguration(org.eclipse.jetty.server.HttpConfiguration) SslConnectionFactory(org.eclipse.jetty.server.SslConnectionFactory) IdentityStore(org.jivesoftware.openfire.keystore.IdentityStore)

Example 39 with SecureRequestCustomizer

use of org.eclipse.jetty.server.SecureRequestCustomizer in project qpid-broker-j by apache.

the class HttpManagement method createConnector.

private ServerConnector createConnector(final HttpPort<?> port, final Server server) {
    port.setPortManager(this);
    if (port.getState() != State.ACTIVE) {
        // TODO - RG - probably does nothing
        port.startAsync();
    }
    HttpConnectionFactory httpConnectionFactory = new HttpConnectionFactory();
    httpConnectionFactory.getHttpConfiguration().setSendServerVersion(false);
    httpConnectionFactory.getHttpConfiguration().setSendXPoweredBy(false);
    HttpConfiguration.Customizer requestAttributeCustomizer = (connector, httpConfiguration, request) -> HttpManagementUtil.getPortAttributeAction(port).performAction(request);
    httpConnectionFactory.getHttpConfiguration().addCustomizer(requestAttributeCustomizer);
    httpConnectionFactory.getHttpConfiguration().addCustomizer(new SecureRequestCustomizer());
    ConnectionFactory[] connectionFactories;
    Collection<Transport> transports = port.getTransports();
    SslContextFactory sslContextFactory = null;
    if (!transports.contains(Transport.SSL)) {
        connectionFactories = new ConnectionFactory[] { httpConnectionFactory };
    } else if (transports.contains(Transport.SSL)) {
        sslContextFactory = createSslContextFactory(port);
        ConnectionFactory sslConnectionFactory = new SslConnectionFactory(sslContextFactory, httpConnectionFactory.getProtocol());
        if (port.getTransports().contains(Transport.TCP)) {
            sslConnectionFactory = new OptionalSslConnectionFactory((SslConnectionFactory) sslConnectionFactory, HttpVersion.HTTP_1_1.asString());
        }
        connectionFactories = new ConnectionFactory[] { sslConnectionFactory, httpConnectionFactory };
    } else {
        throw new IllegalArgumentException("Unexpected transport on port " + port.getName() + ":" + transports);
    }
    ServerConnector connector = new ServerConnector(server, new QBBTrackingThreadPool(port.getThreadPoolMaximum(), port.getThreadPoolMinimum()), null, null, port.getDesiredNumberOfAcceptors(), port.getDesiredNumberOfSelectors(), connectionFactories) {

        @Override
        public void open() throws IOException {
            try {
                super.open();
            } catch (BindException e) {
                _sslContextFactoryMap.remove(port);
                InetSocketAddress addr = getHost() == null ? new InetSocketAddress(getPort()) : new InetSocketAddress(getHost(), getPort());
                throw new PortBindFailureException(addr);
            }
        }
    };
    connector.setAcceptQueueSize(port.getAcceptBacklogSize());
    String bindingAddress = port.getBindingAddress();
    if (bindingAddress != null && !bindingAddress.trim().equals("") && !bindingAddress.trim().equals("*")) {
        connector.setHost(bindingAddress.trim());
    }
    connector.setPort(port.getPort());
    if (transports.contains(Transport.SSL)) {
        connector.addBean(new SslHandshakeListener() {

            @Override
            public void handshakeFailed(final Event event, final Throwable failure) {
                SSLEngine sslEngine = event.getSSLEngine();
                if (LOGGER.isDebugEnabled()) {
                    LOGGER.info("TLS handshake failed: host='{}', port={}", sslEngine.getPeerHost(), sslEngine.getPeerPort(), failure);
                } else {
                    LOGGER.info("TLS handshake failed: host='{}', port={}: {}", sslEngine.getPeerHost(), sslEngine.getPeerPort(), String.valueOf(failure));
                }
            }
        });
    }
    int acceptors = connector.getAcceptors();
    int selectors = connector.getSelectorManager().getSelectorCount();
    if (LOGGER.isDebugEnabled()) {
        LOGGER.debug("Created connector for http port {} with maxThreads={}, minThreads={}, acceptors={}, selectors={}, acceptBacklog={}", port.getName(), port.getThreadPoolMaximum(), port.getThreadPoolMinimum(), acceptors, selectors, port.getAcceptBacklogSize());
    }
    int requiredNumberOfConnections = acceptors + 2 * selectors + 1;
    if (port.getThreadPoolMaximum() < requiredNumberOfConnections) {
        throw new IllegalConfigurationException(String.format("Insufficient number of threads is configured on http port '%s': max=%d < needed(acceptors=%d + selectors=2*%d + request=1)", port.getName(), port.getThreadPoolMaximum(), acceptors, selectors));
    }
    if (sslContextFactory != null) {
        _sslContextFactoryMap.put(port, sslContextFactory);
    }
    return connector;
}
Also used : ServletContextHandler(org.eclipse.jetty.servlet.ServletContextHandler) PortMessages(org.apache.qpid.server.logging.messages.PortMessages) Arrays(java.util.Arrays) SSLContext(javax.net.ssl.SSLContext) ManagedAttributeField(org.apache.qpid.server.model.ManagedAttributeField) PortManager(org.apache.qpid.server.model.port.PortManager) ContentFactory(org.apache.qpid.server.plugin.ContentFactory) BrokerModel(org.apache.qpid.server.model.BrokerModel) InteractiveAuthenticationFilter(org.apache.qpid.server.management.plugin.filter.InteractiveAuthenticationFilter) ErrorHandler(org.eclipse.jetty.server.handler.ErrorHandler) VirtualHostQueryServlet(org.apache.qpid.server.management.plugin.servlet.rest.VirtualHostQueryServlet) StructureServlet(org.apache.qpid.server.management.plugin.servlet.rest.StructureServlet) Map(java.util.Map) Server(org.eclipse.jetty.server.Server) EnumSet(java.util.EnumSet) SslHandshakeListener(org.eclipse.jetty.io.ssl.SslHandshakeListener) RestServlet(org.apache.qpid.server.management.plugin.servlet.rest.RestServlet) ServletHolder(org.eclipse.jetty.servlet.ServletHolder) Set(java.util.Set) ExceptionHandlingFilter(org.apache.qpid.server.management.plugin.filter.ExceptionHandlingFilter) Transport(org.apache.qpid.server.model.Transport) StateTransition(org.apache.qpid.server.model.StateTransition) QpidServiceLoader(org.apache.qpid.server.plugin.QpidServiceLoader) KeyStore(org.apache.qpid.server.model.KeyStore) TaskExecutor(org.apache.qpid.server.configuration.updater.TaskExecutor) Joiner(com.google.common.base.Joiner) FileServlet(org.apache.qpid.server.management.plugin.servlet.FileServlet) HttpConnectionFactory(org.eclipse.jetty.server.HttpConnectionFactory) SSLParameters(javax.net.ssl.SSLParameters) MetaDataServlet(org.apache.qpid.server.management.plugin.servlet.rest.MetaDataServlet) AbstractPluginAdapter(org.apache.qpid.server.model.adapter.AbstractPluginAdapter) ArrayList(java.util.ArrayList) JsonValueServlet(org.apache.qpid.server.management.plugin.servlet.rest.JsonValueServlet) ContentServlet(org.apache.qpid.server.management.plugin.servlet.ContentServlet) SecureRequestCustomizer(org.eclipse.jetty.server.SecureRequestCustomizer) HttpServletRequest(javax.servlet.http.HttpServletRequest) HttpConfiguration(org.eclipse.jetty.server.HttpConfiguration) MethodFilter(org.apache.qpid.server.management.plugin.filter.MethodFilter) HttpPort(org.apache.qpid.server.model.port.HttpPort) NetworkConnector(org.eclipse.jetty.server.NetworkConnector) StringWriter(java.io.StringWriter) ManagedObjectFactoryConstructor(org.apache.qpid.server.model.ManagedObjectFactoryConstructor) ExecutorThreadPool(org.eclipse.jetty.util.thread.ExecutorThreadPool) IOException(java.io.IOException) ConnectionFactory(org.eclipse.jetty.server.ConnectionFactory) AuthenticationCheckFilter(org.apache.qpid.server.management.plugin.filter.AuthenticationCheckFilter) Futures(com.google.common.util.concurrent.Futures) Connection(org.eclipse.jetty.io.Connection) QpidByteBuffer(org.apache.qpid.server.bytebuffer.QpidByteBuffer) SslConnectionFactory(org.eclipse.jetty.server.SslConnectionFactory) DaemonThreadFactory(org.apache.qpid.server.util.DaemonThreadFactory) LoggerFactory(org.slf4j.LoggerFactory) SettableFuture(com.google.common.util.concurrent.SettableFuture) TrustStore(org.apache.qpid.server.model.TrustStore) FilterHolder(org.eclipse.jetty.servlet.FilterHolder) QueuedThreadPool(org.eclipse.jetty.util.thread.QueuedThreadPool) ThreadFactory(java.util.concurrent.ThreadFactory) SSLSessionContext(javax.net.ssl.SSLSessionContext) OptionalSslConnectionFactory(org.eclipse.jetty.server.OptionalSslConnectionFactory) Port(org.apache.qpid.server.model.Port) LoggingFilter(org.apache.qpid.server.management.plugin.filter.LoggingFilter) Collection(java.util.Collection) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) ScheduledThreadPoolExecutor(java.util.concurrent.ScheduledThreadPoolExecutor) RedirectFilter(org.apache.qpid.server.management.plugin.filter.RedirectFilter) MultipartConfigElement(javax.servlet.MultipartConfigElement) InetSocketAddress(java.net.InetSocketAddress) PortBindFailureException(org.apache.qpid.server.transport.PortBindFailureException) ManagedObject(org.apache.qpid.server.model.ManagedObject) List(java.util.List) TimeZoneServlet(org.apache.qpid.server.management.plugin.servlet.rest.TimeZoneServlet) Name(org.eclipse.jetty.util.annotation.Name) Writer(java.io.Writer) AuthenticationProvider(org.apache.qpid.server.model.AuthenticationProvider) LogoutServlet(org.apache.qpid.server.management.plugin.servlet.rest.LogoutServlet) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) BrokerQueryServlet(org.apache.qpid.server.management.plugin.servlet.rest.BrokerQueryServlet) ThreadPoolExecutor(java.util.concurrent.ThreadPoolExecutor) SslContextFactory(org.eclipse.jetty.util.ssl.SslContextFactory) HttpVersion(org.eclipse.jetty.http.HttpVersion) ConfiguredObject(org.apache.qpid.server.model.ConfiguredObject) BindException(java.net.BindException) ManagementConsoleMessages(org.apache.qpid.server.logging.messages.ManagementConsoleMessages) SSLEngine(javax.net.ssl.SSLEngine) HashSet(java.util.HashSet) ServerScopedRuntimeException(org.apache.qpid.server.util.ServerScopedRuntimeException) RewriteRequestForUncompressedJavascript(org.apache.qpid.server.management.plugin.filter.RewriteRequestForUncompressedJavascript) AbstractConfigurationChangeListener(org.apache.qpid.server.model.AbstractConfigurationChangeListener) CrossOriginFilter(org.eclipse.jetty.servlets.CrossOriginFilter) SaslServlet(org.apache.qpid.server.management.plugin.servlet.rest.SaslServlet) Logger(org.slf4j.Logger) IllegalConfigurationException(org.apache.qpid.server.configuration.IllegalConfigurationException) SSLUtil(org.apache.qpid.server.transport.network.security.ssl.SSLUtil) Broker(org.apache.qpid.server.model.Broker) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) State(org.apache.qpid.server.model.State) Protocol(org.apache.qpid.server.model.Protocol) QueueReportServlet(org.apache.qpid.server.management.plugin.servlet.rest.QueueReportServlet) RootServlet(org.apache.qpid.server.management.plugin.servlet.RootServlet) ServerConnector(org.eclipse.jetty.server.ServerConnector) ApiDocsServlet(org.apache.qpid.server.management.plugin.servlet.rest.ApiDocsServlet) DispatcherType(javax.servlet.DispatcherType) Collections(java.util.Collections) PortBindFailureException(org.apache.qpid.server.transport.PortBindFailureException) SslHandshakeListener(org.eclipse.jetty.io.ssl.SslHandshakeListener) InetSocketAddress(java.net.InetSocketAddress) SSLEngine(javax.net.ssl.SSLEngine) IllegalConfigurationException(org.apache.qpid.server.configuration.IllegalConfigurationException) HttpConfiguration(org.eclipse.jetty.server.HttpConfiguration) SslConnectionFactory(org.eclipse.jetty.server.SslConnectionFactory) OptionalSslConnectionFactory(org.eclipse.jetty.server.OptionalSslConnectionFactory) ServerConnector(org.eclipse.jetty.server.ServerConnector) HttpConnectionFactory(org.eclipse.jetty.server.HttpConnectionFactory) ConnectionFactory(org.eclipse.jetty.server.ConnectionFactory) SslConnectionFactory(org.eclipse.jetty.server.SslConnectionFactory) OptionalSslConnectionFactory(org.eclipse.jetty.server.OptionalSslConnectionFactory) SslContextFactory(org.eclipse.jetty.util.ssl.SslContextFactory) SecureRequestCustomizer(org.eclipse.jetty.server.SecureRequestCustomizer) HttpConnectionFactory(org.eclipse.jetty.server.HttpConnectionFactory) BindException(java.net.BindException) Transport(org.apache.qpid.server.model.Transport) OptionalSslConnectionFactory(org.eclipse.jetty.server.OptionalSslConnectionFactory)

Example 40 with SecureRequestCustomizer

use of org.eclipse.jetty.server.SecureRequestCustomizer in project scheduling by ow2-proactive.

the class JettyStarter method configureHttps.

private Connector[] configureHttps(int httpPort, int httpsPort, boolean redirectHttpToHttps, Server server, HttpConfiguration httpConfiguration) {
    Connector[] connectors;
    SslContextFactory sslContextFactory = new SslContextFactory();
    if (WebProperties.WEB_HTTPS_PROTOCOLS_INCLUDED.isSet()) {
        sslContextFactory.setIncludeProtocols(WebProperties.WEB_HTTPS_PROTOCOLS_INCLUDED.getValueAsList(",").toArray(new String[0]));
    }
    if (WebProperties.WEB_HTTPS_PROTOCOLS_EXCLUDED.isSet()) {
        sslContextFactory.setExcludeProtocols(WebProperties.WEB_HTTPS_PROTOCOLS_EXCLUDED.getValueAsList(",").toArray(new String[0]));
    }
    if (WebProperties.WEB_HTTPS_CYPHERS_INCLUDED_ADD.isSet()) {
        List<String> includedCyphers = Arrays.asList(sslContextFactory.getIncludeCipherSuites());
        includedCyphers.addAll(WebProperties.WEB_HTTPS_CYPHERS_INCLUDED_ADD.getValueAsList(","));
        sslContextFactory.setIncludeCipherSuites(includedCyphers.toArray(new String[0]));
    }
    if (WebProperties.WEB_HTTPS_CYPHERS_EXCLUDED_ADD.isSet()) {
        sslContextFactory.addExcludeCipherSuites(WebProperties.WEB_HTTPS_CYPHERS_EXCLUDED_ADD.getValueAsList(",").toArray(new String[0]));
    }
    if (WebProperties.WEB_HTTPS_RENEGOTIATION_ALLOWED.isSet()) {
        sslContextFactory.setRenegotiationAllowed(WebProperties.WEB_HTTPS_RENEGOTIATION_ALLOWED.getValueAsBoolean());
    }
    if (WebProperties.WEB_HTTPS_SECURE_RANDOM_ALGORITHM.isSet()) {
        sslContextFactory.setSecureRandomAlgorithm(WebProperties.WEB_HTTPS_SECURE_RANDOM_ALGORITHM.getValueAsString());
    }
    if (WebProperties.WEB_HTTPS_KEY_FACTORY_ALGORITHM.isSet()) {
        sslContextFactory.setSslKeyManagerFactoryAlgorithm(WebProperties.WEB_HTTPS_KEY_FACTORY_ALGORITHM.getValueAsString());
    }
    if (WebProperties.WEB_HTTPS_TRUST_FACTORY_ALGORITHM.isSet()) {
        sslContextFactory.setTrustManagerFactoryAlgorithm(WebProperties.WEB_HTTPS_TRUST_FACTORY_ALGORITHM.getValueAsString());
    }
    if (WebProperties.WEB_HTTPS_MAX_CERT_PATH.isSet()) {
        sslContextFactory.setMaxCertPathLength(WebProperties.WEB_HTTPS_MAX_CERT_PATH.getValueAsInt());
    }
    if (WebProperties.WEB_HTTPS_CERT_ALIAS.isSet()) {
        sslContextFactory.setCertAlias(WebProperties.WEB_HTTPS_CERT_ALIAS.getValueAsString());
    }
    if (WebProperties.WEB_HTTPS_ENABLE_CRLDP.isSet()) {
        sslContextFactory.setEnableCRLDP(WebProperties.WEB_HTTPS_ENABLE_CRLDP.getValueAsBoolean());
    }
    if (WebProperties.WEB_HTTPS_CRL_PATH.isSet()) {
        sslContextFactory.setCrlPath(WebProperties.WEB_HTTPS_CRL_PATH.getValueAsString());
    }
    if (WebProperties.WEB_HTTPS_ENABLE_OCSP.isSet()) {
        sslContextFactory.setEnableOCSP(WebProperties.WEB_HTTPS_ENABLE_OCSP.getValueAsBoolean());
    }
    if (WebProperties.WEB_HTTPS_OCSP_RESPONDER_URL.isSet()) {
        sslContextFactory.setOcspResponderURL(WebProperties.WEB_HTTPS_OCSP_RESPONDER_URL.getValueAsString());
    }
    if (WebProperties.WEB_HTTPS_SESSION_CACHING.isSet()) {
        sslContextFactory.setSessionCachingEnabled(WebProperties.WEB_HTTPS_SESSION_CACHING.getValueAsBoolean());
    }
    if (WebProperties.WEB_HTTPS_SESSION_CACHE_SIZE.isSet()) {
        sslContextFactory.setSslSessionCacheSize(WebProperties.WEB_HTTPS_SESSION_CACHE_SIZE.getValueAsInt());
    }
    if (WebProperties.WEB_HTTPS_SESSION_TIMEOUT.isSet()) {
        sslContextFactory.setSslSessionTimeout(WebProperties.WEB_HTTPS_SESSION_TIMEOUT.getValueAsInt());
    }
    String httpsKeystore = WebProperties.WEB_HTTPS_KEYSTORE.getValueAsStringOrNull();
    String httpsKeystorePassword = WebProperties.WEB_HTTPS_KEYSTORE_PASSWORD.getValueAsStringOrNull();
    checkPropertyNotNull(WebProperties.WEB_HTTPS_KEYSTORE.getKey(), httpsKeystore);
    checkPropertyNotNull(WebProperties.WEB_HTTPS_KEYSTORE_PASSWORD.getKey(), httpsKeystorePassword);
    sslContextFactory.setKeyStorePath(absolutePathOrRelativeToSchedulerHome(httpsKeystore));
    sslContextFactory.setKeyStorePassword(httpsKeystorePassword);
    if (WebProperties.WEB_HTTPS_TRUSTSTORE.isSet() && WebProperties.WEB_HTTPS_TRUSTSTORE_PASSWORD.isSet()) {
        String httpsTrustStore = WebProperties.WEB_HTTPS_TRUSTSTORE.getValueAsString();
        String httpsTrustStorePassword = WebProperties.WEB_HTTPS_TRUSTSTORE_PASSWORD.getValueAsString();
        sslContextFactory.setTrustStorePath(httpsTrustStore);
        sslContextFactory.setTrustStorePassword(httpsTrustStorePassword);
    }
    HttpConfiguration secureHttpConfiguration = new HttpConfiguration(httpConfiguration);
    secureHttpConfiguration.addCustomizer(new SecureRequestCustomizer());
    secureHttpConfiguration.setSecurePort(httpsPort);
    secureHttpConfiguration.setSecureScheme("https");
    secureHttpConfiguration.setSendDateHeader(false);
    secureHttpConfiguration.setSendServerVersion(false);
    // Connector to listen for HTTPS requests
    ServerConnector httpsConnector = new ServerConnector(server, new SslConnectionFactory(sslContextFactory, HttpVersion.HTTP_1_1.toString()), new HttpConnectionFactory(secureHttpConfiguration));
    httpsConnector.setName(HTTPS_CONNECTOR_NAME);
    httpsConnector.setPort(httpsPort);
    httpsConnector.setIdleTimeout(WebProperties.WEB_IDLE_TIMEOUT.getValueAsLong());
    if (redirectHttpToHttps) {
        // The next two settings allow !403 errors to be redirected to HTTPS
        httpConfiguration.setSecureScheme("https");
        httpConfiguration.setSecurePort(httpsPort);
        // Connector to listen for HTTP requests that are redirected to HTTPS
        ServerConnector httpConnector = createHttpConnector(server, httpConfiguration, httpPort);
        connectors = new Connector[] { httpConnector, httpsConnector };
    } else {
        connectors = new Connector[] { httpsConnector };
    }
    return connectors;
}
Also used : ServerConnector(org.eclipse.jetty.server.ServerConnector) ServerConnector(org.eclipse.jetty.server.ServerConnector) Connector(org.eclipse.jetty.server.Connector) SslContextFactory(org.eclipse.jetty.util.ssl.SslContextFactory) SecureRequestCustomizer(org.eclipse.jetty.server.SecureRequestCustomizer) HttpConnectionFactory(org.eclipse.jetty.server.HttpConnectionFactory) HttpConfiguration(org.eclipse.jetty.server.HttpConfiguration) SslConnectionFactory(org.eclipse.jetty.server.SslConnectionFactory)

Aggregations

SecureRequestCustomizer (org.eclipse.jetty.server.SecureRequestCustomizer)91 HttpConfiguration (org.eclipse.jetty.server.HttpConfiguration)89 ServerConnector (org.eclipse.jetty.server.ServerConnector)87 HttpConnectionFactory (org.eclipse.jetty.server.HttpConnectionFactory)85 SslConnectionFactory (org.eclipse.jetty.server.SslConnectionFactory)82 SslContextFactory (org.eclipse.jetty.util.ssl.SslContextFactory)74 Server (org.eclipse.jetty.server.Server)50 ServletContextHandler (org.eclipse.jetty.servlet.ServletContextHandler)16 QueuedThreadPool (org.eclipse.jetty.util.thread.QueuedThreadPool)16 ServletHolder (org.eclipse.jetty.servlet.ServletHolder)13 File (java.io.File)12 IOException (java.io.IOException)12 MBeanContainer (org.eclipse.jetty.jmx.MBeanContainer)10 Connector (org.eclipse.jetty.server.Connector)10 WebAppContext (org.eclipse.jetty.webapp.WebAppContext)10 ServletException (javax.servlet.ServletException)9 HTTP2ServerConnectionFactory (org.eclipse.jetty.http2.server.HTTP2ServerConnectionFactory)8 ContextHandlerCollection (org.eclipse.jetty.server.handler.ContextHandlerCollection)8 DefaultHandler (org.eclipse.jetty.server.handler.DefaultHandler)8 HttpServletRequest (javax.servlet.http.HttpServletRequest)6