当前位置: 首页>>代码示例>>Java>>正文


Java PfxOptions类代码示例

本文整理汇总了Java中io.vertx.core.net.PfxOptions的典型用法代码示例。如果您正苦于以下问题:Java PfxOptions类的具体用法?Java PfxOptions怎么用?Java PfxOptions使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


PfxOptions类属于io.vertx.core.net包,在下文中一共展示了PfxOptions类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: example9

import io.vertx.core.net.PfxOptions; //导入依赖的package包/类
public void example9(Vertx vertx) {
  AmqpBridgeOptions bridgeOptions = new AmqpBridgeOptions();
  bridgeOptions.setSsl(true);

  PfxOptions trustOptions = new PfxOptions().setPath("path/to/pkcs12.truststore")
                                            .setPassword("password");
  bridgeOptions.setPfxTrustOptions(trustOptions);

  PfxOptions keyCertOptions = new PfxOptions().setPath("path/to/pkcs12.keystore")
                                              .setPassword("password");
  bridgeOptions.setPfxKeyCertOptions(keyCertOptions);

  AmqpBridge bridge = AmqpBridge.create(vertx, bridgeOptions);
  bridge.start("localhost", 5672, res -> {
    // ..do things with the bridge..
  });
}
 
开发者ID:vert-x3,项目名称:vertx-amqp-bridge,代码行数:18,代码来源:VertxAmqpBridgeExamples.java

示例2: testConnectWithSslToNonSslServerFails

import io.vertx.core.net.PfxOptions; //导入依赖的package包/类
@Test(timeout = 20000)
public void testConnectWithSslToNonSslServerFails(TestContext context) throws Exception {
  Async async = context.async();

  // Create a server that doesn't use ssl
  ProtonServerOptions serverOptions = new ProtonServerOptions();
  serverOptions.setSsl(false);

  protonServer = createServer(serverOptions, this::handleClientConnectionSessionReceiverOpen);

  // Try to connect the client and expect it to fail
  ProtonClientOptions clientOptions = new ProtonClientOptions();
  clientOptions.setSsl(true);
  PfxOptions pfxOptions = new PfxOptions().setPath(TRUSTSTORE).setPassword(PASSWORD);
  clientOptions.setPfxTrustOptions(pfxOptions);

  ProtonClient client = ProtonClient.create(vertx);
  client.connect(clientOptions, "localhost", protonServer.actualPort(), res -> {
    // Expect connect to fail due to remote peer not doing SSL
    context.assertFalse(res.succeeded());
    async.complete();
  });

  async.awaitSuccess();
}
 
开发者ID:vert-x3,项目名称:vertx-proton,代码行数:26,代码来源:ProtonClientSslTest.java

示例3: testConnectWithSslToServerWhileUsingTrustAll

import io.vertx.core.net.PfxOptions; //导入依赖的package包/类
@Test(timeout = 20000)
public void testConnectWithSslToServerWhileUsingTrustAll(TestContext context) throws Exception {
  Async async = context.async();

  // Create a server that accept a connection and expects a client connection+session+receiver
  ProtonServerOptions serverOptions = new ProtonServerOptions();
  serverOptions.setSsl(true);
  PfxOptions serverPfxOptions = new PfxOptions().setPath(KEYSTORE).setPassword(PASSWORD);
  serverOptions.setPfxKeyCertOptions(serverPfxOptions);

  protonServer = createServer(serverOptions, this::handleClientConnectionSessionReceiverOpen);

  // Try to connect the client and expect it to succeed due to trusting all certs
  ProtonClientOptions clientOptions = new ProtonClientOptions();
  clientOptions.setSsl(true);
  clientOptions.setTrustAll(true);

  ProtonClient client = ProtonClient.create(vertx);
  client.connect(clientOptions, "localhost", protonServer.actualPort(), res -> {
    // Expect connect to succeed
    context.assertTrue(res.succeeded());
    async.complete();
  });

  async.awaitSuccess();
}
 
开发者ID:vert-x3,项目名称:vertx-proton,代码行数:27,代码来源:ProtonClientSslTest.java

示例4: getTrustOptions

import io.vertx.core.net.PfxOptions; //导入依赖的package包/类
/**
 * Gets the trust options derived from the trust store properties.
 * 
 * @return The trust options or {@code null} if trust store path is not set or not supported.
 */
