本文整理汇总了Java中org.eclipse.jetty.util.ssl.SslContextFactory.setKeyStorePath方法的典型用法代码示例。如果您正苦于以下问题:Java SslContextFactory.setKeyStorePath方法的具体用法?Java SslContextFactory.setKeyStorePath怎么用?Java SslContextFactory.setKeyStorePath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jetty.util.ssl.SslContextFactory
的用法示例。
在下文中一共展示了SslContextFactory.setKeyStorePath方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createConnector
import org.eclipse.jetty.util.ssl.SslContextFactory; //导入方法依赖的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));
}
示例2: setupSSL
import org.eclipse.jetty.util.ssl.SslContextFactory; //导入方法依赖的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);
}
示例3: createSSLServerConnector
import org.eclipse.jetty.util.ssl.SslContextFactory; //导入方法依赖的package包/类
private ServerConnector createSSLServerConnector(Connector connectorConfig)
{
SslContextFactory sslFact = new SslContextFactory();
if (StringUtils.isNotBlank(connectorConfig.getKeyStorePath()))
{
sslFact.setKeyStorePath(connectorConfig.getKeyStorePath());
}
if (StringUtils.isNotBlank(connectorConfig.getKeyStorePassword()))
{
sslFact.setKeyStorePassword(connectorConfig.getKeyStorePassword());
}
if (StringUtils.isNotBlank(connectorConfig.getKeyManagerPassword()))
{
sslFact.setKeyManagerPassword(connectorConfig.getKeyManagerPassword());
}
if (StringUtils.isNotBlank(connectorConfig.getTrustStorePath()))
{
sslFact.setTrustStorePath(connectorConfig.getTrustStorePath());
}
if (StringUtils.isNotBlank(connectorConfig.getTrustStorePassword()))
{
sslFact.setTrustStorePassword(connectorConfig.getTrustStorePassword());
}
return new ServerConnector(internal, sslFact);
}
示例4: createSecureConnector
import org.eclipse.jetty.util.ssl.SslContextFactory; //导入方法依赖的package包/类
private void createSecureConnector(Properties properties) {
SslContextFactory ssl = new SslContextFactory();
if (properties.getProperty(KEYSTORE_LOCATION_KEY) != null) {
ssl.setKeyStorePath(properties.getProperty(KEYSTORE_LOCATION_KEY));
ssl.setKeyStorePassword(properties.getProperty(KEYSTORE_PASSWORD_KEY));
ssl.setKeyStoreType(properties.getProperty(KEYSTORE_TYPE_KEY));
}
if (properties.getProperty(TRUSTSTORE_LOCATION_KEY) != null) {
ssl.setTrustStorePath(properties.getProperty(TRUSTSTORE_LOCATION_KEY));
ssl.setTrustStorePassword(properties.getProperty(TRUSTSTORE_PASSWORD_KEY));
ssl.setTrustStoreType(properties.getProperty(TRUSTSTORE_TYPE_KEY));
ssl.setNeedClientAuth(Boolean.parseBoolean(properties.getProperty(NEED_CLIENT_AUTH_KEY, "true")));
}
// build the connector
final ServerConnector https = new ServerConnector(jetty, ssl);
// set host and port
https.setPort(Integer.parseInt(properties.getProperty(PORT_KEY, "0")));
https.setHost(properties.getProperty(HOST_KEY, "localhost"));
// Severely taxed environments may have significant delays when executing.
https.setIdleTimeout(30000L);
// add the connector
jetty.addConnector(https);
logger.info("Added an https connector on the host '{}' and port '{}'", new Object[]{https.getHost(), https.getPort()});
}
示例5: setUp
import org.eclipse.jetty.util.ssl.SslContextFactory; //导入方法依赖的package包/类
@BeforeClass
public static void setUp() throws Exception {
PullHttpChangeIngestorCommonTest.init();
SslContextFactory ssl = new SslContextFactory();
ssl.setKeyStorePath("./src/test/resources/localhost-ks.jks");
ssl.setKeyStorePassword("localtest");
ssl.setKeyStoreType("JKS");
ssl.setTrustStorePath("./src/test/resources/localhost-ts.jks");
ssl.setTrustStorePassword("localtest");
ssl.setTrustStoreType("JKS");
ssl.setNeedClientAuth(true);
// build the connector
final ServerConnector https = new ServerConnector(jetty, ssl);
// set host and port
https.setPort(0);
https.setHost("localhost");
// Severely taxed environments may have significant delays when executing.
https.setIdleTimeout(30000L);
// add the connector
jetty.addConnector(https);
jetty.start();
Thread.sleep(1000);
if (!jetty.isStarted()) {
throw new IllegalStateException("Jetty server not started");
}
}
示例6: httpsConnector
import org.eclipse.jetty.util.ssl.SslContextFactory; //导入方法依赖的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;
}
示例7: createServer
import org.eclipse.jetty.util.ssl.SslContextFactory; //导入方法依赖的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);
}
示例8: setupConnectors
import org.eclipse.jetty.util.ssl.SslContextFactory; //导入方法依赖的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: main
import org.eclipse.jetty.util.ssl.SslContextFactory; //导入方法依赖的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();
Config.loadProperties();
// 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);
SkySpeechlet sky = new SkySpeechlet();
discoverSkyBox(sky);
ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS);
context.setContextPath("/");
server.setHandler(context);
context.addServlet(new ServletHolder(createServlet(sky)), "/sky");
server.start();
server.join();
}
示例10: createSSLContextObject
import org.eclipse.jetty.util.ssl.SslContextFactory; //导入方法依赖的package包/类
SslContextFactory createSSLContextObject() {
String keyStorePath = System.getProperty(ZMS_KEYSTORE_PATH);
String keyStorePassword = System.getProperty(ZMS_KEYSTORE_PASSWORD);
String keyStoreType = System.getProperty(ZMS_KEYSTORE_TYPE, "PKCS12");
String trustStorePath = System.getProperty(ZMS_TRUSTSTORE_PATH);
String trustStorePassword = System.getProperty(ZMS_TRUSTSTORE_PASSWORD);
String trustStoreType = System.getProperty(ZMS_TRUSTSTORE_TYPE, "PKCS12");
SslContextFactory sslContextFactory = new SslContextFactory();
if (keyStorePath != null) {
sslContextFactory.setKeyStorePath(keyStorePath);
}
if (keyStorePassword != null) {
sslContextFactory.setKeyStorePassword(keyStorePassword);
}
sslContextFactory.setKeyStoreType(keyStoreType);
if (trustStorePath != null) {
sslContextFactory.setTrustStorePath(trustStorePath);
}
if (trustStorePassword != null) {
sslContextFactory.setTrustStorePassword(trustStorePassword);
}
sslContextFactory.setTrustStoreType(trustStoreType);
sslContextFactory.setWantClientAuth(true);
return sslContextFactory;
}
示例11: configureSslContextFactory
import org.eclipse.jetty.util.ssl.SslContextFactory; //导入方法依赖的package包/类
protected void configureSslContextFactory(SslContextFactory sslContextFactory) {
sslContextFactory.setKeyManagerPassword(pwd);
sslContextFactory.setKeyStorePassword(pwd);
URL keyStoreUrl = this.getClass().getClassLoader().getResource("jsse/localhost.ks");
try {
sslContextFactory.setKeyStorePath(keyStoreUrl.toURI().getPath());
} catch (URISyntaxException e) {
throw new RuntimeException(e.getMessage(), e);
}
sslContextFactory.setTrustStoreType("JKS");
}
示例12: prepareSsl
import org.eclipse.jetty.util.ssl.SslContextFactory; //导入方法依赖的package包/类
private SslConnectionFactory prepareSsl(ALPNServerConnectionFactory alpn) {
SslContextFactory sslContextFactory = new SslContextFactory();
sslContextFactory.setKeyStorePath(
Application.class.getResource("/keystore").toExternalForm());
sslContextFactory.setKeyStorePassword("changeit");
sslContextFactory.setCipherComparator(HTTP2Cipher.COMPARATOR);
sslContextFactory.setUseCipherSuitesOrder(true);
SslConnectionFactory ssl = new SslConnectionFactory(sslContextFactory,
alpn.getProtocol());
return ssl;
}
示例13: getAllConnectors
import org.eclipse.jetty.util.ssl.SslContextFactory; //导入方法依赖的package包/类
private Connector[] getAllConnectors(){
List<ServerConnector> availableConnectors = new ArrayList<>();
ServerConnector httpConnector = new ServerConnector(s);
httpConnector.setPort(settings.getPort());
HttpConfiguration https = new HttpConfiguration();
https.addCustomizer(new SecureRequestCustomizer());
availableConnectors.add(httpConnector);
if(settings.getSecurePortEnabled()){
SslContextFactory sslContextFactory = new SslContextFactory();
sslContextFactory.setKeyStorePath(settings.getSslRoot());
// The keys used (just from my simple example), TODO: Remove hardcoding of the pw. This is disgusting Paul!
sslContextFactory.setKeyStorePassword("123456");
sslContextFactory.setKeyManagerPassword("123456");
ServerConnector httpsConnector = new ServerConnector(s,
new SslConnectionFactory(sslContextFactory, "http/1.1"),
new HttpConnectionFactory(https));
httpsConnector.setPort(settings.getSecurePort());
availableConnectors.add(httpsConnector);
}
return availableConnectors.toArray(new Connector[availableConnectors.size()]);
}
示例14: getSslContextFactory
import org.eclipse.jetty.util.ssl.SslContextFactory; //导入方法依赖的package包/类
private static SslContextFactory getSslContextFactory() {
SslContextFactory sslContextFactory = new SslContextFactory();
sslContextFactory.setKeyStorePath(EmbeddedServer.class.getResource("/keystore.jks").toExternalForm());
sslContextFactory.setKeyStorePassword("password");
return sslContextFactory;
}
示例15: createSslContextFactory
import org.eclipse.jetty.util.ssl.SslContextFactory; //导入方法依赖的package包/类
private SslContextFactory createSslContextFactory() {
final SslContextFactory contextFactory = new SslContextFactory();
// if needClientAuth is false then set want to true so we can optionally use certs
if (properties.getNeedClientAuth()) {
logger.info("Setting Jetty's SSLContextFactory needClientAuth to true");
contextFactory.setNeedClientAuth(true);
} else {
logger.info("Setting Jetty's SSLContextFactory wantClientAuth to true");
contextFactory.setWantClientAuth(true);
}
/* below code sets JSSE system properties when values are provided */
// keystore properties
if (StringUtils.isNotBlank(properties.getKeyStorePath())) {
contextFactory.setKeyStorePath(properties.getKeyStorePath());
}
if (StringUtils.isNotBlank(properties.getKeyStoreType())) {
contextFactory.setKeyStoreType(properties.getKeyStoreType());
}
final String keystorePassword = properties.getKeyStorePassword();
final String keyPassword = properties.getKeyPassword();
if (StringUtils.isNotBlank(keystorePassword)) {
// if no key password was provided, then assume the keystore password is the same as the key password.
final String defaultKeyPassword = (StringUtils.isBlank(keyPassword)) ? keystorePassword : keyPassword;
contextFactory.setKeyManagerPassword(keystorePassword);
contextFactory.setKeyStorePassword(defaultKeyPassword);
} else if (StringUtils.isNotBlank(keyPassword)) {
// since no keystore password was provided, there will be no keystore integrity check
contextFactory.setKeyStorePassword(keyPassword);
}
// truststore properties
if (StringUtils.isNotBlank(properties.getTrustStorePath())) {
contextFactory.setTrustStorePath(properties.getTrustStorePath());
}
if (StringUtils.isNotBlank(properties.getTrustStoreType())) {
contextFactory.setTrustStoreType(properties.getTrustStoreType());
}
if (StringUtils.isNotBlank(properties.getTrustStorePassword())) {
contextFactory.setTrustStorePassword(properties.getTrustStorePassword());
}
return contextFactory;
}