當前位置: 首頁>>代碼示例>>Java>>正文


Java HttpConfiguration.addCustomizer方法代碼示例

本文整理匯總了Java中org.eclipse.jetty.server.HttpConfiguration.addCustomizer方法的典型用法代碼示例。如果您正苦於以下問題:Java HttpConfiguration.addCustomizer方法的具體用法?Java HttpConfiguration.addCustomizer怎麽用?Java HttpConfiguration.addCustomizer使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.eclipse.jetty.server.HttpConfiguration的用法示例。


在下文中一共展示了HttpConfiguration.addCustomizer方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: customize

import org.eclipse.jetty.server.HttpConfiguration; //導入方法依賴的package包/類
@Override
public void customize(Server server) {
    // HTTPS Configuration
    HttpConfiguration httpsConfig = new HttpConfiguration();
    httpsConfig.setSecureScheme("https");
    httpsConfig.setSecurePort(8443);
    httpsConfig.addCustomizer(new SecureRequestCustomizer());

    // SSL Context Factory for HTTPS and HTTP/2
    SslContextFactory sslContextFactory = new SslContextFactory();
    sslContextFactory.setKeyStoreResource(newClassPathResource("keystore"));
    sslContextFactory.setKeyStorePassword("OBF:1vny1zlo1x8e1vnw1vn61x8g1zlu1vn4");
    sslContextFactory.setKeyManagerPassword("OBF:1u2u1wml1z7s1z7a1wnl1u2g");
    sslContextFactory.setCipherComparator(HTTP2Cipher.COMPARATOR);

    // SSL Connection Factory
    SslConnectionFactory ssl = new SslConnectionFactory(sslContextFactory, "h2");

    // HTTP/2 Connector
    ServerConnector http2Connector = new ServerConnector(server, ssl, new HTTP2ServerConnectionFactory(httpsConfig));
    http2Connector.setPort(8443);
    server.addConnector(http2Connector);
}
 
開發者ID:thinline72,項目名稱:rpc-example,代碼行數:24,代碼來源:JettyHttp2ServerConfig.java

示例2: createConnector

import org.eclipse.jetty.server.HttpConfiguration; //導入方法依賴的package包/類
/**
 * Creates a server connector.
 *
 * If an HTTPS key store is configured, returns a SSL connector for HTTPS.
 *
 * Otherwise, returns a normal HTTP connector by default.
 *
 * @param server The server.
 * @return The server connector.
 */
@SuppressWarnings("squid:S2095")
private ServerConnector createConnector(final Server server) {
    final String keyStorePath = (String) configuration.get(MinijaxProperties.SSL_KEY_STORE_PATH);

    if (keyStorePath == null || keyStorePath.isEmpty()) {
        // Normal HTTP
        return new ServerConnector(server);
    }

    final String keyStorePassword = (String) configuration.get(MinijaxProperties.SSL_KEY_STORE_PASSWORD);
    final String keyManagerPassword = (String) configuration.get(MinijaxProperties.SSL_KEY_MANAGER_PASSWORD);

    final HttpConfiguration https = new HttpConfiguration();
    https.addCustomizer(new SecureRequestCustomizer());

    final SslContextFactory sslContextFactory = new SslContextFactory();
    sslContextFactory.setKeyStorePath(Minijax.class.getClassLoader().getResource(keyStorePath).toExternalForm());
    sslContextFactory.setKeyStorePassword(keyStorePassword);
    sslContextFactory.setKeyManagerPassword(keyManagerPassword);

    return new ServerConnector(server,
            new SslConnectionFactory(sslContextFactory, "http/1.1"),
            new HttpConnectionFactory(https));
}
 
開發者ID:minijax,項目名稱:minijax,代碼行數:35,代碼來源:Minijax.java

示例3: setupSSL