public final TrustOptions getTrustOptions() {

    if (trustStorePath == null) {
        return null;
    }

    final FileFormat format = FileFormat.orDetect(trustStoreFormat, trustStorePath);

    if (format == null) {
        LOG.debug("unsupported trust store format");
        return null;
    }

    switch (format) {
    case PEM:
        LOG.debug("using certificates from file [{}] as trust anchor", trustStorePath);
        return new PemTrustOptions().addCertPath(trustStorePath);
    case PKCS12:
        LOG.debug("using certificates from PKCS12 key store [{}] as trust anchor", trustStorePath);
        return new PfxOptions()
                .setPath(getTrustStorePath())
                .setPassword(getTrustStorePassword());
    case JKS:
        LOG.debug("using certificates from JKS key store [{}] as trust anchor", trustStorePath);
        return new JksOptions()
                .setPath(getTrustStorePath())
                .setPassword(getTrustStorePassword());
    default:
        LOG.debug("unsupported trust store format: {}", format);
        return null;
    }
}
 
开发者ID:eclipse,项目名称:hono,代码行数:38,代码来源:AbstractConfig.java

示例5: testPfxConfig

import io.vertx.core.net.PfxOptions; //导入依赖的package包/类
/**
 * Test a valid PFX configuration.
 */
@Test
public void testPfxConfig() {
    final TestConfig cfg = new TestConfig();
    cfg.setKeyStorePath(PREFIX_KEY_PATH + "honoKeyStore.p12");
    cfg.setKeyStorePassword("honokeys");

    final KeyCertOptions options = cfg.getKeyCertOptions();

    Assert.assertNotNull(options);
    Assert.assertThat(options, instanceOf(PfxOptions.class));
}
 
开发者ID:eclipse,项目名称:hono,代码行数:15,代码来源:AbstractConfigTest.java

示例6: start

import io.vertx.core.net.PfxOptions; //导入依赖的package包/类
@Override
public void start() {
    ProtonServerOptions options = new ProtonServerOptions();
    if(useTls) {
        options.setSsl(true);
        String path;
        if((path = config.get("jksKeyStorePath")) != null) {
            final JksOptions jksOptions = new JksOptions();
            jksOptions.setPath(path);
            jksOptions.setPassword(config.get("keyStorePassword"));
            options.setKeyStoreOptions(jksOptions);
        } else if((path = config.get("pfxKeyStorePath")) != null) {
            final PfxOptions pfxOptions = new PfxOptions();
            pfxOptions.setPath(path);
            pfxOptions.setPassword(config.get("keyStorePassword"));
            options.setPfxKeyCertOptions(pfxOptions);
        } else if((path = config.get("pemCertificatePath")) != null) {
            final PemKeyCertOptions pemKeyCertOptions = new PemKeyCertOptions();
            pemKeyCertOptions.setCertPath(path);
            pemKeyCertOptions.setKeyPath(config.get("pemKeyPath"));
            options.setPemKeyCertOptions(pemKeyCertOptions);
        } else {
            // use JDK settings?
        }

    }
    server = ProtonServer.create(vertx, options);

    server.saslAuthenticatorFactory(() -> new SaslAuthenticator(keycloakSessionFactory, config, useTls));
    server.connectHandler(this::connectHandler);
    LOG.info("Starting server on "+hostname+":"+ port);
    server.listen(port, hostname, event -> {
        if(event.failed())
        {
            LOG.error("Unable to listen for AMQP on "+hostname+":" + port, event.cause());
        }

    });
}
 
开发者ID:EnMasseProject,项目名称:enmasse,代码行数:40,代码来源:AmqpServer.java

示例7: example8

import io.vertx.core.net.PfxOptions; //导入依赖的package包/类
public void example8(Vertx vertx) {
  AmqpBridgeOptions bridgeOptions = new AmqpBridgeOptions();
  bridgeOptions.setSsl(true);

  PfxOptions trustOptions = new PfxOptions().setPath("path/to/pkcs12.truststore")
                                            .setPassword("password");
  bridgeOptions.setPfxTrustOptions(trustOptions);

  AmqpBridge bridge = AmqpBridge.create(vertx, bridgeOptions);
  bridge.start("localhost", 5672, "username", "password", res -> {
    // ..do things with the bridge..
  });
}
 
开发者ID:vert-x3,项目名称:vertx-amqp-bridge,代码行数:14,代码来源:VertxAmqpBridgeExamples.java

示例8: testConnectWithSslSucceeds

