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


Java HttpConfiguration.setSecurePort方法代碼示例

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


在下文中一共展示了HttpConfiguration.setSecurePort方法的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: 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

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

示例4: startServer

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

示例5: doInstall

import org.eclipse.jetty.server.HttpConfiguration; //導入方法依賴的package包/類
public Connector doInstall(Server server){
	
	// shared http config
	HttpConfiguration http_config = new HttpConfiguration();
	http_config.setSecureScheme("https");
	http_config.setSecurePort(8443);
	http_config.setOutputBufferSize(32768);
	
	// HTTP connector #1
	ServerConnector http = new ServerConnector(server, new HttpConnectionFactory(http_config));
	http.setPort(httpPort);
	http.setIdleTimeout(idleTimeout == null ? 30000 : idleTimeout);
	if(host != null){
		http.setHost(host);			
	}
	
	return http;
	
}
 
開發者ID:danidemi,項目名稱:jlubricant,代碼行數:20,代碼來源:HttpConnectivity.java

示例6: get

import org.eclipse.jetty.server.HttpConfiguration; //導入方法依賴的package包/類
@Override
public ServerConnector get(Server server) {
  HttpConfiguration configuration = new HttpConfiguration(defaultConfig);
  configuration.setSecurePort(configurator.getPort());
  configuration.setSecureScheme(HttpScheme.HTTPS.asString());

  final ServerConnector connector = new ServerConnector(server, new HttpConnectionFactory(configuration));
  connector.setPort(configurator.getPort());
  connector.setHost(configurator.getHost());

  return connector;
}
 
開發者ID:sorskod,項目名稱:webserver,代碼行數:13,代碼來源:HTTPSConnectorFactory.java

示例7: createHttpConfiguration

import org.eclipse.jetty.server.HttpConfiguration; //導入方法依賴的package包/類
private HttpConfiguration createHttpConfiguration(ConfigMap<String, Object> connectorCfg) {
	HttpConfiguration httpConfig = new HttpConfiguration();
	if (connectorCfg.getBoolean("ssl", false) == true) {
		httpConfig.setSecureScheme("https");
		httpConfig.setSecurePort(connectorCfg.getInteger("port", 443));
	}
	
	httpConfig.setOutputBufferSize(connectorCfg.getInteger("output-buffer-size", 32) * KB);
	httpConfig.setRequestHeaderSize(connectorCfg.getInteger("request-header-size", 256) * KB);
	httpConfig.setResponseHeaderSize(connectorCfg.getInteger("response-header-size", 256) * KB);
	
	return httpConfig;
}
 
開發者ID:PinaeOS,項目名稱:pumbaa,代碼行數:14,代碼來源:PumbaaServer.java

示例8: setupConnectors

import org.eclipse.jetty.server.HttpConfiguration; //導入方法依賴的package包/類
private void setupConnectors() {
	Configuration conf = Configuration.getInstance();

	HttpConfiguration http = new HttpConfiguration();
	http.addCustomizer(new SecureRequestCustomizer());
	http.setSecureScheme("https");

	ServerConnector connector = new ServerConnector(server);
	connector.addConnectionFactory(new HttpConnectionFactory(http));
	connector.setPort(port);
	
	if(conf.getPropertyAsBoolean("ui.ssl.enabled", false)) {
		int httpsPort = conf.getPropertyAsInteger("ui.ssl.port", 443);
		
		http.setSecurePort(httpsPort);

		HttpConfiguration https = new HttpConfiguration();
		https.addCustomizer(new SecureRequestCustomizer());
		
		SslContextFactory sslContextFactory = new SslContextFactory();
		sslContextFactory.setKeyStorePath(conf.getProperty("ui.ssl.keystore.path"));
		sslContextFactory.setKeyStorePassword(conf.getProperty("ui.ssl.keystore.password"));
		sslContextFactory.setKeyManagerPassword(conf.getProperty("ui.ssl.keymanager.password"));
		
		ServerConnector sslConnector = new ServerConnector(server, new SslConnectionFactory(sslContextFactory, "http/1.1"), new HttpConnectionFactory(https));
		sslConnector.setPort(httpsPort);
		server.addConnector(sslConnector);
	}

	server.addConnector(connector);
}
 