import org.eclipse.jetty.server.HttpConfiguration; //導入方法依賴的package包/類
private void setupSSL(Server server,HttpConfiguration http_config) {
	SslContextFactory sslContextFactory = new SslContextFactory();
	
	if (sslKeyStoreFile!=null)
		sslContextFactory.setKeyStorePath(sslKeyStoreFile);
	else if (sslKeyStore!=null)
		sslContextFactory.setKeyStore(sslKeyStore);
	else {
		log.log(Level.SEVERE,"Error while configuring SSL connection. Missing KeyStore!");
		return;
	}
	sslContextFactory.setKeyStorePassword(new String(sslKeyStorePassword));
	sslContextFactory.setExcludeCipherSuites("SSL_RSA_WITH_DES_CBC_SHA",
			"SSL_DHE_RSA_WITH_DES_CBC_SHA", "SSL_DHE_DSS_WITH_DES_CBC_SHA",
			"SSL_RSA_EXPORT_WITH_RC4_40_MD5",
			"SSL_RSA_EXPORT_WITH_DES40_CBC_SHA",
			"SSL_DHE_RSA_EXPORT_WITH_DES40_CBC_SHA",
			"SSL_DHE_DSS_EXPORT_WITH_DES40_CBC_SHA");
	HttpConfiguration https_config = new HttpConfiguration(http_config);
	https_config.addCustomizer(new SecureRequestCustomizer());
	ServerConnector sslConnector = new ServerConnector(server,
		new SslConnectionFactory(sslContextFactory,HttpVersion.HTTP_1_1.asString()),
		new HttpConnectionFactory(https_config));
	sslConnector.setPort(daemonPortSecure);
	server.addConnector(sslConnector);
}
 
開發者ID:gustavohbf,項目名稱:robotoy,代碼行數:27,代碼來源:WebServer.java

示例4: addHttpsConnector

import org.eclipse.jetty.server.HttpConfiguration; //導入方法依賴的package包/類
public static void addHttpsConnector(Server server, int port) throws IOException, URISyntaxException {

        String keyStoreFile = resourceAsFile("ssltest-keystore.jks").getAbsolutePath();
        SslContextFactory sslContextFactory = new SslContextFactory(keyStoreFile);
        sslContextFactory.setKeyStorePassword("changeit");

        String trustStoreFile = resourceAsFile("ssltest-cacerts.jks").getAbsolutePath();
        sslContextFactory.setTrustStorePath(trustStoreFile);
        sslContextFactory.setTrustStorePassword("changeit");

        HttpConfiguration httpsConfig = new HttpConfiguration();
        httpsConfig.setSecureScheme("https");
        httpsConfig.setSecurePort(port);
        httpsConfig.addCustomizer(new SecureRequestCustomizer());

        ServerConnector connector = new ServerConnector(server, new SslConnectionFactory(sslContextFactory, "http/1.1"), new HttpConnectionFactory(httpsConfig));
        connector.setPort(port);

        server.addConnector(connector);
    }
 
開發者ID:amaralDaniel,項目名稱:megaphone,代碼行數:21,代碼來源:TestUtils.java

示例5: buildHttpConfiguration

import org.eclipse.jetty.server.HttpConfiguration; //導入方法依賴的package包/類
protected HttpConfiguration buildHttpConfiguration() {

        HttpConfiguration httpConfig = new HttpConfiguration();

        // most parameters are hardcoded for now... we should turn these
        // into properties

        httpConfig.setHeaderCacheSize(512);
        httpConfig.setOutputBufferSize(32 * 1024);
        httpConfig.setRequestHeaderSize(requestHeaderSize);
        httpConfig.setResponseHeaderSize(responseHeaderSize);
        httpConfig.setSendDateHeader(true);
        httpConfig.setSendServerVersion(true);

        httpConfig.addCustomizer(new ForwardedRequestCustomizer());

        return httpConfig;
    }
 
開發者ID:bootique,項目名稱:bootique-jetty,代碼行數:19,代碼來源:ConnectorFactory.java

示例6: startHttpsServer

import org.eclipse.jetty.server.HttpConfiguration; //導入方法依賴的package包/類
@BeforeClass
public static void startHttpsServer() throws Exception {
    skipIfHeadlessEnvironment();
    server = new Server();

    SslContextFactory sslContextFactory = new SslContextFactory();
    sslContextFactory.setKeyStorePath(ErrorCases.class.getResource("keystore").getPath());
    sslContextFactory.setKeyStorePassword("activeeon");

    HttpConfiguration httpConfig = new HttpConfiguration();
    HttpConfiguration httpsConfig = new HttpConfiguration(httpConfig);
    httpsConfig.addCustomizer(new SecureRequestCustomizer());

    ServerConnector sslConnector = new ServerConnector(server,
                                                       new ConnectionFactory[] { new SslConnectionFactory(sslContextFactory,
                                                                                                          HttpVersion.HTTP_1_1.asString()),
                                                                                 new HttpConnectionFactory(httpsConfig) });

    server.addConnector(sslConnector);
    server.start();
    serverUrl = "https://localhost:" + sslConnector.getLocalPort() + "/rest";
}
 
