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


Java HttpConnectionFactory類代碼示例

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


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

示例1: startJetty

import org.eclipse.jetty.server.HttpConnectionFactory; //導入依賴的package包/類
private void startJetty() throws Exception {
	QueuedThreadPool jettyThreadPool = new QueuedThreadPool(jettyServerThreads);
	Server server = new Server(jettyThreadPool);

	ServerConnector http = new ServerConnector(server, new HttpConnectionFactory());
	http.setPort(jettyListenPort);
	
	server.addConnector(http);
	
	ContextHandler contextHandler = new ContextHandler();
	contextHandler.setHandler(botSocketHandler);
	server.setHandler(contextHandler);
	
   	server.start();
   	server.join();
}
 
開發者ID:BuaBook,項目名稱:buabook-api-interface,代碼行數:17,代碼來源:BuaBookApiInterface.java

示例2: createConnector

import org.eclipse.jetty.server.HttpConnectionFactory; //導入依賴的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.HttpConnectionFactory; //導入依賴的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.HttpConnectionFactory; //導入依賴的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.HttpConnectionFactory; //導入依賴的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: jettyServer

import org.eclipse.jetty.server.HttpConnectionFactory; //導入依賴的package包/類
/** Build a Jetty server */
private static Server jettyServer(int port, boolean loopback) {
    Server server = new Server() ;
    HttpConnectionFactory f1 = new HttpConnectionFactory() ;
    // Some people do try very large operations ... really, should use POST.
    f1.getHttpConfiguration().setRequestHeaderSize(512 * 1024);
    f1.getHttpConfiguration().setOutputBufferSize(5 * 1024 * 1024) ;
    // Do not add "Server: Jetty(....) when not a development system.
    if ( true )
        f1.getHttpConfiguration().setSendServerVersion(false) ;
    ServerConnector connector = new ServerConnector(server, f1) ;
    connector.setPort(port) ;
    server.addConnector(connector);
    if ( loopback )
        connector.setHost("localhost");
    return server ;
}
 
開發者ID:afs,項目名稱:rdf-delta,代碼行數:18,代碼來源:PatchLogServer.java

示例7: LfsServer

import org.eclipse.jetty.server.HttpConnectionFactory; //導入依賴的package包/類
/**
 * Ctor.
 * @param path Server path.
 * @param storage Storage container.
 * @param port Server port
 */
LfsServer(final String path, final ContentManager storage,
    final int port) {
    this.server = new Server();
    this.http =
        new ServerConnector(this.server, new HttpConnectionFactory());
    this.http.setPort(port);
    // @checkstyle MagicNumber (1 line)
    this.http.setIdleTimeout(30000);
    this.server.addConnector(this.http);
    final ServletHandler handler = new ServletHandler();
    this.server.setHandler(handler);
    handler.addServletWithMapping(
        new ServletHolder(
            new PointerServlet(
                storage, String.format("%s/info/lfs/storage/", path)
            )
        ),
        String.format("%s/info/lfs/objects/*", path)
    );
    handler.addServletWithMapping(
        new ServletHolder(new ContentServlet(storage)),
        String.format("%s/info/lfs/storage/*", path)
    );
}
 
開發者ID:carlosmiranda,項目名稱:git-lfs-azureblob,代碼行數:31,代碼來源:LfsServer.java

示例8: disableServerHeader

import org.eclipse.jetty.server.HttpConnectionFactory; //導入依賴的package包/類
@Bean
public EmbeddedServletContainerCustomizer disableServerHeader() {
    return container -> {
        if (container instanceof JettyEmbeddedServletContainerFactory) {
            ((JettyEmbeddedServletContainerFactory) container).addServerCustomizers(new JettyServerCustomizer() {
                @Override
                public void customize(Server server) {
                    for (Connector connector : server.getConnectors()) {
                        if (connector instanceof ServerConnector) {
                            HttpConnectionFactory connectionFactory = connector.getConnectionFactory(HttpConnectionFactory.class);
                            connectionFactory.getHttpConfiguration().setSendServerVersion(false);
                        }
                    }
                }
            });
        }
    };
}
 
開發者ID:AusDTO,項目名稱:citizenship-appointment-server,代碼行數:19,代碼來源:AppConfig.java

示例9: defaultServerConfig

