本文整理汇总了Java中org.eclipse.jetty.server.SslConnectionFactory类的典型用法代码示例。如果您正苦于以下问题:Java SslConnectionFactory类的具体用法?Java SslConnectionFactory怎么用?Java SslConnectionFactory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SslConnectionFactory类属于org.eclipse.jetty.server包,在下文中一共展示了SslConnectionFactory类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: customize
import org.eclipse.jetty.server.SslConnectionFactory; //导入依赖的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: createConnector
import org.eclipse.jetty.server.SslConnectionFactory; //导入依赖的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));
}
示例3: createHttpsConnector
import org.eclipse.jetty.server.SslConnectionFactory; //导入依赖的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);
}
示例4: setupSSL
import org.eclipse.jetty.server.SslConnectionFactory; //导入依赖的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);
}
示例5: getConnectorPath
import org.eclipse.jetty.server.SslConnectionFactory; //导入依赖的package包/类
private String getConnectorPath(ServerConnector sc) {
String prefix = "http";
String host = sc.getHost();
int port = sc.getPort();
ConnectionFactory cf = sc.getDefaultConnectionFactory();
if (cf instanceof SslConnectionFactory) {
prefix = "https";
}
if (host == null || host.equals("0.0.0.0")) {
try {
host = InetAddress.getLocalHost().getHostAddress();
} catch (UnknownHostException e) {
// Well, we failed to read from system, fall back to main.properties.
// Better than nothing
host = CONFIG.getJetty().getServerHost();
}
}
String layout = "%s://%s:%d" + CONFIG.getContextPath();
return String.format(layout, prefix, host, port);
}
示例6: addHttpsConnector
import org.eclipse.jetty.server.SslConnectionFactory; //导入依赖的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);
}
示例7: sslCiphersConfiguration
import org.eclipse.jetty.server.SslConnectionFactory; //导入依赖的package包/类
@Test
public void sslCiphersConfiguration() throws Exception {
Ssl ssl = new Ssl();
ssl.setKeyStore("src/test/resources/test.jks");
ssl.setKeyStorePassword("secret");
ssl.setKeyPassword("password");
ssl.setCiphers(new String[] { "ALPHA", "BRAVO", "CHARLIE" });
JettyEmbeddedServletContainerFactory factory = getFactory();
factory.setSsl(ssl);
this.container = factory.getEmbeddedServletContainer();
this.container.start();
JettyEmbeddedServletContainer jettyContainer = (JettyEmbeddedServletContainer) this.container;
ServerConnector connector = (ServerConnector) jettyContainer.getServer()
.getConnectors()[0];
SslConnectionFactory connectionFactory = connector
.getConnectionFactory(SslConnectionFactory.class);
assertThat(connectionFactory.getSslContextFactory().getIncludeCipherSuites())
.containsExactly("ALPHA", "BRAVO", "CHARLIE");
assertThat(connectionFactory.getSslContextFactory().getExcludeCipherSuites())
.isEmpty();
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:25,代码来源:JettyEmbeddedServletContainerFactoryTests.java
示例8: sslEnabledMultiProtocolsConfiguration
import org.eclipse.jetty.server.SslConnectionFactory; //导入依赖的package包/类
@Test
public void sslEnabledMultiProtocolsConfiguration() throws Exception {
Ssl ssl = new Ssl();
ssl.setKeyStore("src/test/resources/test.jks");
ssl.setKeyStorePassword("secret");
ssl.setKeyPassword("password");
ssl.setCiphers(new String[] { "ALPHA", "BRAVO", "CHARLIE" });
ssl.setEnabledProtocols(new String[] { "TLSv1.1", "TLSv1.2" });
JettyEmbeddedServletContainerFactory factory = getFactory();
factory.setSsl(ssl);
this.container = factory.getEmbeddedServletContainer();
this.container.start();
JettyEmbeddedServletContainer jettyContainer = (JettyEmbeddedServletContainer) this.container;
ServerConnector connector = (ServerConnector) jettyContainer.getServer()
.getConnectors()[0];
SslConnectionFactory connectionFactory = connector
.getConnectionFactory(SslConnectionFactory.class);
assertThat(connectionFactory.getSslContextFactory().getIncludeProtocols())
.isEqualTo(new String[] { "TLSv1.1", "TLSv1.2" });
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:25,代码来源:JettyEmbeddedServletContainerFactoryTests.java
示例9: sslEnabledProtocolsConfiguration
import org.eclipse.jetty.server.SslConnectionFactory; //导入依赖的package包/类
@Test
public void sslEnabledProtocolsConfiguration() throws Exception {
Ssl ssl = new Ssl();
ssl.setKeyStore("src/test/resources/test.jks");
ssl.setKeyStorePassword("secret");
ssl.setKeyPassword("password");
ssl.setCiphers(new String[] { "ALPHA", "BRAVO", "CHARLIE" });
ssl.setEnabledProtocols(new String[] { "TLSv1.1" });
JettyEmbeddedServletContainerFactory factory = getFactory();
factory.setSsl(ssl);
this.container = factory.getEmbeddedServletContainer();
this.container.start();
JettyEmbeddedServletContainer jettyContainer = (JettyEmbeddedServletContainer) this.container;
ServerConnector connector = (ServerConnector) jettyContainer.getServer()
.getConnectors()[0];
SslConnectionFactory connectionFactory = connector
.getConnectionFactory(SslConnectionFactory.class);
assertThat(connectionFactory.getSslContextFactory().getIncludeProtocols())
.isEqualTo(new String[] { "TLSv1.1" });
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:25,代码来源:JettyEmbeddedServletContainerFactoryTests.java
示例10: sslCiphersConfiguration
import org.eclipse.jetty.server.SslConnectionFactory; //导入依赖的package包/类
@Test
public void sslCiphersConfiguration() throws Exception {
Ssl ssl = new Ssl();
ssl.setKeyStore("src/test/resources/test.jks");
ssl.setKeyStorePassword("secret");
ssl.setKeyPassword("password");
ssl.setCiphers(new String[] { "ALPHA", "BRAVO", "CHARLIE" });
JettyEmbeddedServletContainerFactory factory = getFactory();
factory.setSsl(ssl);
this.container = factory.getEmbeddedServletContainer();
this.container.start();
JettyEmbeddedServletContainer jettyContainer = (JettyEmbeddedServletContainer) this.container;
ServerConnector connector = (ServerConnector) jettyContainer.getServer()
.getConnectors()[0];
SslConnectionFactory connectionFactory = connector
.getConnectionFactory(SslConnectionFactory.class);
assertThat(connectionFactory.getSslContextFactory().getIncludeCipherSuites())
.containsExactly("ALPHA", "BRAVO", "CHARLIE");
}
开发者ID:philwebb,项目名称:spring-boot-concourse,代码行数:23,代码来源:JettyEmbeddedServletContainerFactoryTests.java
示例11: sslCiphersConfiguration
import org.eclipse.jetty.server.SslConnectionFactory; //导入依赖的package包/类
@Test
public void sslCiphersConfiguration() throws Exception {
Ssl ssl = new Ssl();
ssl.setKeyStore("src/test/resources/test.jks");
ssl.setKeyStorePassword("secret");
ssl.setKeyPassword("password");
ssl.setCiphers(new String[] { "ALPHA", "BRAVO", "CHARLIE" });
JettyEmbeddedServletContainerFactory factory = getFactory();
factory.setSsl(ssl);
this.container = factory.getEmbeddedServletContainer();
this.container.start();
JettyEmbeddedServletContainer jettyContainer = (JettyEmbeddedServletContainer) this.container;
ServerConnector connector = (ServerConnector) jettyContainer.getServer()
.getConnectors()[0];
SslConnectionFactory connectionFactory = connector
.getConnectionFactory(SslConnectionFactory.class);
assertThat(connectionFactory.getSslContextFactory().getIncludeCipherSuites(),
equalTo(new String[] { "ALPHA", "BRAVO", "CHARLIE" }));
}
示例12: startHttpsServer
import org.eclipse.jetty.server.SslConnectionFactory; //导入依赖的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";
}
示例13: testCreateHttpServerUsingHttpsAndRedirection
import org.eclipse.jetty.server.SslConnectionFactory; //导入依赖的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();
}
示例14: sslConnector
import org.eclipse.jetty.server.SslConnectionFactory; //导入依赖的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;
}
示例15: createServer
import org.eclipse.jetty.server.SslConnectionFactory; //导入依赖的package包/类
protected Server createServer(int port, boolean serverSsl, boolean clientSsl) {
Server server = new Server();
if (!serverSsl) {
InetSocketAddress addr = new InetSocketAddress("localhost", port);
ServerConnector connector = new ServerConnector(server);
connector.setHost(addr.getHostName());
connector.setPort(addr.getPort());
server.setConnectors(new Connector[]{connector});
} else {
SslContextFactory sslContextFactory = createSslContextFactory(clientSsl);
ServerConnector httpsConnector = new ServerConnector(server,
new SslConnectionFactory(sslContextFactory, "http/1.1"),
new HttpConnectionFactory()
);
httpsConnector.setPort(port);
httpsConnector.setHost("localhost");
server.setConnectors(new Connector[]{httpsConnector});
}
return server;
}