当前位置: 首页>>代码示例>>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;未经允许,请勿转载。