開發者ID:denkbar,項目名稱:step,代碼行數:32,代碼來源:ControllerServer.java

示例9: setupHttpConnectors

import org.eclipse.jetty.server.HttpConfiguration; //導入方法依賴的package包/類
/**
 * This method sets up an insecure connector, and binds it to the port
 * defined in active.properties as http_port, if you do not want to use
 * https (why wouldn't you !?) , this is the only connector that will be
 * used to reach your application.
 *
 * @param port
 * @param securePort
 * @return
 */
private static ServerConnector setupHttpConnectors(int port, int securePort) {
    /*CONNECTORS BUSINESS*/
    HttpConfiguration httpConf = new HttpConfiguration();
    httpConf.setSecurePort(securePort);
    httpConf.setSecureScheme("https");

    ServerConnector httpConnector = new ServerConnector(embed_server,
            new HttpConnectionFactory(httpConf));
    httpConnector.setName("unsecured"); // named connector
    httpConnector.setPort(port);
    return httpConnector;
}
 
開發者ID:korena,項目名稱:service-base,代碼行數:23,代碼來源:JServer.java

示例10: run

import org.eclipse.jetty.server.HttpConfiguration; //導入方法依賴的package包/類
public void run() {
    try {
        QueuedThreadPool threadPool = new QueuedThreadPool();
        threadPool.setMaxThreads(16);

        Server server = new Server(threadPool);
        ServletContextHandler handler = new ServletContextHandler();
        handler.setContextPath("");
        ResourceConfig config = new ResourceConfig(InstanceProviderResources.class).register(new Binder());
        handler.addServlet(new ServletHolder(new ServletContainer(config)), "/*");
        server.setHandler(handler);
        
        // SSL Context Factory

        SslContextFactory sslContextFactory = createSSLContextObject();

        // SSL HTTP Configuration
        
        HttpConfiguration httpConfig = new HttpConfiguration();
        httpConfig.setSecureScheme("https");
        httpConfig.setSecurePort(10043);

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

        // SSL Connector
        
        ServerConnector sslConnector = new ServerConnector(server,
                new SslConnectionFactory(sslContextFactory, HttpVersion.HTTP_1_1.asString()),
                new HttpConnectionFactory(httpsConfig));
        sslConnector.setPort(10043);
        server.addConnector(sslConnector);
        
        server.start();
        server.join();
    } catch (Exception e) {
        System.err.println("*** " + e);
    }
}
 
開發者ID:yahoo,項目名稱:athenz,代碼行數:40,代碼來源:InstanceProviderContainer.java

示例11: createHttpConfiguration

import org.eclipse.jetty.server.HttpConfiguration; //導入方法依賴的package包/類
private static HttpConfiguration createHttpConfiguration() {
    HttpConfiguration config = new HttpConfiguration();
    config.setSecureScheme("https");
    config.setSecurePort(SSL_PORT);
    config.setSendXPoweredBy(false);
    config.setSendServerVersion(false);
    config.addCustomizer(new SecureRequestCustomizer());
    return config;
}
 
開發者ID:AndreasKl,項目名稱:embedded-jetty-http2,代碼行數:10,代碼來源:Application.java

示例12: buildHttpConfiguration

import org.eclipse.jetty.server.HttpConfiguration; //導入方法依賴的package包/類
private HttpConfiguration buildHttpConfiguration(int port) {
    // HTTP Configuration
    HttpConfiguration httpConfig = new HttpConfiguration();
    httpConfig.setSecureScheme("https");
    httpConfig.setSecurePort(port);
    httpConfig.setOutputBufferSize(32768);
    httpConfig.setRequestHeaderSize(8192);
    httpConfig.setResponseHeaderSize(8192);
    httpConfig.setSendServerVersion(true);
    httpConfig.setSendDateHeader(false);
    httpConfig.setBlockingTimeout(30000); // Config
    // httpConfig.addCustomizer(new ForwardedRequestCustomizer());
    return httpConfig;
}
 
開發者ID:jivesoftware,項目名稱:routing-bird,代碼行數:15,代碼來源:RestfulServer.java

示例13: createHttpsConnector