import org.eclipse.jetty.server.HttpConnectionFactory; //導入依賴的package包/類
private static void defaultServerConfig(int port, boolean loopback) {
    server = new Server() ;
    HttpConnectionFactory f1 = new HttpConnectionFactory() ;
    // Some people do try very large operations ... really, should use POST.
    f1.getHttpConfiguration().setRequestHeaderSize(512 * 1024);
    f1.getHttpConfiguration().setOutputBufferSize(5 * 1024 * 1024) ;
    
    //SslConnectionFactory f2 = new SslConnectionFactory() ;
    
    ServerConnector connector = new ServerConnector(server, f1) ; //, f2) ;
    connector.setPort(port) ;
    server.addConnector(connector);
    if ( loopback )
        connector.setHost("localhost");
    serverConnector = connector ;
}
 
開發者ID:afs,項目名稱:http-digest-auth,代碼行數:17,代碼來源:RunJetty.java

示例10: startHttpsServer

import org.eclipse.jetty.server.HttpConnectionFactory; //導入依賴的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

示例11: testCreateHttpServerUsingHttpsAndRedirection

import org.eclipse.jetty.server.HttpConnectionFactory; //導入依賴的package包/類
@Test
public void testCreateHttpServerUsingHttpsAndRedirection() {
    createHttpsContextProperties();

    server = jettyStarter.createHttpServer(8080, 8443, true, true);

    Connector[] connectors = server.getConnectors();

    assertThat(connectors).hasLength(2);
    assertThat(connectors[0].getName()).isEqualTo(JettyStarter.HTTP_CONNECTOR_NAME);
    assertThat(connectors[0].getConnectionFactory(HttpConnectionFactory.class)).isNotNull();
    assertThat(connectors[1].getName()).isEqualTo(JettyStarter.HTTPS_CONNECTOR_NAME.toLowerCase());
    assertThat(connectors[1].getConnectionFactory(HttpConnectionFactory.class)).isNotNull();
    assertThat(connectors[1].getConnectionFactory(SslConnectionFactory.class)).isNotNull();

    unsetHttpsContextProperties();
}
 
開發者ID:ow2-proactive,項目名稱:scheduling,代碼行數:18,代碼來源:JettyStarterTest.java

示例12: listener

import org.eclipse.jetty.server.HttpConnectionFactory; //導入依賴的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

示例13: startup

import org.eclipse.jetty.server.HttpConnectionFactory; //導入依賴的package包/類
public static boolean startup(int port) {
    Server server = new Server(port);
    
       ServletHandler handler = new ServletHandler();
       handler.addServletWithMapping(CrocoWebDecryptor.class, "/*");
       
    for(Connector y : server.getConnectors()) {
        for(ConnectionFactory x  : y.getConnectionFactories()) {
            if(x instanceof HttpConnectionFactory) {
                ((HttpConnectionFactory)x).getHttpConfiguration().setSendServerVersion(false);
            }
        }
    }

    server.setHandler(handler);
    try {
	    server.start();
	    return true;
	} catch (Exception e) {
		try {
			server.stop();
		} catch (Exception e2) {}
	}
    
    return false;
}
 
開發者ID:fhissen,項目名稱:CrococryptFile,代碼行數:27,代碼來源:JettyStart.java

示例14: sslConnector

import org.eclipse.jetty.server.HttpConnectionFactory; //導入依賴的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

示例15: startServer

import org.eclipse.jetty.server.HttpConnectionFactory; //導入依賴的package包/類
/**
 * Start the Jetty Server on the specified port
 * @throws Exception
 */
private static void startServer() throws Exception {
	HttpConfiguration http_config = new HttpConfiguration();
	http_config.setSecureScheme("https");
	http_config.setSecurePort(8443);
	http_config.setOutputBufferSize(32768);
	Server server = new Server();
	ServerConnector http = new ServerConnector(server,
			new HttpConnectionFactory(http_config));
	http.setPort(_port);
	http.setIdleTimeout(30000);
	server.setConnectors(new Connector[] { http });

	// Set a handler
	server.setHandler(new PoolWatcher());

	// Start the server
	server.start();
}
 
開發者ID:shri30,項目名稱:ProcessPool,代碼行數:23,代碼來源:PoolWatcher.java


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