本文整理汇总了Java中org.eclipse.jetty.util.ssl.SslContextFactory.setKeyStorePassword方法的典型用法代码示例。如果您正苦于以下问题:Java SslContextFactory.setKeyStorePassword方法的具体用法?Java SslContextFactory.setKeyStorePassword怎么用?Java SslContextFactory.setKeyStorePassword使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jetty.util.ssl.SslContextFactory
的用法示例。
在下文中一共展示了SslContextFactory.setKeyStorePassword方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: customize
import org.eclipse.jetty.util.ssl.SslContextFactory; //导入方法依赖的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.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));
}
示例3: 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);
}
示例4: addHttpsConnector
import org.eclipse.jetty.util.ssl.SslContextFactory; //导入方法依赖的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: getSSLConnectionFactory
import org.eclipse.jetty.util.ssl.SslContextFactory; //导入方法依赖的package包/类
private SslConnectionFactory getSSLConnectionFactory() {
Resource keyStoreResource = null;
try {
keyStoreResource = Resource.newClassPathResource("localhost");
System.out.println(keyStoreResource);
} catch (Exception ex) {
Logger.getLogger(EventServer.class.getName()).log(Level.SEVERE, null, ex);
}
SslContextFactory sslContextFactory = new SslContextFactory();
sslContextFactory.setKeyStoreResource(keyStoreResource);
sslContextFactory.setKeyStorePassword(keyStorePassword);
sslContextFactory.setKeyManagerPassword(keyManagerPassword);
return new SslConnectionFactory(sslContextFactory, HttpVersion.HTTP_1_1.asString());
}
示例6: configureSslPasswords
import org.eclipse.jetty.util.ssl.SslContextFactory; //导入方法依赖的package包/类
private void configureSslPasswords(SslContextFactory factory, Ssl ssl) {
if (ssl.getKeyStorePassword() != null) {
factory.setKeyStorePassword(ssl.getKeyStorePassword());
}
if (ssl.getKeyPassword() != null) {
factory.setKeyManagerPassword(ssl.getKeyPassword());
}
}
示例7: 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);
}
示例8: 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");
}
}
示例9: 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;
}
示例10: 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();
}
示例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: configureSslPasswords
import org.eclipse.jetty.util.ssl.SslContextFactory; //导入方法依赖的package包/类
private void configureSslPasswords(SslContextFactory factory, Ssl ssl) {
if (ssl.getKeyStorePassword() != null) {
factory.setKeyStorePassword(ssl.getKeyStorePassword());
}
if (ssl.getKeyPassword() != null) {
factory.setKeyManagerPassword(ssl.getKeyPassword());
}
}
示例13: 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);
}
示例14: NetworkAssistantHttpsEngine
import org.eclipse.jetty.util.ssl.SslContextFactory; //导入方法依赖的package包/类
public NetworkAssistantHttpsEngine(int port) throws KeyStoreException, NoSuchAlgorithmException, CertificateException, IOException {
this.port = port;
this.server = new Server();
this.server.setSendServerVersion(false);
SslContextFactory contextFactory = new SslContextFactory(true);
// this looks like fun, doesn't it?!?
// contextFactory.setKeyStorePath() would be easier, but it can't handle
// paths from within the jar..
// ..and contextFactory.setKeyStoreInputStream() is deprecated
final String keyStorePath = "/mpo/dayon/common/security/X509";
final String keyStorePass = "spasspass";
KeyStore keyStore = KeyStore.getInstance(KeyStore.getDefaultType());
keyStore.load(NetworkAssistantHttpsEngine.class.getResourceAsStream(keyStorePath), keyStorePass.toCharArray());
contextFactory.setKeyStore(keyStore);
contextFactory.setKeyStorePassword(keyStorePass);
this.acceptor = new MySocketConnector(contextFactory);
this.server.setConnectors(new Connector[] { this.acceptor });
final HandlerList httpHandlers = new HandlerList();
{
final File jnlp = SystemUtilities.getOrCreateAppDirectory("jnlp");
if (jnlp == null) {
throw new RuntimeException("No JNLP directory!");
}
httpHandlers.addHandler(handler = new MyHttpHandler(jnlp.getAbsolutePath()));
}
this.server.setHandler(httpHandlers);
}
示例15: configureServerForHttp2
import org.eclipse.jetty.util.ssl.SslContextFactory; //导入方法依赖的package包/类
/**
* Configure the http2 server.
*
* @param server the server
* @return the server
*/
@VisibleForTesting
Server configureServerForHttp2(Server server) {
// HTTP Configuration
HttpConfiguration http11Config = new HttpConfiguration();
http11Config.setSecureScheme("https");
http11Config.setSecurePort(httpsPort);
// SSL Context Factory for HTTPS and HTTP/2
SslContextFactory sslContextFactory = new SslContextFactory();
sslContextFactory.setKeyStoreResource(newClassPathResource("sample.jks"));
sslContextFactory.setKeyStorePassword("secret");
sslContextFactory.setKeyManagerPassword("secret");
sslContextFactory.setCipherComparator(HTTP2Cipher.COMPARATOR);
sslContextFactory.setUseCipherSuitesOrder(true);
// HTTPS Configuration
HttpConfiguration httpsConfig = new HttpConfiguration(http11Config);
httpsConfig.addCustomizer(new SecureRequestCustomizer());
// HTTP/2 Connection Factory
HTTP2ServerConnectionFactory h2 = new HTTP2ServerConnectionFactory(httpsConfig);
NegotiatingServerConnectionFactory.checkProtocolNegotiationAvailable();
ALPNServerConnectionFactory alpnServerConnectionFactory = new ALPNServerConnectionFactory();
alpnServerConnectionFactory.setDefaultProtocol("h2");
alpnServerConnectionFactory.getALPNProcessor();
// SSL Connection Factory
SslConnectionFactory sslConnectionFactory =
new SslConnectionFactory(sslContextFactory,
alpnServerConnectionFactory.getProtocol());
// HTTP/2 Connector
ServerConnector http2Connector =
new ServerConnector(server, sslConnectionFactory, alpnServerConnectionFactory, h2,
new HttpConnectionFactory(httpsConfig));
http2Connector.setPort(httpPort);
server.addConnector(http2Connector);
return server;
}