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


Java SslContextFactory.setKeyStoreResource方法代碼示例

本文整理匯總了Java中org.eclipse.jetty.util.ssl.SslContextFactory.setKeyStoreResource方法的典型用法代碼示例。如果您正苦於以下問題:Java SslContextFactory.setKeyStoreResource方法的具體用法?Java SslContextFactory.setKeyStoreResource怎麽用?Java SslContextFactory.setKeyStoreResource使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.eclipse.jetty.util.ssl.SslContextFactory的用法示例。


在下文中一共展示了SslContextFactory.setKeyStoreResource方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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);
}
 
開發者ID:thinline72,項目名稱:rpc-example,代碼行數:24,代碼來源:JettyHttp2ServerConfig.java

示例2: configureSslKeyStore

import org.eclipse.jetty.util.ssl.SslContextFactory; //導入方法依賴的package包/類
private void configureSslKeyStore(SslContextFactory factory, Ssl ssl) {
    try {
        URL url = ResourceUtils.getURL(ssl.getKeyStore());
        factory.setKeyStoreResource(Resource.newResource(url));
    }
    catch (IOException ex) {
        throw new EmbeddedServletContainerException(
                "Could not find key store '" + ssl.getKeyStore() + "'", ex);
    }
    if (ssl.getKeyStoreType() != null) {
        factory.setKeyStoreType(ssl.getKeyStoreType());
    }
    if (ssl.getKeyStoreProvider() != null) {
        factory.setKeyStoreProvider(ssl.getKeyStoreProvider());
    }
}
 
開發者ID:philwebb,項目名稱:spring-boot-concourse,代碼行數:17,代碼來源:JettyEmbeddedServletContainerFactory.java

示例3: configureSslKeyStore

import org.eclipse.jetty.util.ssl.SslContextFactory; //導入方法依賴的package包/類
private void configureSslKeyStore(SslContextFactory factory, Ssl ssl) {
    try {
        URL url = ResourceUtils.getURL(ssl.getKeyStore());
        factory.setKeyStoreResource(Resource.newResource(url));
    } catch (IOException ex) {
        throw new WebServerException(
                "Could not find key store '" + ssl.getKeyStore() + "'", ex);
    }

    if (ssl.getKeyStoreType() != null) {
        factory.setKeyStoreType(ssl.getKeyStoreType());
    }

    if (ssl.getKeyStoreProvider() != null) {
        factory.setKeyStoreProvider(ssl.getKeyStoreProvider());
    }
}
 
開發者ID:gdrouet,項目名稱:nightclazz-spring5,代碼行數:18,代碼來源:CustomJettyReactiveWebServerFactory.java

示例4: 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());
}
 
開發者ID:CognizantQAHub,項目名稱:Cognizant-Intelligent-Test-Scripter,代碼行數:16,代碼來源:EventServer.java

示例5: 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;
}
 
開發者ID:janweinschenker,項目名稱:servlet4-demo,代碼行數:48,代碼來源:ApplicationConfig.java

示例6: main

import org.eclipse.jetty.util.ssl.SslContextFactory; //導入方法依賴的package包/類
public static void main(String[] args) throws Exception {
    int timeout = (int) Duration.ONE_HOUR.getMilliseconds();

    Server server = new Server();
    SocketConnector connector = new SocketConnector();

    // Set some timeout options to make debugging easier.
    connector.setMaxIdleTime(timeout);
    connector.setSoLingerTime(-1);
    connector.setPort(8080);
    server.addConnector(connector);

    Resource keystore = Resource.newClassPathResource("/keystore");
    if (keystore != null && keystore.exists()) {
        // if a keystore for a SSL certificate is available, start a SSL
        // connector on port 8443.
        // By default, the quickstart comes with a Apache Wicket Quickstart
        // Certificate that expires about half way september 2021. Do not
        // use this certificate anywhere important as the passwords are
        // available in the source.

        connector.setConfidentialPort(8443);

        SslContextFactory factory = new SslContextFactory();
        factory.setKeyStoreResource(keystore);
        factory.setKeyStorePassword("wicket");
        factory.setTrustStoreResource(keystore);
        factory.setKeyManagerPassword("wicket");
        SslSocketConnector sslConnector = new SslSocketConnector(factory);
        sslConnector.setMaxIdleTime(timeout);
        sslConnector.setPort(8443);
        sslConnector.setAcceptors(4);
        server.addConnector(sslConnector);

        System.out.println("SSL access to the quickstart has been enabled on port 8443");
        System.out.println("You can access the application using SSL on https://localhost:8443");
        System.out.println();
    }

    WebAppContext bb = new WebAppContext();
    bb.setServer(server);
    bb.setContextPath("/");
    bb.setWar("src/main/webapp");

    // START JMX SERVER
    // MBeanServer mBeanServer = ManagementFactory.getPlatformMBeanServer();
    // MBeanContainer mBeanContainer = new MBeanContainer(mBeanServer);
    // server.getContainer().addEventListener(mBeanContainer);
    // mBeanContainer.start();

    server.setHandler(bb);

    try {
        System.out.println(">>> STARTING EMBEDDED JETTY SERVER, PRESS ANY KEY TO STOP");
        server.start();
        System.in.read();
        System.out.println(">>> STOPPING EMBEDDED JETTY SERVER");
        server.stop();
        server.join();
    } catch (Exception e) {
        e.printStackTrace();
        System.exit(1);
    }
}
 
