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


Java TestSslUtils類代碼示例

本文整理匯總了Java中org.apache.kafka.test.TestSslUtils的典型用法代碼示例。如果您正苦於以下問題:Java TestSslUtils類的具體用法?Java TestSslUtils怎麽用?Java TestSslUtils使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


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

示例1: testSslFactoryConfiguration

import org.apache.kafka.test.TestSslUtils; //導入依賴的package包/類
@Test
public void testSslFactoryConfiguration() throws Exception {
    File trustStoreFile = File.createTempFile("truststore", ".jks");
    Map<String, Object> serverSslConfig = TestSslUtils.createSslConfig(false, true, Mode.SERVER, trustStoreFile, "server");
    SslFactory sslFactory = new SslFactory(Mode.SERVER);
    sslFactory.configure(serverSslConfig);
    //host and port are hints
    SSLEngine engine = sslFactory.createSslEngine("localhost", 0);
    assertNotNull(engine);
    String[] expectedProtocols = {"TLSv1.2"};
    assertArrayEquals(expectedProtocols, engine.getEnabledProtocols());
    assertEquals(false, engine.getUseClientMode());
}
 
開發者ID:YMCoding,項目名稱:kafka-0.11.0.0-src-with-comment,代碼行數:14,代碼來源:SslFactoryTest.java

示例2: testSslFactoryWithoutPasswordConfiguration

import org.apache.kafka.test.TestSslUtils; //導入依賴的package包/類
@Test
public void testSslFactoryWithoutPasswordConfiguration() throws Exception {
    File trustStoreFile = File.createTempFile("truststore", ".jks");
    Map<String, Object> serverSslConfig = TestSslUtils.createSslConfig(false, true, Mode.SERVER, trustStoreFile, "server");
    // unset the password
    serverSslConfig.remove(SslConfigs.SSL_TRUSTSTORE_PASSWORD_CONFIG);
    SslFactory sslFactory = new SslFactory(Mode.SERVER);
    try {
        sslFactory.configure(serverSslConfig);
    } catch (Exception e) {
        fail("An exception was thrown when configuring the truststore without a password: " + e);
    }
}
 
開發者ID:YMCoding,項目名稱:kafka-0.11.0.0-src-with-comment,代碼行數:14,代碼來源:SslFactoryTest.java

示例3: testClientMode

import org.apache.kafka.test.TestSslUtils; //導入依賴的package包/類
@Test
public void testClientMode() throws Exception {
    File trustStoreFile = File.createTempFile("truststore", ".jks");
    Map<String, Object> clientSslConfig = TestSslUtils.createSslConfig(false, true, Mode.CLIENT, trustStoreFile, "client");
    SslFactory sslFactory = new SslFactory(Mode.CLIENT);
    sslFactory.configure(clientSslConfig);
    //host and port are hints
    SSLEngine engine = sslFactory.createSslEngine("localhost", 0);
    assertTrue(engine.getUseClientMode());
}
 
開發者ID:YMCoding,項目名稱:kafka-0.11.0.0-src-with-comment,代碼行數:11,代碼來源:SslFactoryTest.java

示例4: CertStores

import org.apache.kafka.test.TestSslUtils; //導入依賴的package包/類
private CertStores(boolean server, String commonName, TestSslUtils.CertificateBuilder certBuilder) throws Exception {
    String name = server ? "server" : "client";
    Mode mode = server ? Mode.SERVER : Mode.CLIENT;
    File truststoreFile = File.createTempFile(name + "TS", ".jks");
    sslConfig = TestSslUtils.createSslConfig(!server, true, mode, truststoreFile, name, commonName, certBuilder);
    if (server)
        sslConfig.put(SslConfigs.PRINCIPAL_BUILDER_CLASS_CONFIG, Class.forName(SslConfigs.DEFAULT_PRINCIPAL_BUILDER_CLASS));
}
 
開發者ID:YMCoding,項目名稱:kafka-0.11.0.0-src-with-comment,代碼行數:9,代碼來源:CertStores.java

