本文整理汇总了Java中org.eclipse.jetty.server.SecureRequestCustomizer类的典型用法代码示例。如果您正苦于以下问题:Java SecureRequestCustomizer类的具体用法?Java SecureRequestCustomizer怎么用?Java SecureRequestCustomizer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SecureRequestCustomizer类属于org.eclipse.jetty.server包,在下文中一共展示了SecureRequestCustomizer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: customize
import org.eclipse.jetty.server.SecureRequestCustomizer; //导入依赖的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.SecureRequestCustomizer; //导入依赖的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: setupSSL
import org.eclipse.jetty.server.SecureRequestCustomizer; //导入依赖的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);
}
示例4: addHttpsConnector
import org.eclipse.jetty.server.SecureRequestCustomizer; //导入依赖的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);
}
示例5: startHttpsServer
import org.eclipse.jetty.server.SecureRequestCustomizer; //导入依赖的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";
}
示例6: sslConnector
import org.eclipse.jetty.server.SecureRequestCustomizer; //导入依赖的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;
}
示例7: setupSslServer
import org.eclipse.jetty.server.SecureRequestCustomizer; //导入依赖的package包/类
public void setupSslServer(int port, SslContextFactory sslContextFactory) {
if (_server != null && port > 0) {
try {
HttpConfiguration https = new HttpConfiguration();
https.addCustomizer(new SecureRequestCustomizer());
ServerConnector sslConnector = new ServerConnector(
_server,
new SslConnectionFactory(sslContextFactory, HttpVersion.HTTP_1_1.asString()),
new HttpConnectionFactory(https));
sslConnector.setPort(port);
_server.addConnector(sslConnector);
LOG.info("Helix SSL rest server is ready to start.");
} catch (Exception ex) {
LOG.error("Failed to setup Helix SSL rest server, " + ex);
}
}
}
示例8: startSSL
import org.eclipse.jetty.server.SecureRequestCustomizer; //导入依赖的package包/类
@Override
public void startSSL(String keyStoreLocation, String keyStorePassword) throws Exception {
Server server = new Server();
HttpConfiguration httpsConfig = new HttpConfiguration();
httpsConfig.addCustomizer(new SecureRequestCustomizer());
SslContextFactory sslContextFactory = new SslContextFactory();
sslContextFactory.setKeyStorePath(keyStoreLocation);
sslContextFactory.setKeyStorePassword(keyStorePassword);
ServerConnector https = new ServerConnector(server,
new SslConnectionFactory(sslContextFactory, "http/1.1"),
new HttpConnectionFactory(httpsConfig));
https.setHost(host);
https.setPort(port);
server.setConnectors(new Connector[]{https});
configureContextHandler(server);
startServer(server);
}
示例9: createSSLConnector
import org.eclipse.jetty.server.SecureRequestCustomizer; //导入依赖的package包/类
private ServerConnector createSSLConnector() {
SslContextFactory sslContextFactory = new SslContextFactory();
sslContextFactory.setKeyStorePath(m_keystore);
sslContextFactory.setKeyStorePassword(m_keystorepassword);
sslContextFactory.setTrustStorePath(m_truststore);
sslContextFactory.setTrustStorePassword(m_truststorepassword);
sslContextFactory.setNeedClientAuth(m_clientauthentication);
sslContextFactory.setIncludeCipherSuites(m_tls_cipher_suites);
HttpConfiguration http_config = new HttpConfiguration();
http_config.setSecureScheme("https");
HttpConfiguration https_config = new HttpConfiguration(http_config);
https_config.addCustomizer(new SecureRequestCustomizer());
SslConnectionFactory sslConnFactory = new SslConnectionFactory(sslContextFactory, "http/1.1");
HttpConnectionFactory httpConnFactory = new HttpConnectionFactory(https_config);
ServerConnector sslConnector = new ServerConnector(m_jettyServer, sslConnFactory, httpConnFactory);
return sslConnector;
}
示例10: httpsConnector
import org.eclipse.jetty.server.SecureRequestCustomizer; //导入依赖的package包/类
private ServerConnector httpsConnector(HttpConfiguration httpConfig) {
// === jetty-https.xml ===
// SSL Context Factory
SslContextFactory sslContextFactory = new SslContextFactory();
sslContextFactory.setKeyStorePath(CONFIG.getJetty().getKeyStorePath());
sslContextFactory.setKeyStorePassword(CONFIG.getJetty().getKeyStorePassword());
sslContextFactory.setKeyManagerPassword(CONFIG.getJetty().getKeyStorePassword());
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");
// SSL HTTP Configuration
HttpConfiguration httpsConfig = new HttpConfiguration(httpConfig);
httpsConfig.addCustomizer(new SecureRequestCustomizer());
// SSL Connector
ServerConnector https = new ServerConnector(server,
new SslConnectionFactory(sslContextFactory, HttpVersion.HTTP_1_1.asString()),
new HttpConnectionFactory(httpsConfig));
https.setHost(CONFIG.getJetty().getServerHost());
https.setPort(CONFIG.getJetty().getHttpsPort());
https.setIdleTimeout(IDLE_TIMEOUT);
return https;
}
示例11: getConnector
import org.eclipse.jetty.server.SecureRequestCustomizer; //导入依赖的package包/类
@Override
public ServerConnector getConnector(Server server,
SslContextFactory sslContextFactory, int port) {
HttpConfiguration config = new HttpConfiguration();
config.addCustomizer(new SecureRequestCustomizer());
HttpConnectionFactory connectionFactory = new HttpConnectionFactory(config);
SslConnectionFactory sslConnectionFactory = new SslConnectionFactory(
sslContextFactory, HttpVersion.HTTP_1_1.asString());
ServerConnector serverConnector = new ServerConnector(server,
sslConnectionFactory, connectionFactory);
serverConnector.setPort(port);
return serverConnector;
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:14,代码来源:JettyEmbeddedServletContainerFactory.java
示例12: initServerForContextualCallbacks
import org.eclipse.jetty.server.SecureRequestCustomizer; //导入依赖的package包/类
private Server initServerForContextualCallbacks(AuthServerProperties properties)
throws CertificateException, NoSuchAlgorithmException, KeyStoreException, IOException
{
ContextualCallbackHandler contextualCallbackHandler = new ContextualCallbackHandler(this);
Server serverForContextualCallbacks = new Server();
serverForContextualCallbacks.setHandler(contextualCallbackHandler);
HttpConfiguration httpConfig = new HttpConfiguration();
httpConfig.setPersistentConnectionsEnabled(true);
httpConfig.setSecureScheme("https");
// time out with out keep alive messages?
//httpConfig.setBlockingTimeout();
httpConfig.addCustomizer(new SecureRequestCustomizer());
//new SSL
ServerConnector connector = new ServerConnector(serverForContextualCallbacks, new HttpConnectionFactory(httpConfig));
connector.setPort(properties.getTrustedAuthPort());
// Idle time out for keep alive connections
// time out with out requests?
connector.setIdleTimeout(properties.getTrustedAuthPortIdleTimeout());
serverForContextualCallbacks.setConnectors(new org.eclipse.jetty.server.Connector[]{connector});
return serverForContextualCallbacks;
}
示例13: createServer
import org.eclipse.jetty.server.SecureRequestCustomizer; //导入依赖的package包/类
private Server createServer(URI endpointURI, boolean needClientAuth) {
if ("ws".equals(endpointURI.getScheme())) {
return new Server(endpointURI.getPort());
}
else if ("wss".equals(endpointURI.getScheme())) {
// see http://git.eclipse.org/c/jetty/org.eclipse.jetty.project.git/tree/examples/embedded/src/main/java/org/eclipse/jetty/embedded/ManyConnectors.java
// http://git.eclipse.org/c/jetty/org.eclipse.jetty.project.git/tree/examples/embedded/src/main/java/org/eclipse/jetty/embedded/LikeJettyXml.java
Server server = new Server();
SslContextFactory sslContextFactory = new SslContextFactory();
sslContextFactory.setKeyStorePath(getStorePath("serverKeyStore.jks"));
sslContextFactory.setKeyStorePassword("passw0rd");
sslContextFactory.setKeyManagerPassword("passw0rd");
sslContextFactory.setCertAlias("default");
sslContextFactory.setNeedClientAuth(needClientAuth);
sslContextFactory.setTrustStorePath(getStorePath("serverTrustStore.jks"));
sslContextFactory.setTrustStorePassword("passw0rd");
HttpConfiguration httpsConfig = new HttpConfiguration();
httpsConfig.addCustomizer(new SecureRequestCustomizer());
ServerConnector https= new ServerConnector(server,
new SslConnectionFactory(sslContextFactory,
HttpVersion.HTTP_1_1.asString()),
new HttpConnectionFactory(httpsConfig));
https.setPort(endpointURI.getPort());
server.addConnector(https);
return server;
}
else
throw new IllegalArgumentException("unrecognized uri: "+endpointURI);
}
示例14: newHttpConnectionFactory
import org.eclipse.jetty.server.SecureRequestCustomizer; //导入依赖的package包/类
private HttpConnectionFactory newHttpConnectionFactory() {
HttpConfiguration httpConfig = new HttpConfiguration();
httpConfig.setSendDateHeader(true);
httpConfig.setSendServerVersion(false);
httpConfig.setSendXPoweredBy(false);
httpConfig.setHeaderCacheSize(connectorConfig.headerCacheSize());
httpConfig.setOutputBufferSize(connectorConfig.outputBufferSize());
httpConfig.setRequestHeaderSize(connectorConfig.requestHeaderSize());
httpConfig.setResponseHeaderSize(connectorConfig.responseHeaderSize());
if (connectorConfig.ssl().enabled()) {
httpConfig.addCustomizer(new SecureRequestCustomizer());
}
return new HttpConnectionFactory(httpConfig);
}
示例15: setupConnectors
import org.eclipse.jetty.server.SecureRequestCustomizer; //导入依赖的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);
}