import org.eclipse.jetty.server.HttpConfiguration; //導入方法依賴的package包/類
Connector createHttpsConnector(int port, SslContext context) {

		SslContextFactory sslContextFactory = new SslContextFactory();
		{
			sslContextFactory.setKeyStorePath(context.getKeystore());
			sslContextFactory.setKeyStorePassword(context.getObfKeypass());

			sslContextFactory.setTrustStorePath(context.getTruststore());
			sslContextFactory.setTrustStorePassword(context.getObfTrustpass());

			sslContextFactory.setKeyManagerPassword(context.getObfMgrpass());

			sslContextFactory.setNeedClientAuth(false);
		}

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

		ConnectionFactory[] factories = new ConnectionFactory[] {
				//
				new SslConnectionFactory(sslContextFactory, "http/1.1"),//
				new HttpConnectionFactory(httpsConfig) //
		};

		return connectionWith(new ServerConnector(this.server, factories), port);
	}
 
開發者ID:dohbot,項目名稱:knives,代碼行數:31,代碼來源:EmbeddedJetty.java

示例14: main

import org.eclipse.jetty.server.HttpConfiguration; //導入方法依賴的package包/類
/**
 * Main entry point. Starts a Jetty server.
 *
 * @param args
 *            ignored.
 * @throws Exception
 *             if anything goes wrong.
 */
public static void main(final String[] args) throws Exception {
    // Configure logging to output to the console with default level of INFO
    BasicConfigurator.configure();

    // Configure server and its associated servlets
    Server server = new Server();
    SslConnectionFactory sslConnectionFactory = new SslConnectionFactory();
    SslContextFactory sslContextFactory = sslConnectionFactory.getSslContextFactory();
    sslContextFactory.setKeyStorePath(System.getProperty("javax.net.ssl.keyStore"));
    sslContextFactory.setKeyStorePassword(System.getProperty("javax.net.ssl.keyStorePassword"));
    sslContextFactory.setIncludeCipherSuites(Sdk.SUPPORTED_CIPHER_SUITES);

    HttpConfiguration httpConf = new HttpConfiguration();
    httpConf.setSecurePort(PORT);
    httpConf.setSecureScheme(HTTPS_SCHEME);
    httpConf.addCustomizer(new SecureRequestCustomizer());
    HttpConnectionFactory httpConnectionFactory = new HttpConnectionFactory(httpConf);

    ServerConnector serverConnector =
            new ServerConnector(server, sslConnectionFactory, httpConnectionFactory);
    serverConnector.setPort(PORT);

    Connector[] connectors = new Connector[1];
    connectors[0] = serverConnector;
    server.setConnectors(connectors);

    ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS);
    context.setContextPath("/");
    server.setHandler(context);
    context.addServlet(new ServletHolder(createServlet(new HelloWorldSpeechlet())), "/hello");
    context.addServlet(new ServletHolder(createServlet(new MinecraftSpeechlet())), "/minecrafthelper");
    context.addServlet(new ServletHolder(createServlet(new DomoticzSpeechlet())), "/domoticz");
    context.addServlet(new ServletHolder(createServlet(new SessionSpeechlet())), "/session");
    server.start();
    server.join();
}
 
開發者ID:beckdac,項目名稱:alexa_domoticz_bridge,代碼行數:45,代碼來源:Launcher.java

示例15: createHttpConfiguration

import org.eclipse.jetty.server.HttpConfiguration; //導入方法依賴的package包/類
/**
 * 創建HttpConfiguration
 * 
 * @return HttpConfiguration
 */
public static HttpConfiguration createHttpConfiguration() {
	HttpConfiguration httpConfig = new HttpConfiguration();

	httpConfig.setSecurePort(setting.getInt("secure-port", "http", 8443));
	httpConfig.setOutputBufferSize(setting.getInt("output-buffersize", "http", 32768));
	httpConfig.setRequestHeaderSize(setting.getInt("request-headersize", "http", 8192));
	httpConfig.setResponseHeaderSize(setting.getInt("response-headersize", "http", 8192));
	httpConfig.setSendServerVersion(true);
	httpConfig.setSendDateHeader(false);

	return httpConfig;
}
 
開發者ID:looly,項目名稱:hulu,代碼行數:18,代碼來源:JettySetting.java


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