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


Java X509TrustManager.getAcceptedIssuers方法代碼示例

本文整理匯總了Java中javax.net.ssl.X509TrustManager.getAcceptedIssuers方法的典型用法代碼示例。如果您正苦於以下問題:Java X509TrustManager.getAcceptedIssuers方法的具體用法?Java X509TrustManager.getAcceptedIssuers怎麽用?Java X509TrustManager.getAcceptedIssuers使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.net.ssl.X509TrustManager的用法示例。


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

示例1: create

import javax.net.ssl.X509TrustManager; //導入方法依賴的package包/類
private void create(Path path)
    throws KeyStoreException, IOException, NoSuchAlgorithmException, CertificateException,
    KeyManagementException {
  TrustManager[] trustManagers;
  KeyStore keyStore = KeyStore.getInstance(KeyStore.getDefaultType());
  keyStore.load(null, null);

  installCertificates(path, keyStore);

  String defaultAlgorithm = TrustManagerFactory.getDefaultAlgorithm();
  TrustManagerFactory trustManagerFactory = TrustManagerFactory.getInstance(defaultAlgorithm);
  trustManagerFactory.init(keyStore);
  trustManagers = trustManagerFactory.getTrustManagers();
  sslContext = SSLContext.getInstance("TLS");
  sslContext.init(null, trustManagers, null);
  trustManager = (X509TrustManager) trustManagers[0];
  X509Certificate[] acceptedIssuers = trustManager.getAcceptedIssuers();
  for (X509Certificate acceptedIssuer : acceptedIssuers) {
    logger.info("installed cert details: subject={} issuer={}",
        acceptedIssuer.getSubjectX500Principal(), acceptedIssuer.getIssuerX500Principal());
  }
}
 
開發者ID:dehora,項目名稱:outland,代碼行數:23,代碼來源:CertificateLoader.java

示例2: X509TrustManagerWrapper

import javax.net.ssl.X509TrustManager; //導入方法依賴的package包/類
public X509TrustManagerWrapper(X509TrustManager tm, boolean verifyServerCertificate) throws CertificateException {
    this.origTm = tm;
    this.verifyServerCert = verifyServerCertificate;

    if (verifyServerCertificate) {
        try {
            Set<TrustAnchor> anch = new HashSet<TrustAnchor>();
            for (X509Certificate cert : tm.getAcceptedIssuers()) {
                anch.add(new TrustAnchor(cert, null));
            }
            this.validatorParams = new PKIXParameters(anch);
            this.validatorParams.setRevocationEnabled(false);
            this.validator = CertPathValidator.getInstance("PKIX");
            this.certFactory = CertificateFactory.getInstance("X.509");
        } catch (Exception e) {
            throw new CertificateException(e);
        }
    }
}
 
開發者ID:bragex,項目名稱:the-vigilantes,代碼行數:20,代碼來源:ExportControlled.java

示例3: dumpTrustedCerts

import javax.net.ssl.X509TrustManager; //導入方法依賴的package包/類
public void dumpTrustedCerts() {
	try {
		TrustManagerFactory tmf = TrustManagerFactory.getInstance(TrustManagerFactory
				.getDefaultAlgorithm());
		tmf.init((KeyStore) null);
		X509TrustManager xtm = (X509TrustManager) tmf.getTrustManagers()[0];
		StringBuffer buff = new StringBuffer();
		for (X509Certificate cert : xtm.getAcceptedIssuers()) {
			String certStr = "S:" + cert.getSubjectDN().getName() + "\nI:"
					+ cert.getIssuerDN().getName();
			Log.d(TAG, certStr);
			buff.append(certStr + "\n\n");
		}
	} catch (GeneralSecurityException e) {
		throw new RuntimeException(e);
	}
}
 
開發者ID:CactusSoft,項目名稱:zabbkit-android,代碼行數:18,代碼來源:SSLManager.java

示例4: KeyStoresTrustManager

