本文整理汇总了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));
}
示例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");
}
示例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;
}
示例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());
}