本文整理匯總了Java中org.eclipse.jetty.util.ssl.SslContextFactory.start方法的典型用法代碼示例。如果您正苦於以下問題:Java SslContextFactory.start方法的具體用法?Java SslContextFactory.start怎麽用?Java SslContextFactory.start使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.eclipse.jetty.util.ssl.SslContextFactory
的用法示例。
在下文中一共展示了SslContextFactory.start方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getSslContextFactory
import org.eclipse.jetty.util.ssl.SslContextFactory; //導入方法依賴的package包/類
public SslContextFactory getSslContextFactory() throws GeneralSecurityException, IOException {
SslContextFactory sslContextFactory = new SslContextFactory();
KeyStore keyStore = KeyStore.getInstance(properties.getProperty(MINIFI_C2_SERVER_KEYSTORE_TYPE));
Path keyStorePath = Paths.get(C2_SERVER_HOME).resolve(properties.getProperty(MINIFI_C2_SERVER_KEYSTORE)).toAbsolutePath();
logger.debug("keystore path: " + keyStorePath);
try (InputStream inputStream = Files.newInputStream(keyStorePath)) {
keyStore.load(inputStream, properties.getProperty(MINIFI_C2_SERVER_KEYSTORE_PASSWD).toCharArray());
}
sslContextFactory.setKeyStore(keyStore);
sslContextFactory.setKeyManagerPassword(properties.getProperty(MINIFI_C2_SERVER_KEY_PASSWD));
sslContextFactory.setWantClientAuth(true);
String trustStorePath = Paths.get(C2_SERVER_HOME).resolve(properties.getProperty(MINIFI_C2_SERVER_TRUSTSTORE)).toAbsolutePath().toFile().getAbsolutePath();
logger.debug("truststore path: " + trustStorePath);
sslContextFactory.setTrustStorePath(trustStorePath);
sslContextFactory.setTrustStoreType(properties.getProperty(MINIFI_C2_SERVER_TRUSTSTORE_TYPE));
sslContextFactory.setTrustStorePassword(properties.getProperty(MINIFI_C2_SERVER_TRUSTSTORE_PASSWD));
try {
sslContextFactory.start();
} catch (Exception e) {
throw new IOException(e);
}
return sslContextFactory;
}
示例2: getSslContextFactory
import org.eclipse.jetty.util.ssl.SslContextFactory; //導入方法依賴的package包/類
private static SslContextFactory getSslContextFactory(String password, InputStream key) {
SslContextFactory sslContextFactory1 = new SslContextFactory(true);
try {
//init KeyStore
final char[] pwdChars = password.toCharArray();
final KeyStore keyStore = KeyStore.getInstance("PKCS12");
keyStore.load(key, pwdChars);
final KeyManagerFactory keyManagerFactory = KeyManagerFactory.getInstance("SunX509");
keyManagerFactory.init(keyStore, pwdChars);
//init TrustManager
final TrustManagerFactory trustManagerFactory = TrustManagerFactory.getInstance("SunX509");
trustManagerFactory.init((KeyStore) null);
TrustManager[] trustManagers = trustManagerFactory.getTrustManagers();
//init SSLContext
final SSLContext sslContext = SSLContext.getInstance("TLSv1.2");
sslContext.init(keyManagerFactory.getKeyManagers(), trustManagers, null);
sslContextFactory1.setSslContext(sslContext);
sslContextFactory1.start();
} catch (Exception e) {
log.error("create sslContextFactory error.", e);
}
return sslContextFactory1;
}
示例3: getSslContext
import org.eclipse.jetty.util.ssl.SslContextFactory; //導入方法依賴的package包/類
@SuppressWarnings("unused") //TODO(bzz) why unused?
private static SSLContext getSslContext(ZeppelinConfiguration conf)
throws Exception {
SslContextFactory scf = getSslContextFactory(conf);
if (!scf.isStarted()) {
scf.start();
}
return scf.getSslContext();
}
示例4: connectWebsocket
import org.eclipse.jetty.util.ssl.SslContextFactory; //導入方法依賴的package包/類
public void connectWebsocket(String url, int sampleEveryN, boolean showMessages) {
try {
int timeout = 9000; // 9 seconds
System.out.println("NOTE: For GeoEvent Stream Service append /subscribe to the Web Socket URL");
System.out.println("Starting: If you see rapid connection lost messages. Ctrl-C and check you're URL");
SslContextFactory sslContextFactory = new SslContextFactory();
sslContextFactory.setTrustAll(true);
sslContextFactory.start();
final WebSocketClientFactory factory = new WebSocketClientFactory();
factory.start();
WebSocketClient client = factory.newWebSocketClient();
URI uri = new URI(url);
//WebSocketMessage msg = new WebSocketMessage();
//WebSocket.Connection websocketConnection = client.open(uri, new WebSocketMessage(sampleEveryN, showMessages)).get(5, TimeUnit.SECONDS);
WebSocket.Connection websocketConnection = client.open(uri, new WebSocketMessage(sampleEveryN, showMessages),timeout, TimeUnit.SECONDS);
//System.out.println(System.currentTimeMillis());
websocketConnection.setMaxTextMessageSize(MAX_MESSAGE_SIZE);
//System.out.println(timeout);
websocketConnection.setMaxIdleTime(timeout);
//websocketConnection.setMaxIdleTime(-1);
while (true) {
if (websocketConnection.isOpen()) {
// Wait a second
Thread.sleep(1000);
} else {
// Reopen
websocketConnection = client.open(uri, new WebSocketMessage(sampleEveryN, showMessages)).get(5, TimeUnit.SECONDS);
websocketConnection.setMaxTextMessageSize(MAX_MESSAGE_SIZE);
websocketConnection.setMaxIdleTime(timeout);
}
}
} catch (Exception e) {
e.printStackTrace();
}
}