import javax.net.ssl.X509TrustManager; //導入方法依賴的package包/類
public KeyStoresTrustManager(KeyStore... keyStores) throws NoSuchAlgorithmException, KeyStoreException {
    super();

    for (KeyStore keystore : keyStores) {
        TrustManagerFactory factory = TrustManagerFactory.getInstance("JKS");
        factory.init(keystore);
        TrustManager[] tms = factory.getTrustManagers();
        if (tms.length == 0) {
            throw new NoSuchAlgorithmException("Unable to load keystore");
        }
        trustManagers.add((X509TrustManager) tms[0]);
    }

    //Build accepted issuers list
    Set<X509Certificate> issuers = new HashSet<X509Certificate>();
    for (X509TrustManager tm : trustManagers) {
        for (X509Certificate issuer : tm.getAcceptedIssuers()) {
            issuers.add(issuer);
        }
    }
    acceptedIssuers = issuers.toArray(new X509Certificate[issuers.size()]);
}
 
開發者ID:blackarbiter,項目名稱:Android_Code_Arbiter,代碼行數:23,代碼來源:KeyStoresTrustManager.java

示例5: getAcceptedIssuers

import javax.net.ssl.X509TrustManager; //導入方法依賴的package包/類
@Override
public X509Certificate[] getAcceptedIssuers() {
  X509Certificate[] issuers = EMPTY;
  X509TrustManager tm = trustManagerRef.get();
  if (tm != null) {
    issuers = tm.getAcceptedIssuers();
  }
  return issuers;
}
 
開發者ID:nucypher,項目名稱:hadoop-oss,代碼行數:10,代碼來源:ReloadingX509TrustManager.java

示例6: createSome

import javax.net.ssl.X509TrustManager; //導入方法依賴的package包/類
@Test
public void createSome() throws IOException {
  CertificateLoader securitySupport =
      new CertificateLoader("classpath:certs");

  X509TrustManager x509TrustManager = securitySupport.trustManager();
  SSLContext sslContext = securitySupport.sslContext();
  assertNotNull(x509TrustManager);
  assertNotNull(sslContext);
  X509Certificate[] acceptedIssuers = x509TrustManager.getAcceptedIssuers();

  assertEquals(3, acceptedIssuers.length);

  String issuer1 = "CN=Let's Encrypt Authority X1, O=Let's Encrypt, C=US";
  String issuer2 = "CN=Let's Encrypt Authority X2, O=Let's Encrypt, C=US";
  String issuer3 = "CN=Let's Encrypt Authority X3, O=Let's Encrypt, C=US";
  Set<String> seen = Sets.newHashSet();
  for (X509Certificate acceptedIssuer : acceptedIssuers) {
    String name = acceptedIssuer.getSubjectDN().getName();
    System.out.println(name);
    if (issuer1.equals(name)) {
      seen.add(name);
    }

    if (issuer2.equals(name)) {
      seen.add(name);
    }

    if (issuer3.equals(name)) {
      seen.add(name);
    }
  }

  assertEquals(3, seen.size());
  assertTrue(seen.contains(issuer1));
  assertTrue(seen.contains(issuer2));
  assertTrue(seen.contains(issuer3));
}
 
開發者ID:dehora,項目名稱:outland,代碼行數:39,代碼來源:CertificateLoaderTest.java

示例7: createNone

import javax.net.ssl.X509TrustManager; //導入方法依賴的package包/類
@Test
public void createNone() throws IOException {
  String fPath = "file://" + folder.newFolder().getAbsolutePath();
  CertificateLoader securitySupport = new CertificateLoader(fPath);
  X509TrustManager x509TrustManager = securitySupport.trustManager();
  SSLContext sslContext = securitySupport.sslContext();

  assertNotNull(x509TrustManager);
  assertNotNull(sslContext);

  X509Certificate[] acceptedIssuers = x509TrustManager.getAcceptedIssuers();
  assertEquals(0, acceptedIssuers.length);
}
 
開發者ID:dehora,項目名稱:outland,代碼行數:14,代碼來源:CertificateLoaderTest.java

示例8: buildTrustRootIndex

import javax.net.ssl.X509TrustManager; //導入方法依賴的package包/類
public TrustRootIndex buildTrustRootIndex(X509TrustManager trustManager) {
  return new BasicTrustRootIndex(trustManager.getAcceptedIssuers());
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:4,代碼來源:Platform.java

示例9: trustRootIndex

import javax.net.ssl.X509TrustManager; //導入方法依賴的package包/類
public TrustRootIndex trustRootIndex(X509TrustManager trustManager) {
    return new RealTrustRootIndex(trustManager.getAcceptedIssuers());
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:4,代碼來源:Platform.java


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