開發者ID:ow2-proactive,項目名稱:scheduling,代碼行數:23,代碼來源:ErrorCases.java

示例7: sslConnector

import org.eclipse.jetty.server.HttpConfiguration; //導入方法依賴的package包/類
/**
 * Create ssl connector if https is used
 * @return
 */
private ServerConnector sslConnector() {
	HttpConfiguration http_config = new HttpConfiguration();
	http_config.setSecureScheme("https");
	http_config.setSecurePort(this.getPort());
	
	HttpConfiguration https_config = new HttpConfiguration(http_config);
	https_config.addCustomizer(new SecureRequestCustomizer());
	
	SslContextFactory sslContextFactory = new SslContextFactory(this.getCertKeyStorePath());
	sslContextFactory.setKeyStorePassword(this.getCertKeyStorePassword());
	//exclude weak ciphers
	sslContextFactory.setExcludeCipherSuites("^.*_(MD5|SHA|SHA1)$");
	//only support tlsv1.2
	sslContextFactory.addExcludeProtocols("SSL", "SSLv2", "SSLv2Hello", "SSLv3", "TLSv1", "TLSv1.1");
	
	ServerConnector connector = new ServerConnector(jettyServer, 
			new SslConnectionFactory(sslContextFactory, "http/1.1"),
			new HttpConnectionFactory(https_config));
	connector.setPort(this.getPort());
	connector.setIdleTimeout(50000);
	return connector;
}
 
開發者ID:yahoo,項目名稱:mysql_perf_analyzer,代碼行數:27,代碼來源:App.java

示例8: setupSslServer

import org.eclipse.jetty.server.HttpConfiguration; //導入方法依賴的package包/類
public void setupSslServer(int port, SslContextFactory sslContextFactory) {
  if (_server != null && port > 0) {
    try {
      HttpConfiguration https = new HttpConfiguration();
      https.addCustomizer(new SecureRequestCustomizer());
      ServerConnector sslConnector = new ServerConnector(
          _server,
          new SslConnectionFactory(sslContextFactory, HttpVersion.HTTP_1_1.asString()),
          new HttpConnectionFactory(https));
      sslConnector.setPort(port);

      _server.addConnector(sslConnector);

      LOG.info("Helix SSL rest server is ready to start.");
    } catch (Exception ex) {
      LOG.error("Failed to setup Helix SSL rest server, " + ex);
    }
  }
}
 
開發者ID:apache,項目名稱:helix,代碼行數:20,代碼來源:HelixRestServer.java

示例9: startSSL

import org.eclipse.jetty.server.HttpConfiguration; //導入方法依賴的package包/類
@Override
public void startSSL(String keyStoreLocation, String keyStorePassword) throws Exception {
    Server server = new Server();

    HttpConfiguration httpsConfig = new HttpConfiguration();
    httpsConfig.addCustomizer(new SecureRequestCustomizer());
    SslContextFactory sslContextFactory = new SslContextFactory();
    sslContextFactory.setKeyStorePath(keyStoreLocation);
    sslContextFactory.setKeyStorePassword(keyStorePassword);
    ServerConnector https = new ServerConnector(server,
            new SslConnectionFactory(sslContextFactory, "http/1.1"),
            new HttpConnectionFactory(httpsConfig));
    https.setHost(host);
    https.setPort(port);
    server.setConnectors(new Connector[]{https});

    configureContextHandler(server);
    startServer(server);
}
 
開發者ID:sequenceiq,項目名稱:sequenceiq-samples,代碼行數:20,代碼來源:JettyWebSocketServer.java

示例10: createSSLConnector