開發者ID:sparsick,項目名稱:ansible-docker-talk,代碼行數:65,代碼來源:Start.java

示例7: main

import org.eclipse.jetty.util.ssl.SslContextFactory; //導入方法依賴的package包/類
/**
 * Main function, starts the jetty server.
 *
 * @param args
 */
public static void main(String[] args)
{
    System.setProperty("wicket.configuration", "development");

    Server server = new Server();

    HttpConfiguration http_config = new HttpConfiguration();
    http_config.setSecureScheme("https");
    http_config.setSecurePort(8443);
    http_config.setOutputBufferSize(32768);

    ServerConnector http = new ServerConnector(server, new HttpConnectionFactory(http_config));
    http.setPort(8080);
    http.setIdleTimeout(1000 * 60 * 60);

    server.addConnector(http);

    Resource keystore = Resource.newClassPathResource("/keystore");
    if (keystore != null && keystore.exists())
    {
        // if a keystore for a SSL certificate is available, start a SSL
        // connector on port 8443.
        // By default, the quickstart comes with a Apache Wicket Quickstart
        // Certificate that expires about half way september 2021. Do not
        // use this certificate anywhere important as the passwords are
        // available in the source.

        SslContextFactory sslContextFactory = new SslContextFactory();
        sslContextFactory.setKeyStoreResource(keystore);
        sslContextFactory.setKeyStorePassword("wicket");
        sslContextFactory.setKeyManagerPassword("wicket");

        HttpConfiguration https_config = new HttpConfiguration(http_config);
        https_config.addCustomizer(new SecureRequestCustomizer());

        ServerConnector https = new ServerConnector(server, new SslConnectionFactory(
            sslContextFactory, "http/1.1"), new HttpConnectionFactory(https_config));
        https.setPort(8443);
        https.setIdleTimeout(500000);

        server.addConnector(https);
        System.out.println("SSL access to the examples has been enabled on port 8443");
        System.out
            .println("You can access the application using SSL on https://localhost:8443");
        System.out.println();
    }

    WebAppContext bb = new WebAppContext();
    bb.setServer(server);
    bb.setContextPath("/");
    bb.setWar("src/main/webapp");

    // uncomment next line if you want to test with JSESSIONID encoded in the urls
    // ((AbstractSessionManager)
    // bb.getSessionHandler().getSessionManager()).setUsingCookies(false);

    server.setHandler(bb);

    MBeanServer mBeanServer = ManagementFactory.getPlatformMBeanServer();
    MBeanContainer mBeanContainer = new MBeanContainer(mBeanServer);
    server.addEventListener(mBeanContainer);
    server.addBean(mBeanContainer);

    try
    {
        server.start();
        server.join();
    }
    catch (Exception e)
    {
        e.printStackTrace();
        System.exit(100);
    }
}
 
開發者ID:pingunaut,項目名稱:wicket-stream-download-example,代碼行數:80,代碼來源:Start.java

示例8: main

import org.eclipse.jetty.util.ssl.SslContextFactory; //導入方法依賴的package包/類
public static void main(String[] args) throws Exception {
    int timeout = (int) Duration.ONE_HOUR.getMilliseconds();

    Server server = new Server();
    SocketConnector connector = new SocketConnector();

    // Set some timeout options to make debugging easier.
    connector.setMaxIdleTime(timeout);
    connector.setSoLingerTime(-1);
    connector.setPort(8090);
    server.addConnector(connector);

    Resource keystore = Resource.newClassPathResource("/keystore");
    if (keystore != null && keystore.exists()) {
        // if a keystore for a SSL certificate is available, start a SSL
        // connector on port 8443.
        // By default, the quickstart comes with a Apache Wicket Quickstart
        // Certificate that expires about half way september 2021. Do not
        // use this certificate anywhere important as the passwords are
        // available in the source.

        connector.setConfidentialPort(8443);

        SslContextFactory factory = new SslContextFactory();
        factory.setKeyStoreResource(keystore);
        factory.setKeyStorePassword("wicket");
        factory.setTrustStoreResource(keystore);
        factory.setKeyManagerPassword("wicket");
        SslSocketConnector sslConnector = new SslSocketConnector(factory);
        sslConnector.setMaxIdleTime(timeout);
        sslConnector.setPort(8443);
        sslConnector.setAcceptors(4);
        server.addConnector(sslConnector);

        System.out.println("SSL access to the quickstart has been enabled on port 8443");
        System.out.println("You can access the application using SSL on https://localhost:8443");
        System.out.println();
    }

    WebAppContext bb = new WebAppContext();
    bb.setServer(server);
    bb.setContextPath("/");
    bb.setWar("src/main/webapp");

    // START JMX SERVER
    // MBeanServer mBeanServer = ManagementFactory.getPlatformMBeanServer();
    // MBeanContainer mBeanContainer = new MBeanContainer(mBeanServer);
    // server.getContainer().addEventListener(mBeanContainer);
    // mBeanContainer.start();

    server.setHandler(bb);

    try {
        System.out.println(">>> STARTING EMBEDDED JETTY SERVER, PRESS ANY KEY TO STOP");
        server.start();
        System.in.read();
        System.out.println(">>> STOPPING EMBEDDED JETTY SERVER");
        server.stop();
        server.join();
    } catch (Exception e) {
        e.printStackTrace();
        System.exit(1);
    }
}
 
開發者ID:acdh-oeaw,項目名稱:vlo-curation,代碼行數:65,代碼來源:Start.java


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