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


Java X509ExtendedKeyManager.getCertificateChain方法代码示例

本文整理汇总了Java中javax.net.ssl.X509ExtendedKeyManager.getCertificateChain方法的典型用法代码示例。如果您正苦于以下问题:Java X509ExtendedKeyManager.getCertificateChain方法的具体用法?Java X509ExtendedKeyManager.getCertificateChain怎么用?Java X509ExtendedKeyManager.getCertificateChain使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.net.ssl.X509ExtendedKeyManager的用法示例。


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

示例1: implRun

import javax.net.ssl.X509ExtendedKeyManager; //导入方法依赖的package包/类
public void implRun() throws SSLException
{
  KeyExchangeAlgorithm kexalg = engine.session().suite.keyExchangeAlgorithm();
  X509ExtendedKeyManager km = engine.contextImpl.keyManager;
  Principal[] issuers = null; // XXX use TrustedAuthorities extension.
  keyAlias = km.chooseEngineServerAlias(kexalg.name(), issuers, engine);
  if (keyAlias == null)
    throw new SSLException("no certificates available");
  X509Certificate[] chain = km.getCertificateChain(keyAlias);
  engine.session().setLocalCertificates(chain);
  localCert = chain[0];
  serverKey = km.getPrivateKey(keyAlias);
  if (kexalg == DH_DSS || kexalg == DH_RSA)
    dhPair = new KeyPair(localCert.getPublicKey(),
                         km.getPrivateKey(keyAlias));
}
 
开发者ID:vilie,项目名称:javify,代码行数:17,代码来源:ServerHandshake.java

示例2: testKeyManagerProxyGetCertificateChain

import javax.net.ssl.X509ExtendedKeyManager; //导入方法依赖的package包/类
@Test
public void testKeyManagerProxyGetCertificateChain(@Mocked X509ExtendedKeyManager mockedKeyManager) throws CertificateException {
    new Expectations() {{
        mockedKeyManager.getCertificateChain("cert"); times = 1;
    }};

    KeyManagerProxy keyManagerProxy = new KeyManagerProxy(new KeyManager[]{mockedKeyManager});

    keyManagerProxy.getCertificateChain("cert");
}
 
开发者ID:yahoo,项目名称:athenz,代码行数:11,代码来源:KeyManagerProxyTest.java

示例3: getCertificateChain

import javax.net.ssl.X509ExtendedKeyManager; //导入方法依赖的package包/类
@Override
public X509Certificate[] getCertificateChain(String s) {
  X509ExtendedKeyManager km = keyManagerLocalRef.get();
  if (km != null) {
    return km.getCertificateChain(s);
  }
  return null;
}
 
开发者ID:hopshadoop,项目名称:hops,代码行数:9,代码来源:ReloadingX509KeyManager.java

示例4: testGoodKeyAndGoodCertificate

import javax.net.ssl.X509ExtendedKeyManager; //导入方法依赖的package包/类
@Test
public void testGoodKeyAndGoodCertificate() throws KeyManagementException, KeyStoreException {
    String generatorAlias = DynamicKeystoreGenerator.KEYSTORE_ALIAS;

    byte[] decodedPrivateKey = DynamicKeystoreGenerator.getDecodedPrivateKey(GOOD_TESTABLE_PRIVATE_KEY);
    Assert.assertEquals("Check private key decoded length", 1219, decodedPrivateKey.length);

    RSAPrivateKey rsaPrivateKey = DynamicKeystoreGenerator.generateRSAPrivateKey(decodedPrivateKey);
    Assert.assertEquals("RSA private key format", "PKCS#8", rsaPrivateKey.getFormat());
    Assert.assertEquals("RSA private key algorithm", "RSA", rsaPrivateKey.getAlgorithm());
    Assert.assertEquals("RSA private key length", 46, rsaPrivateKey.toString().length());

    InputStream is = new ByteArrayInputStream(GOOD_TESTABLE_CERTIFICATE.getBytes());
    Certificate certificate = DynamicKeystoreGenerator.generateX509Certificate(is);
    Assert.assertEquals("Certificate type ", "X.509", certificate.getType());
    // NOTE: the certificate length computed below appears to vary from
    // machine to machine.
    // Need to understand why that is. Commenting out for now.
    // Assert.assertEquals("Certificate length ", 2893,
    // certificate.toString().length());
    Assert.assertEquals("Certificate public key algorithm ", "RSA", certificate.getPublicKey().getAlgorithm());
    Assert.assertEquals("Certificate public key format ", "X.509", certificate.getPublicKey().getFormat());
    Assert.assertEquals("Certificate public key length ", 683, certificate.getPublicKey().toString().length());

    KeyStore keystore = DynamicKeystoreGenerator.createAndLoadDynamicKeystore(rsaPrivateKey, certificate);
    Assert.assertEquals("Keystore type ", "JKS", keystore.getType());
    Assert.assertEquals("Keystore certificate type ", "X.509", keystore.getCertificate(generatorAlias).getType());
    Assert.assertEquals("Keystore certificate public key format ", "X.509", keystore.getCertificate(generatorAlias).getType());

    KeyManager[] keyManagers = DynamicKeystoreGenerator.generateKeyManagersForDynamicKeystore(keystore);
    Assert.assertEquals(1, keyManagers.length);
    X509ExtendedKeyManager ekm = (X509ExtendedKeyManager) keyManagers[0];

    String[] aliases = ekm.getClientAliases("RSA", null);
    String alias = aliases[0];
    Assert.assertEquals("Keymanager Keystore client alias ", generatorAlias, alias);

    PrivateKey keyManagerPrivateKey = ekm.getPrivateKey(alias);
    Assert.assertEquals("Keymanager RSA private key format", "PKCS#8", keyManagerPrivateKey.getFormat());
    Assert.assertEquals("Keymanager RSA private key algorithm", "RSA", keyManagerPrivateKey.getAlgorithm());
    Assert.assertEquals("Keymanager RSA private key length", 46, keyManagerPrivateKey.toString().length());

    X509Certificate[] keyManagerCertificates = ekm.getCertificateChain(generatorAlias);
    X509Certificate keyManagerCert = keyManagerCertificates[0];
    Assert.assertEquals("Keymanager certificate chain length", 1, keyManagerCertificates.length);
    Assert.assertEquals("Keymanager certificate type", "X.509", keyManagerCert.getType());
    Assert.assertEquals("Keymanager certificate signature algorithm", "SHA256withRSA", keyManagerCert.getSigAlgName());
}
 
开发者ID:nuagenetworks,项目名称:java-bambou,代码行数:49,代码来源:DynamicKeystoreGeneratorTest.java


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