import io.vertx.core.net.PfxOptions; //导入依赖的package包/类
@Test(timeout = 20000)
public void testConnectWithSslSucceeds(TestContext context) throws Exception {
  Async async = context.async();

  ProtonServerOptions serverOptions = new ProtonServerOptions();
  serverOptions.setSsl(true);
  PfxOptions serverPfxOptions = new PfxOptions().setPath(KEYSTORE).setPassword(PASSWORD);
  serverOptions.setPfxKeyCertOptions(serverPfxOptions);

  mockServer = new MockServer(vertx, conn -> {
    handleBridgeStartupProcess(conn, context);
  }, serverOptions);

  // Start the bridge and verify is succeeds
  AmqpBridgeOptions bridgeOptions = new AmqpBridgeOptions();
  bridgeOptions.setSsl(true);
  PfxOptions clientPfxOptions = new PfxOptions().setPath(TRUSTSTORE).setPassword(PASSWORD);
  bridgeOptions.setPfxTrustOptions(clientPfxOptions);

  AmqpBridge bridge = AmqpBridge.create(vertx, bridgeOptions);
  bridge.start("localhost", mockServer.actualPort(), res -> {
    // Expect start to succeed
    context.assertTrue(res.succeeded(), "expected start to suceed");
    async.complete();
  });

  async.awaitSuccess();
}
 
开发者ID:vert-x3,项目名称:vertx-amqp-bridge,代码行数:29,代码来源:AmqpBridgeSslTest.java

示例9: testConnectWithSslToNonSslServerFails

import io.vertx.core.net.PfxOptions; //导入依赖的package包/类
@Test(timeout = 20000)
public void testConnectWithSslToNonSslServerFails(TestContext context) throws Exception {
  Async async = context.async();

  // Create a server that doesn't use ssl
  ProtonServerOptions serverOptions = new ProtonServerOptions();
  serverOptions.setSsl(false);

  mockServer = new MockServer(vertx, conn -> {
    handleBridgeStartupProcess(conn, context);
  }, serverOptions);

  // Try to start the bridge and expect it to fail
  AmqpBridgeOptions bridgeOptions = new AmqpBridgeOptions();
  bridgeOptions.setSsl(true);
  PfxOptions pfxOptions = new PfxOptions().setPath(TRUSTSTORE).setPassword(PASSWORD);
  bridgeOptions.setPfxTrustOptions(pfxOptions);

  AmqpBridge bridge = AmqpBridge.create(vertx, bridgeOptions);
  bridge.start("localhost", mockServer.actualPort(), res -> {
    // Expect start to fail due to remote peer not doing SSL
    context.assertFalse(res.succeeded(), "expected start to fail due to server not using secure transport");
    async.complete();
  });

  async.awaitSuccess();
}
 
开发者ID:vert-x3,项目名称:vertx-amqp-bridge,代码行数:28,代码来源:AmqpBridgeSslTest.java

示例10: testConnectWithSslToServerWithUntrustedKeyFails

import io.vertx.core.net.PfxOptions; //导入依赖的package包/类
@Test(timeout = 20000)
public void testConnectWithSslToServerWithUntrustedKeyFails(TestContext context) throws Exception {
  Async async = context.async();

  ProtonServerOptions serverOptions = new ProtonServerOptions();
  serverOptions.setSsl(true);
  PfxOptions serverPfxOptions = new PfxOptions().setPath(KEYSTORE).setPassword(PASSWORD);
  serverOptions.setPfxKeyCertOptions(serverPfxOptions);

  mockServer = new MockServer(vertx, conn -> {
    handleBridgeStartupProcess(conn, context);
  }, serverOptions);

  // Try to start the bridge and expect it to fail due to not trusting the server
  AmqpBridgeOptions bridgeOptions = new AmqpBridgeOptions();
  bridgeOptions.setSsl(true);
  PfxOptions pfxOptions = new PfxOptions().setPath(OTHER_CA_TRUSTSTORE).setPassword(PASSWORD);
  bridgeOptions.setPfxTrustOptions(pfxOptions);

  AmqpBridge bridge = AmqpBridge.create(vertx, bridgeOptions);
  bridge.start("localhost", mockServer.actualPort(), res -> {
    // Expect start to fail due to remote peer not being trusted
    context.assertFalse(res.succeeded(), "expected start to fail due to untrusted server");
    async.complete();
  });

  async.awaitSuccess();
}
 
开发者ID:vert-x3,项目名称:vertx-amqp-bridge,代码行数:29,代码来源:AmqpBridgeSslTest.java