import org.eclipse.jetty.server.HttpConfiguration; //導入方法依賴的package包/類
private ServerConnector createSSLConnector() {
    SslContextFactory sslContextFactory = new SslContextFactory();
    sslContextFactory.setKeyStorePath(m_keystore);
    sslContextFactory.setKeyStorePassword(m_keystorepassword);
    sslContextFactory.setTrustStorePath(m_truststore);
    sslContextFactory.setTrustStorePassword(m_truststorepassword);
    sslContextFactory.setNeedClientAuth(m_clientauthentication);
    sslContextFactory.setIncludeCipherSuites(m_tls_cipher_suites);

    HttpConfiguration http_config = new HttpConfiguration();
    http_config.setSecureScheme("https");
    HttpConfiguration https_config = new HttpConfiguration(http_config);
    https_config.addCustomizer(new SecureRequestCustomizer());
    SslConnectionFactory sslConnFactory = new SslConnectionFactory(sslContextFactory, "http/1.1");
    HttpConnectionFactory httpConnFactory = new HttpConnectionFactory(https_config);
    ServerConnector sslConnector = new ServerConnector(m_jettyServer, sslConnFactory, httpConnFactory);
    return sslConnector;
}
 
開發者ID:QSFT,項目名稱:Doradus,代碼行數:19,代碼來源:JettyWebServer.java

示例11: httpsConnector

import org.eclipse.jetty.server.HttpConfiguration; //導入方法依賴的package包/類
private ServerConnector httpsConnector(HttpConfiguration httpConfig) {
    // === jetty-https.xml ===
    // SSL Context Factory
    SslContextFactory sslContextFactory = new SslContextFactory();
    sslContextFactory.setKeyStorePath(CONFIG.getJetty().getKeyStorePath());
    sslContextFactory.setKeyStorePassword(CONFIG.getJetty().getKeyStorePassword());
    sslContextFactory.setKeyManagerPassword(CONFIG.getJetty().getKeyStorePassword());
    sslContextFactory.setExcludeCipherSuites(
            "SSL_RSA_WITH_DES_CBC_SHA",
            "SSL_DHE_RSA_WITH_DES_CBC_SHA",
            "SSL_DHE_DSS_WITH_DES_CBC_SHA",
            "SSL_RSA_EXPORT_WITH_RC4_40_MD5",
            "SSL_RSA_EXPORT_WITH_DES40_CBC_SHA",
            "SSL_DHE_RSA_EXPORT_WITH_DES40_CBC_SHA",
            "SSL_DHE_DSS_EXPORT_WITH_DES40_CBC_SHA");

    // SSL HTTP Configuration
    HttpConfiguration httpsConfig = new HttpConfiguration(httpConfig);
    httpsConfig.addCustomizer(new SecureRequestCustomizer());

    // SSL Connector
    ServerConnector https = new ServerConnector(server,
            new SslConnectionFactory(sslContextFactory, HttpVersion.HTTP_1_1.asString()),
            new HttpConnectionFactory(httpsConfig));
    https.setHost(CONFIG.getJetty().getServerHost());
    https.setPort(CONFIG.getJetty().getHttpsPort());
    https.setIdleTimeout(IDLE_TIMEOUT);
    return https;
}
 
開發者ID:RWTH-i5-IDSG,項目名稱:steve-plugsurfing,代碼行數:30,代碼來源:JettyServer.java

示例12: getConnector

import org.eclipse.jetty.server.HttpConfiguration; //導入方法依賴的package包/類
@Override
public ServerConnector getConnector(Server server,
		SslContextFactory sslContextFactory, int port) {
	HttpConfiguration config = new HttpConfiguration();
	config.addCustomizer(new SecureRequestCustomizer());
	HttpConnectionFactory connectionFactory = new HttpConnectionFactory(config);
	SslConnectionFactory sslConnectionFactory = new SslConnectionFactory(
			sslContextFactory, HttpVersion.HTTP_1_1.asString());
	ServerConnector serverConnector = new ServerConnector(server,
			sslConnectionFactory, connectionFactory);
	serverConnector.setPort(port);
	return serverConnector;
}
 
開發者ID:vikrammane23,項目名稱:https-github.com-g0t4-jenkins2-course-spring-boot,代碼行數:14,代碼來源:JettyEmbeddedServletContainerFactory.java

示例13: initServerForContextualCallbacks

