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


Java SslConnectionFactory.getSslContextFactory方法代碼示例

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


在下文中一共展示了SslConnectionFactory.getSslContextFactory方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: httpsRequireClientCert

import org.eclipse.jetty.server.SslConnectionFactory; //導入方法依賴的package包/類
@Test
public void httpsRequireClientCert() throws Exception {
    Server server = BaseServerBuilder.create().httpsPort(8443).sslKeyStoreType(SslKeyStoreType.PKCS12)
            .sslKeyStorePath(ETC_SECURITY + "/server_keystore.p12").sslKeyStorePassword("pkcs12password")
            .sslTrustStoreType(SslKeyStoreType.JKS).sslRequireClientCert(true)
            .sslTrustStorePath(ETC_SECURITY + "/server_truststore.jks").sslTrustStorePassword("truststorepassword")
            .sslRequireClientCert(true).build();

    List<Connector> connectors = Arrays.asList(server.getConnectors());
    assertThat(server.getConnectors().length, is(1));
    // should have a server connector on port 8443
    ServerConnector connector = (ServerConnector) connectors.get(0);
    assertThat(connector.getPort(), is(8443));

    // should have a https connection factory
    SslConnectionFactory httpsConnectionFactory = connector.getConnectionFactory(SslConnectionFactory.class);
    assertThat(httpsConnectionFactory, is(notNullValue()));

    SslContextFactory sslContextFactory = httpsConnectionFactory.getSslContextFactory();

    // should require client cert authentication
    assertThat(sslContextFactory.getNeedClientAuth(), is(true));
}
 
開發者ID:elastisys,項目名稱:scale.commons,代碼行數:24,代碼來源:TestBaseServerBuilder.java

示例2: main

import org.eclipse.jetty.server.SslConnectionFactory; //導入方法依賴的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();

    // 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);

    ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS);
    context.setContextPath("/");
    server.setHandler(context);
    context.addServlet(new ServletHolder(createServlet(new HelloWorldSpeechlet())), "/hello");
    context.addServlet(new ServletHolder(createServlet(new MinecraftSpeechlet())), "/minecrafthelper");
    context.addServlet(new ServletHolder(createServlet(new DomoticzSpeechlet())), "/domoticz");
    context.addServlet(new ServletHolder(createServlet(new SessionSpeechlet())), "/session");
    server.start();
    server.join();
}
 
開發者ID:beckdac,項目名稱:alexa_domoticz_bridge,代碼行數:45,代碼來源:Launcher.java

示例3: https

import org.eclipse.jetty.server.SslConnectionFactory; //導入方法依賴的package包/類
/**
 * Creates a HTTPS server with a key store but without explicit trust store.
 * In these cases, the key store is used as trust store.
 */
@Test
public void https() throws Exception {
    Server server = BaseServerBuilder.create().httpsPort(8443).sslKeyStoreType(SslKeyStoreType.PKCS12)
            .sslKeyStorePath(ETC_SECURITY + "/server_keystore.p12").sslKeyStorePassword("pkcs12password").build();

    List<Connector> connectors = Arrays.asList(server.getConnectors());
    assertThat(server.getConnectors().length, is(1));
    // should have a server connector on port 8443
    ServerConnector connector = (ServerConnector) connectors.get(0);
    assertThat(connector.getPort(), is(8443));

    // should have a https connection factory
    SslConnectionFactory httpsConnectionFactory = connector.getConnectionFactory(SslConnectionFactory.class);
    assertThat(httpsConnectionFactory, is(notNullValue()));

    // should have a key store configured
    SslContextFactory sslContextFactory = httpsConnectionFactory.getSslContextFactory();
    assertThat(sslContextFactory, is(notNullValue()));
    assertThat(sslContextFactory.getKeyStoreType(), is(SslKeyStoreType.PKCS12.name()));
    assertThat(sslContextFactory.getKeyStoreResource().getFile().getPath(),
            is(ETC_SECURITY + "/server_keystore.p12"));

    // since no trust store was specified, it should fall back to use the
    // key store as trust store
    assertThat(sslContextFactory.getTrustStore(), is(sslContextFactory.getKeyStore()));

    // should not require client cert authentication
    assertThat(sslContextFactory.getNeedClientAuth(), is(false));
    // should not *want* client cert authentication (if offered)
    assertThat(sslContextFactory.getWantClientAuth(), is(false));
}
 