示例11: testConnectWithSslToServerWhileUsingTrustAll

import io.vertx.core.net.PfxOptions; //导入依赖的package包/类
@Test(timeout = 20000)
public void testConnectWithSslToServerWhileUsingTrustAll(TestContext context) throws Exception {
  Async async = context.async();

  ProtonServerOptions serverOptions = new ProtonServerOptions();
  serverOptions.setSsl(true);
  PfxOptions serverPfxOptions = new PfxOptions().setPath(KEYSTORE).setPassword(PASSWORD);
  serverOptions.setPfxKeyCertOptions(serverPfxOptions);

  mockServer = new MockServer(vertx, conn -> {
    handleBridgeStartupProcess(conn, context);
  }, serverOptions);

  // Try to start the bridge and expect it to succeed due to trusting all certs
  AmqpBridgeOptions bridgeOptions = new AmqpBridgeOptions();
  bridgeOptions.setSsl(true);
  bridgeOptions.setTrustAll(true);

  AmqpBridge bridge = AmqpBridge.create(vertx, bridgeOptions);
  bridge.start("localhost", mockServer.actualPort(), res -> {
    // Expect start to succeed
    context.assertTrue(res.succeeded(), "expected start to suceed due to trusting all certs");
    async.complete();
  });

  async.awaitSuccess();
}
 
开发者ID:vert-x3,项目名称:vertx-amqp-bridge,代码行数:28,代码来源:AmqpBridgeSslTest.java

示例12: doHostnameVerificationTestImpl

import io.vertx.core.net.PfxOptions; //导入依赖的package包/类
private void doHostnameVerificationTestImpl(TestContext context, boolean verifyHost) throws Exception {

    Async async = context.async();

    ProtonServerOptions serverOptions = new ProtonServerOptions();
    serverOptions.setSsl(true);
    PfxOptions serverPfxOptions = new PfxOptions().setPath(WRONG_HOST_KEYSTORE).setPassword(PASSWORD);
    serverOptions.setPfxKeyCertOptions(serverPfxOptions);

    mockServer = new MockServer(vertx, conn -> {
      handleBridgeStartupProcess(conn, context);
    }, serverOptions);

    // Start the bridge
    AmqpBridgeOptions bridgeOptions = new AmqpBridgeOptions();
    bridgeOptions.setSsl(true);
    PfxOptions clientPfxOptions = new PfxOptions().setPath(TRUSTSTORE).setPassword(PASSWORD);
    bridgeOptions.setPfxTrustOptions(clientPfxOptions);

    // Verify/update the hostname verification settings
    context.assertEquals(VERIFY_HTTPS, bridgeOptions.getHostnameVerificationAlgorithm(),
        "expected host verification to be on by default");
    if (!verifyHost) {
      bridgeOptions.setHostnameVerificationAlgorithm(NO_VERIFY);
    }

    AmqpBridge bridge = AmqpBridge.create(vertx, bridgeOptions);
    bridge.start("localhost", mockServer.actualPort(), res -> {
      if (verifyHost) {
        // Expect start to fail
        context.assertFalse(res.succeeded(), "expected start to fail due to server cert not matching hostname");
      } else {
        // Expect start to succeed
        context.assertTrue(res.succeeded(), "expected start to suceed due to not verifying server hostname");
      }
      async.complete();
    });

    async.awaitSuccess();
  }
 
开发者ID:vert-x3,项目名称:vertx-amqp-bridge,代码行数:41,代码来源:AmqpBridgeSslTest.java

示例13: testConnectWithSslSucceeds

import io.vertx.core.net.PfxOptions; //导入依赖的package包/类
@Test(timeout = 20000)
public void testConnectWithSslSucceeds(TestContext context) throws Exception {
  Async async = context.async();

  // Create a server that accept a connection and expects a client connection+session+receiver
  ProtonServerOptions serverOptions = new ProtonServerOptions();
  serverOptions.setSsl(true);
  PfxOptions serverPfxOptions = new PfxOptions().setPath(KEYSTORE).setPassword(PASSWORD);
  serverOptions.setPfxKeyCertOptions(serverPfxOptions);

  protonServer = createServer(serverOptions, this::handleClientConnectionSessionReceiverOpen);

  // Connect the client and open a receiver to verify the connection works
  ProtonClientOptions clientOptions = new ProtonClientOptions();
  clientOptions.setSsl(true);
  PfxOptions clientPfxOptions = new PfxOptions().setPath(TRUSTSTORE).setPassword(PASSWORD);
  clientOptions.setPfxTrustOptions(clientPfxOptions);

  ProtonClient client = ProtonClient.create(vertx);
  client.connect(clientOptions, "localhost", protonServer.actualPort(), res -> {
    // Expect connect to succeed
    context.assertTrue(res.succeeded());
    ProtonConnection connection = res.result();
    connection.open();

    ProtonReceiver receiver = connection.createReceiver("some-address");

    receiver.openHandler(recvResult -> {
      context.assertTrue(recvResult.succeeded());
      LOG.trace("Client reciever open");
      async.complete();
    }).open();
  });

  async.awaitSuccess();
}
 
