當前位置: 首頁>>代碼示例>>Java>>正文


Java SslContextFactory.start方法代碼示例

本文整理匯總了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;
}
 
開發者ID:apache,項目名稱:nifi-minifi,代碼行數:25,代碼來源:C2Properties.java

示例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;
}
 
開發者ID:linmingchang,項目名稱:java-apns2,代碼行數:25,代碼來源:ApnsHttp2ClientPool.java

示例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();
}
 
開發者ID:lorthos,項目名稱:incubator-zeppelin-druid,代碼行數:11,代碼來源:ZeppelinServer.java

示例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();
    }
}
 
開發者ID:david618,項目名稱:Simulator,代碼行數:53,代碼來源:WebSocketSink.java


注:本文中的org.eclipse.jetty.util.ssl.SslContextFactory.start方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。