本文整理匯總了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);
}
示例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);
}
示例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;
}
示例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();
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
示例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;
}
示例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);
}
}
示例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;
}
示例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;
}
示例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);
}
示例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();
}
示例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;
}