开发者ID:vert-x3,项目名称:vertx-proton,代码行数:37,代码来源:ProtonClientSslTest.java

示例14: testConnectWithSslToServerWithUntrustedKeyFails

import io.vertx.core.net.PfxOptions; //导入依赖的package包/类
@Test(timeout = 20000)
public void testConnectWithSslToServerWithUntrustedKeyFails(TestContext context) throws Exception {
  Async async = context.async();

  // Create a server that accept a connection and expects a client connection+session+receiver
  ProtonServerOptions serverOptions = new ProtonServerOptions();
  serverOptions.setSsl(true);
  PfxOptions serverPfxOptions = new PfxOptions().setPath(KEYSTORE).setPassword(PASSWORD);
  serverOptions.setPfxKeyCertOptions(serverPfxOptions);

  protonServer = createServer(serverOptions, this::handleClientConnectionSessionReceiverOpen);

  // Try to connect the client and expect it to fail due to us not trusting the server
  ProtonClientOptions clientOptions = new ProtonClientOptions();
  clientOptions.setSsl(true);
  PfxOptions pfxOptions = new PfxOptions().setPath(OTHER_CA_TRUSTSTORE).setPassword(PASSWORD);
  clientOptions.setPfxTrustOptions(pfxOptions);

  ProtonClient client = ProtonClient.create(vertx);
  client.connect(clientOptions, "localhost", protonServer.actualPort(), res -> {
    // Expect connect to fail due to remote peer not doing SSL
    context.assertFalse(res.succeeded());
    async.complete();
  });

  async.awaitSuccess();
}
 
开发者ID:vert-x3,项目名称:vertx-proton,代码行数:28,代码来源:ProtonClientSslTest.java

示例15: doClientCertificateTestImpl

import io.vertx.core.net.PfxOptions; //导入依赖的package包/类
private void doClientCertificateTestImpl(TestContext context, boolean supplyClientCert) throws InterruptedException,
                                                                                        ExecutionException {
  Async async = context.async();

  // Create a server that accept a connection and expects a client connection+session+receiver
  ProtonServerOptions serverOptions = new ProtonServerOptions();
  serverOptions.setSsl(true);
  serverOptions.setClientAuth(ClientAuth.REQUIRED);
  PfxOptions serverPfxOptions = new PfxOptions().setPath(KEYSTORE).setPassword(PASSWORD);
  serverOptions.setPfxKeyCertOptions(serverPfxOptions);

  PfxOptions pfxOptions = new PfxOptions().setPath(TRUSTSTORE).setPassword(PASSWORD);
  serverOptions.setPfxTrustOptions(pfxOptions);

  protonServer = createServer(serverOptions, this::handleClientConnectionSessionReceiverOpen);

  // Try to connect the client
  ProtonClientOptions clientOptions = new ProtonClientOptions();
  clientOptions.setSsl(true);
  clientOptions.setPfxTrustOptions(pfxOptions);

  if (supplyClientCert) {
    PfxOptions clientKeyPfxOptions = new PfxOptions().setPath(KEYSTORE_CLIENT).setPassword(PASSWORD);
    clientOptions.setPfxKeyCertOptions(clientKeyPfxOptions);
  }

  ProtonClient client = ProtonClient.create(vertx);
  client.connect(clientOptions, "localhost", protonServer.actualPort(), res -> {
    if (supplyClientCert) {
      // Expect connect to succeed
      context.assertTrue(res.succeeded());
    } else {
      // Expect connect to fail
      context.assertFalse(res.succeeded());
    }
    async.complete();
  });

  async.awaitSuccess();
}
 
开发者ID:vert-x3,项目名称:vertx-proton,代码行数:41,代码来源:ProtonClientSslTest.java


注:本文中的io.vertx.core.net.PfxOptions类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。