示例5: setUp

import org.apache.kafka.test.TestSslUtils; //導入依賴的package包/類
@Before
public void setUp() throws Exception {
    File trustStoreFile = File.createTempFile("truststore", ".jks");

    Map<String, Object> sslServerConfigs = TestSslUtils.createSslConfig(false, true, Mode.SERVER, trustStoreFile, "server");
    sslServerConfigs.put(SslConfigs.PRINCIPAL_BUILDER_CLASS_CONFIG, Class.forName(SslConfigs.DEFAULT_PRINCIPAL_BUILDER_CLASS));
    this.server = new EchoServer(SecurityProtocol.SSL, sslServerConfigs);
    this.server.start();
    this.time = new MockTime();
    sslClientConfigs = TestSslUtils.createSslConfig(false, false, Mode.CLIENT, trustStoreFile, "client");
    this.channelBuilder = new SslChannelBuilder(Mode.CLIENT);
    this.channelBuilder.configure(sslClientConfigs);
    this.metrics = new Metrics();
    this.selector = new Selector(5000, metrics, time, "MetricGroup", channelBuilder);
}
 
開發者ID:YMCoding,項目名稱:kafka-0.11.0.0-src-with-comment,代碼行數:16,代碼來源:SslSelectorTest.java

示例6: CertStores

import org.apache.kafka.test.TestSslUtils; //導入依賴的package包/類
public CertStores(boolean server, String host) throws Exception {
    String name = server ? "server" : "client";
    Mode mode = server ? Mode.SERVER : Mode.CLIENT;
    File truststoreFile = File.createTempFile(name + "TS", ".jks");
    sslConfig = TestSslUtils.createSslConfig(!server, true, mode, truststoreFile, name, host);
    if (server)
        sslConfig.put(SslConfigs.PRINCIPAL_BUILDER_CLASS_CONFIG, Class.forName(SslConfigs.DEFAULT_PRINCIPAL_BUILDER_CLASS));
}
 
開發者ID:txazo,項目名稱:kafka,代碼行數:9,代碼來源:CertStores.java

示例7: setUp

import org.apache.kafka.test.TestSslUtils; //導入依賴的package包/類
@Before
public void setUp() throws Exception {
  try {
    trustStore = File.createTempFile("SslTest-truststore", ".jks");
    clientKeystore = File.createTempFile("SslTest-client-keystore", ".jks");
    serverKeystore = File.createTempFile("SslTest-server-keystore", ".jks");
  } catch (IOException ioe) {
    throw new RuntimeException("Unable to create temporary files for trust stores and keystores.");
  }
  Map<String, X509Certificate> certs = new HashMap<>();
  createKeystoreWithCert(clientKeystore, "client", certs);
  createKeystoreWithCert(serverKeystore, "server", certs);
  TestSslUtils.createTrustStore(trustStore.getAbsolutePath(), new Password(SSL_PASSWORD), certs);
}
 
開發者ID:confluentinc,項目名稱:rest-utils,代碼行數:15,代碼來源:SslTest.java

示例8: createKeystoreWithCert

import org.apache.kafka.test.TestSslUtils; //導入依賴的package包/類
private void createKeystoreWithCert(File file, String alias, Map<String, X509Certificate> certs) throws Exception {
  KeyPair keypair = TestSslUtils.generateKeyPair("RSA");
  // IMPORTANT: CN must be "localhost" because Jetty expects the server CN to be the FQDN.
  X509Certificate cCert = TestSslUtils.generateCertificate("CN=localhost, O=A client", keypair, 30, "SHA1withRSA");
  TestSslUtils.createKeyStore(file.getPath(), new Password(SSL_PASSWORD), alias, keypair.getPrivate(), cCert);
  certs.put(alias, cCert);
}
 
開發者ID:confluentinc,項目名稱:rest-utils,代碼行數:8,代碼來源:SslTest.java


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