当前位置: 首页>>代码示例>>Java>>正文


Java HttpConfiguration类代码示例

本文整理汇总了Java中org.eclipse.jetty.server.HttpConfiguration的典型用法代码示例。如果您正苦于以下问题:Java HttpConfiguration类的具体用法?Java HttpConfiguration怎么用?Java HttpConfiguration使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


HttpConfiguration类属于org.eclipse.jetty.server包,在下文中一共展示了HttpConfiguration类的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: createHttpsConnector

import org.eclipse.jetty.server.HttpConfiguration; //导入依赖的package包/类
/**
 * Create an HTTPS connector for given jetty server instance. If the config has specified keystore/truststore settings
 * they will be used else a self-signed certificate is generated and used.
 *
 * @param hostName
 * @param config {@link DremioConfig} containing SSL related settings if any.
 * @param embeddedJetty Jetty server instance needed for creating a ServerConnector.
 *
 * @return Initialized {@link ServerConnector} for HTTPS connections and the trust store. Trust store is non-null only
 * when in case of auto generated self-signed certificate.
 * @throws Exception
 */
public Pair<ServerConnector, KeyStore> createHttpsConnector(final Server embeddedJetty,
    final DremioConfig config, final String hostName, final String... alternativeNames) throws Exception {
  logger.info("Setting up HTTPS connector for web server");

  final SslContextFactory sslContextFactory = new SslContextFactory();

  Pair<KeyStore, String> keyStore = getKeyStore(config, hostName, alternativeNames);
  KeyStore trustStore = getTrustStore(config);

  sslContextFactory.setKeyStore(keyStore.getLeft());
  // Assuming that the keystore and the keymanager passwords are the same
  // based on JSSE examples...
  sslContextFactory.setKeyManagerPassword(keyStore.getRight());
  sslContextFactory.setTrustStore(trustStore);

  // Disable ciphers, protocols and other that are considered weak/vulnerable
  sslContextFactory.setExcludeCipherSuites(
      "TLS_DHE.*",
      "TLS_EDH.*"
      // TODO: there are few other ciphers that Chrome complains about being obsolete. Research more about them and
      // include here.
  );

  sslContextFactory.setExcludeProtocols("SSLv3");
  sslContextFactory.setRenegotiationAllowed(false);

  // SSL Connector
  final ServerConnector sslConnector = new ServerConnector(embeddedJetty,
      new SslConnectionFactory(sslContextFactory, HttpVersion.HTTP_1_1.asString()),
      new HttpConnectionFactory(new HttpConfiguration()));

  return Pair.of(sslConnector, trustStore);
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:46,代码来源:HttpsConnectorGenerator.java

示例4: 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

示例5: 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

示例6: newHttpConfiguration

import org.eclipse.jetty.server.HttpConfiguration; //导入依赖的package包/类
public HttpConfiguration newHttpConfiguration() {

        // HTTP Configuration
        
        boolean sendServerVersion = Boolean.parseBoolean(
                System.getProperty(AthenzConsts.ATHENZ_PROP_SEND_SERVER_VERSION, "false"));
        boolean sendDateHeader = Boolean.parseBoolean(
                System.getProperty(AthenzConsts.ATHENZ_PROP_SEND_DATE_HEADER, "false"));
        int outputBufferSize = Integer.parseInt(
                System.getProperty(AthenzConsts.ATHENZ_PROP_OUTPUT_BUFFER_SIZE, "32768"));
        int requestHeaderSize = Integer.parseInt(
                System.getProperty(AthenzConsts.ATHENZ_PROP_REQUEST_HEADER_SIZE, "8192"));
        int responseHeaderSize = Integer.parseInt(
                System.getProperty(AthenzConsts.ATHENZ_PROP_RESPONSE_HEADER_SIZE, "8192"));
        
        HttpConfiguration httpConfig = new HttpConfiguration();
        
        httpConfig.setOutputBufferSize(outputBufferSize);
        httpConfig.setRequestHeaderSize(requestHeaderSize);
        httpConfig.setResponseHeaderSize(responseHeaderSize);
        httpConfig.setSendServerVersion(sendServerVersion);
        httpConfig.setSendDateHeader(sendDateHeader);

        return httpConfig;
    }
 
开发者ID:yahoo,项目名称:athenz,代码行数:26,代码来源:AthenzJettyContainer.java

示例7: testHttpConfigurationValidHttpsPort

import org.eclipse.jetty.server.HttpConfiguration; //导入依赖的package包/类
@Test
public void testHttpConfigurationValidHttpsPort() {
    
    AthenzJettyContainer container = new AthenzJettyContainer();
    container.createServer(100);
    
    System.setProperty(AthenzConsts.ATHENZ_PROP_SEND_SERVER_VERSION, "true");
    System.setProperty(AthenzConsts.ATHENZ_PROP_SEND_DATE_HEADER, "false");
    System.setProperty(AthenzConsts.ATHENZ_PROP_OUTPUT_BUFFER_SIZE, "128");
    System.setProperty(AthenzConsts.ATHENZ_PROP_REQUEST_HEADER_SIZE, "256");
    System.setProperty(AthenzConsts.ATHENZ_PROP_RESPONSE_HEADER_SIZE, "512");
    
    HttpConfiguration httpConfig = container.newHttpConfiguration();
    assertNotNull(httpConfig);
    
    assertEquals(httpConfig.getOutputBufferSize(), 128);
    assertFalse(httpConfig.getSendDateHeader());
    assertTrue(httpConfig.getSendServerVersion());
    assertEquals(httpConfig.getRequestHeaderSize(), 256);
    assertEquals(httpConfig.getResponseHeaderSize(), 512);
    
    // it defaults to https even if we have no value specified
    assertEquals(httpConfig.getSecureScheme(), "https");
}
 
开发者ID:yahoo,项目名称:athenz,代码行数:25,代码来源:AthenzJettyContainerTest.java

示例8: testHttpConfigurationNoHttpsPort

import org.eclipse.jetty.server.HttpConfiguration; //导入依赖的package包/类
@Test
public void testHttpConfigurationNoHttpsPort() {
    
    AthenzJettyContainer container = new AthenzJettyContainer();
    container.createServer(100);
    
    System.setProperty(AthenzConsts.ATHENZ_PROP_SEND_SERVER_VERSION, "false");
    System.setProperty(AthenzConsts.ATHENZ_PROP_SEND_DATE_HEADER, "true");
    System.setProperty(AthenzConsts.ATHENZ_PROP_OUTPUT_BUFFER_SIZE, "64");
    System.setProperty(AthenzConsts.ATHENZ_PROP_REQUEST_HEADER_SIZE, "128");
    System.setProperty(AthenzConsts.ATHENZ_PROP_RESPONSE_HEADER_SIZE, "256");
    
    HttpConfiguration httpConfig = container.newHttpConfiguration();
    assertNotNull(httpConfig);
    
    assertEquals(httpConfig.getOutputBufferSize(), 64);
    assertTrue(httpConfig.getSendDateHeader());
    assertFalse(httpConfig.getSendServerVersion());
    assertEquals(httpConfig.getRequestHeaderSize(), 128);
    assertEquals(httpConfig.getResponseHeaderSize(), 256);
    assertEquals(httpConfig.getSecurePort(), 0);
    
    // it defaults to https even if we have no value specified
    assertEquals(httpConfig.getSecureScheme(), "https");
}
 
开发者ID:yahoo,项目名称:athenz,代码行数:26,代码来源:AthenzJettyContainerTest.java

示例9: testHttpConnectorsHttpsOnly

import org.eclipse.jetty.server.HttpConfiguration; //导入依赖的package包/类
@Test
public void testHttpConnectorsHttpsOnly() {
    
    System.setProperty(AthenzConsts.ATHENZ_PROP_KEYSTORE_PATH, "file:///tmp/keystore");
    System.setProperty(AthenzConsts.ATHENZ_PROP_KEYSTORE_TYPE, "PKCS12");
    System.setProperty(AthenzConsts.ATHENZ_PROP_KEYSTORE_PASSWORD, "pass123");
    System.setProperty(AthenzConsts.ATHENZ_PROP_TRUSTSTORE_PATH, "file:///tmp/truststore");
    System.setProperty(AthenzConsts.ATHENZ_PROP_TRUSTSTORE_TYPE, "PKCS12");
    System.setProperty(AthenzConsts.ATHENZ_PROP_TRUSTSTORE_PASSWORD, "pass123");
    System.setProperty(AthenzConsts.ATHENZ_PROP_KEYMANAGER_PASSWORD, "pass123");
    System.setProperty(AthenzConsts.ATHENZ_PROP_IDLE_TIMEOUT, "10001");
    
    AthenzJettyContainer container = new AthenzJettyContainer();
    container.createServer(100);
    
    HttpConfiguration httpConfig = container.newHttpConfiguration();
    container.addHTTPConnectors(httpConfig, 0, 8082, 0);
    
    Server server = container.getServer();
    Connector[] connectors = server.getConnectors();
    assertEquals(connectors.length, 1);
    
    assertTrue(connectors[0].getProtocols().contains("http/1.1"));
    assertTrue(connectors[0].getProtocols().contains("ssl"));
}
 
开发者ID:yahoo,项目名称:athenz,代码行数:26,代码来源:AthenzJettyContainerTest.java

示例10: testHttpConnectorsHttpOnly

import org.eclipse.jetty.server.HttpConfiguration; //导入依赖的package包/类
@Test
public void testHttpConnectorsHttpOnly() {
    
    System.setProperty(AthenzConsts.ATHENZ_PROP_KEYSTORE_PATH, "file:///tmp/keystore");
    System.setProperty(AthenzConsts.ATHENZ_PROP_KEYSTORE_TYPE, "PKCS12");
    System.setProperty(AthenzConsts.ATHENZ_PROP_KEYSTORE_PASSWORD, "pass123");
    System.setProperty(AthenzConsts.ATHENZ_PROP_TRUSTSTORE_PATH, "file:///tmp/truststore");
    System.setProperty(AthenzConsts.ATHENZ_PROP_TRUSTSTORE_TYPE, "PKCS12");
    System.setProperty(AthenzConsts.ATHENZ_PROP_TRUSTSTORE_PASSWORD, "pass123");
    System.setProperty(AthenzConsts.ATHENZ_PROP_KEYMANAGER_PASSWORD, "pass123");
    System.setProperty(AthenzConsts.ATHENZ_PROP_IDLE_TIMEOUT, "10001");
    
    AthenzJettyContainer container = new AthenzJettyContainer();
    container.createServer(100);
    
    HttpConfiguration httpConfig = container.newHttpConfiguration();
    container.addHTTPConnectors(httpConfig, 8081, 0, 0);
    
    Server server = container.getServer();
    Connector[] connectors = server.getConnectors();
    assertEquals(connectors.length, 1);
    
    assertEquals(connectors[0].getIdleTimeout(), 10001);
    assertTrue(connectors[0].getProtocols().contains("http/1.1"));
    assertFalse(connectors[0].getProtocols().contains("ssl"));
}
 
开发者ID:yahoo,项目名称:athenz,代码行数:27,代码来源:AthenzJettyContainerTest.java

示例11: verifyConfiguration

import org.eclipse.jetty.server.HttpConfiguration; //导入依赖的package包/类
/**
 * Verifies all the needed bits are present in Jetty XML configuration (as HTTPS must be enabled by users).
 */
private void verifyConfiguration(final HttpScheme httpScheme) {
  try {
    if (HttpScheme.HTTP == httpScheme) {
      bean(HTTP_CONFIG_ID, HttpConfiguration.class);
      bean(HTTP_CONNECTOR_ID, ServerConnector.class);
    }
    else if (HttpScheme.HTTPS == httpScheme) {
      bean(SSL_CONTEXT_FACTORY_ID, SslContextFactory.class);
      bean(HTTPS_CONFIG_ID, HttpConfiguration.class);
      bean(HTTPS_CONNECTOR_ID, ServerConnector.class);
    }
    else {
      throw new UnsupportedHttpSchemeException(httpScheme);
    }
  }
  catch (IllegalStateException e) {
    throw new IllegalStateException("Jetty HTTPS is not enabled in Nexus", e);
  }
}
 
开发者ID:sonatype,项目名称:nexus-public,代码行数:23,代码来源:ConnectorManager.java

示例12: 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

示例13: setup

import org.eclipse.jetty.server.HttpConfiguration; //导入依赖的package包/类
public ServerConnector setup(final Server server, final InetSocketAddress address) {
    final HttpConfiguration config = this.config.build();

    final ConnectionFactory[] factories = this.factories
        .stream()
        .map(f -> f.setup(config))
        .toArray(size -> new ConnectionFactory[size]);

    final ServerConnector c = new ServerConnector(server, factories);

    c.setHost(this.address.map(a -> a.getHostString()).orElseGet(address::getHostString));
    c.setPort(this.address.map(a -> a.getPort()).orElseGet(address::getPort));

    defaultProtocol.ifPresent(c::setDefaultProtocol);
    return c;
}
 
开发者ID:spotify,项目名称:heroic,代码行数:17,代码来源:JettyServerConnector.java

示例14: 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

示例15: listener

import org.eclipse.jetty.server.HttpConfiguration; //导入依赖的package包/类
public void listener(int port) {
    initJettyConfig();

    this.port = port;
    HttpConfiguration httpConfiguration = initHttpConfiguration();
    HttpConnectionFactory httpConnectionFactory = new HttpConnectionFactory(httpConfiguration);

    QueuedThreadPool threadPool = this.initThreadPool();
    this.server = new Server(threadPool);
    int cores = Runtime.getRuntime().availableProcessors();
    ServerConnector connector = new ServerConnector(server, null, null, null, 1 + cores / 2, -1,
            httpConnectionFactory);
    initConnector(connector);
    connector.setPort(this.port);
    server.setConnectors(new Connector[] { connector });
    logger.info("Application listen on " + port);
}
 
开发者ID:HunanTV,项目名称:fw,代码行数:18,代码来源:Application.java


注:本文中的org.eclipse.jetty.server.HttpConfiguration类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。