開發者ID:elastisys,項目名稱:scale.commons,代碼行數:36,代碼來源:TestBaseServerBuilder.java

示例4: httpsWithExplicitTrustStore

import org.eclipse.jetty.server.SslConnectionFactory; //導入方法依賴的package包/類
@Test
public void httpsWithExplicitTrustStore() throws Exception {
    Server server = BaseServerBuilder.create().httpsPort(8443).sslKeyStoreType(SslKeyStoreType.PKCS12)
            .sslKeyStorePath(ETC_SECURITY + "/server_keystore.p12").sslKeyStorePassword("pkcs12password")
            .sslTrustStoreType(SslKeyStoreType.JKS).sslTrustStorePath(ETC_SECURITY + "/server_truststore.jks")
            .sslTrustStorePassword("truststorepassword").build();

    List<Connector> connectors = Arrays.asList(server.getConnectors());
    assertThat(server.getConnectors().length, is(1));
    // should have a server connector on port 8443
    ServerConnector connector = (ServerConnector) connectors.get(0);
    assertThat(connector.getPort(), is(8443));

    // should have a https connection factory
    SslConnectionFactory httpsConnectionFactory = connector.getConnectionFactory(SslConnectionFactory.class);
    assertThat(httpsConnectionFactory, is(notNullValue()));

    // should have a key store configured
    SslContextFactory sslContextFactory = httpsConnectionFactory.getSslContextFactory();
    assertThat(sslContextFactory, is(notNullValue()));
    assertThat(sslContextFactory.getTrustStoreType(), is(SslKeyStoreType.JKS.name()));
    assertThat(sslContextFactory.getTrustStoreResource().getFile().getPath(),
            is(ETC_SECURITY + "/server_truststore.jks"));

    // should not require client cert authentication
    assertThat(sslContextFactory.getNeedClientAuth(), is(false));
    // should not *want* client cert authentication (if offered)
    assertThat(sslContextFactory.getWantClientAuth(), is(false));
}
 
開發者ID:elastisys,項目名稱:scale.commons,代碼行數:30,代碼來源:TestBaseServerBuilder.java

示例5: main

import org.eclipse.jetty.server.SslConnectionFactory; //導入方法依賴的package包/類
/**
 * Configures and sets up a Jetty server.
 * @param args
 * @throws Exception
 */
public static void main(final String[] args) throws Exception {
  // Configure logging to output to the console with default level of
  // INFO.
  BasicConfigurator.configure();

  Server server = new Server();

  // Configure SSL from system properties.
  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);

  // Configure HTTPS server.
  HttpConfiguration httpConf = new HttpConfiguration();
  httpConf.setSecurePort(PORT);
  httpConf.setSecureScheme(HTTPS_SCHEME);
  httpConf.addCustomizer(new SecureRequestCustomizer());
  HttpConnectionFactory httpConnectionFactory =
      new HttpConnectionFactory(httpConf);

  // Set up the servlets.
  ServerConnector serverConnector = new ServerConnector(
      server, sslConnectionFactory, httpConnectionFactory);
  serverConnector.setPort(PORT);

  Connector[] connectors = new Connector[1];
  connectors[0] = serverConnector;
  server.setConnectors(connectors);

  ServletContextHandler context =
      new ServletContextHandler(ServletContextHandler.SESSIONS);
  context.setContextPath("/");
  server.setHandler(context);
  context.addServlet(new ServletHolder(
      createServlet(new EchoQuerySpeechlet())), "/echoquery");
  server.start();
  server.join();
}
 
開發者ID:vqtran,項目名稱:EchoQuery,代碼行數:49,代碼來源:Launcher.java


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