import org.eclipse.jetty.server.HttpConfiguration; //導入方法依賴的package包/類
private Server initServerForContextualCallbacks(AuthServerProperties properties)
        throws CertificateException, NoSuchAlgorithmException, KeyStoreException, IOException
{
    ContextualCallbackHandler contextualCallbackHandler = new ContextualCallbackHandler(this);

    Server serverForContextualCallbacks = new Server();
    serverForContextualCallbacks.setHandler(contextualCallbackHandler);

    HttpConfiguration httpConfig = new HttpConfiguration();
    httpConfig.setPersistentConnectionsEnabled(true);
    httpConfig.setSecureScheme("https");
    // time out with out keep alive messages?
    //httpConfig.setBlockingTimeout();

    httpConfig.addCustomizer(new SecureRequestCustomizer());
    //new SSL
    ServerConnector connector = new ServerConnector(serverForContextualCallbacks, new HttpConnectionFactory(httpConfig));

    connector.setPort(properties.getTrustedAuthPort());

    // Idle time out for keep alive connections
    // time out with out requests?
    connector.setIdleTimeout(properties.getTrustedAuthPortIdleTimeout());

    serverForContextualCallbacks.setConnectors(new org.eclipse.jetty.server.Connector[]{connector});

    return serverForContextualCallbacks;
}
 
開發者ID:iotauth,項目名稱:iotauth,代碼行數:29,代碼來源:AuthServer.java

示例14: createServer

import org.eclipse.jetty.server.HttpConfiguration; //導入方法依賴的package包/類
private Server createServer(URI endpointURI, boolean needClientAuth) {
    if ("ws".equals(endpointURI.getScheme())) {
        return new Server(endpointURI.getPort());
    }
    else if ("wss".equals(endpointURI.getScheme())) {
        // see http://git.eclipse.org/c/jetty/org.eclipse.jetty.project.git/tree/examples/embedded/src/main/java/org/eclipse/jetty/embedded/ManyConnectors.java
        //     http://git.eclipse.org/c/jetty/org.eclipse.jetty.project.git/tree/examples/embedded/src/main/java/org/eclipse/jetty/embedded/LikeJettyXml.java
        
        Server server = new Server();
        
        SslContextFactory sslContextFactory = new SslContextFactory();
        sslContextFactory.setKeyStorePath(getStorePath("serverKeyStore.jks"));
        sslContextFactory.setKeyStorePassword("passw0rd");
        sslContextFactory.setKeyManagerPassword("passw0rd");
        sslContextFactory.setCertAlias("default");
        sslContextFactory.setNeedClientAuth(needClientAuth);
        sslContextFactory.setTrustStorePath(getStorePath("serverTrustStore.jks"));
        sslContextFactory.setTrustStorePassword("passw0rd");
        
        HttpConfiguration httpsConfig = new HttpConfiguration();
        httpsConfig.addCustomizer(new SecureRequestCustomizer());
        
        ServerConnector https= new ServerConnector(server,
                new SslConnectionFactory(sslContextFactory,
                        HttpVersion.HTTP_1_1.asString()),
                new HttpConnectionFactory(httpsConfig));
        https.setPort(endpointURI.getPort());
        
        server.addConnector(https);
        return server;
    }
    else
        throw new IllegalArgumentException("unrecognized uri: "+endpointURI);
}
 
開發者ID:quarks-edge,項目名稱:quarks,代碼行數:35,代碼來源:WebSocketServerEcho.java

示例15: newHttpConnectionFactory

import org.eclipse.jetty.server.HttpConfiguration; //導入方法依賴的package包/類
private HttpConnectionFactory newHttpConnectionFactory() {
    HttpConfiguration httpConfig = new HttpConfiguration();
    httpConfig.setSendDateHeader(true);
    httpConfig.setSendServerVersion(false);
    httpConfig.setSendXPoweredBy(false);
    httpConfig.setHeaderCacheSize(connectorConfig.headerCacheSize());
    httpConfig.setOutputBufferSize(connectorConfig.outputBufferSize());
    httpConfig.setRequestHeaderSize(connectorConfig.requestHeaderSize());
    httpConfig.setResponseHeaderSize(connectorConfig.responseHeaderSize());
    if (connectorConfig.ssl().enabled()) {
        httpConfig.addCustomizer(new SecureRequestCustomizer());
    }
    return new HttpConnectionFactory(httpConfig);
}
 
開發者ID:vespa-engine,項目名稱:vespa,代碼行數:15,代碼來源:ConnectorFactory.java


注:本文中的org.eclipse.jetty.server.HttpConfiguration.addCustomizer方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。