예제 #1
0
    @Override
    public X509Certificate[] getAcceptedIssuers() {
      X509Certificate ret[] = null;

      X509Certificate customAcceptedIssuers[] =
          (mCustomTrustManager != null)
              ? mCustomTrustManager.getAcceptedIssuers()
              : new X509Certificate[0];
      X509Certificate sysAcceptedIssuers[] =
          (mSysTrustManager != null)
              ? mSysTrustManager.getAcceptedIssuers()
              : new X509Certificate[0];

      if (customAcceptedIssuers == null) {
        customAcceptedIssuers = new X509Certificate[0];
      }

      if (sysAcceptedIssuers == null) {
        sysAcceptedIssuers = new X509Certificate[0];
      }

      int size = customAcceptedIssuers.length + sysAcceptedIssuers.length;

      if (size > 0) {

        ret = new X509Certificate[size];

        System.arraycopy(sysAcceptedIssuers, 0, ret, 0, sysAcceptedIssuers.length);
        System.arraycopy(
            customAcceptedIssuers, 0, ret, sysAcceptedIssuers.length, customAcceptedIssuers.length);
      }

      return ret;
    }
  public RippleTrustManager(KeyStore localKeyStore) {
    try {
      TrustManagerFactory tmf =
          TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
      tmf.init((KeyStore) null);

      defaultTrustManager = findX509TrustManager(tmf);
      if (defaultTrustManager == null) {
        throw new IllegalStateException("not found X509TrustManager");
      }

      localTrustManager = new LocalStoreX509TrustManager(localKeyStore);

      ArrayList<X509Certificate> allIssuers = new ArrayList<X509Certificate>();
      for (X509Certificate cert : defaultTrustManager.getAcceptedIssuers()) {
        allIssuers.add(cert);
      }
      for (X509Certificate cert : localTrustManager.getAcceptedIssuers()) {
        allIssuers.add(cert);
      }
      acceptedIssuers = allIssuers.toArray(new X509Certificate[allIssuers.size()]);
    } catch (GeneralSecurityException e) {
      throw new RuntimeException(e);
    }
  }
예제 #3
0
  private void init() {
    if (myTrustedCerts != null) {
      return;
    }
    Collection trustedCerts = new ArrayList();
    // load trusted certs from files.
    for (int i = 0; i < myServerCertFiles.length; i++) {
      X509Certificate cert = loadCertificate(myServerCertFiles[i]);
      if (cert != null) {
        trustedCerts.add(cert);
      }
    }

    X509TrustManager[] trustManagers = getDefaultTrustManagers();
    for (int i = 0; trustManagers != null && i < trustManagers.length; i++) {
      X509TrustManager trustManager = trustManagers[i];
      X509Certificate[] acceptedCerts = trustManager.getAcceptedIssuers();
      for (int c = 0; acceptedCerts != null && c < acceptedCerts.length; c++) {
        X509Certificate cert = acceptedCerts[c];
        trustedCerts.add(cert);
      }
    }
    myTrustedCerts =
        (X509Certificate[]) trustedCerts.toArray(new X509Certificate[trustedCerts.size()]);
  }
 @Override
 public X509Certificate[] getAcceptedIssuers() {
   final ArrayList<X509Certificate> list = new ArrayList<X509Certificate>();
   for (X509TrustManager tm : x509TrustManagers)
     list.addAll(Arrays.asList(tm.getAcceptedIssuers()));
   return list.toArray(new X509Certificate[list.size()]);
 }
 @Override
 public X509Certificate[] getAcceptedIssuers() {
   if (defaultManager == null) {
     return new X509Certificate[0];
   } else {
     return defaultManager.getAcceptedIssuers();
   }
 }
예제 #6
0
  /**
   * @return
   * @param trustManager der Trustmanager mit den Zertifikaten.
   */
  private static GenericIterator init(X509TrustManager trustManager) {
    try {
      X509Certificate[] list = trustManager.getAcceptedIssuers();
      List<CertObject> al = new ArrayList<CertObject>();
      for (int i = 0; i < list.length; ++i) {
        al.add(new CertObject(list[i]));
      }

      if (trustManager == Application.getSSLFactory().getTrustManager()) {
        // System-Zertifikat noch hinzufuegen
        al.add(new CertObject(Application.getSSLFactory().getSystemCertificate()));
      }
      Collections.sort(al);
      return PseudoIterator.fromArray(al.toArray(new CertObject[al.size()]));
    } catch (Exception e) {
      Logger.error("error while loading certificate list", e);
      try {
        return PseudoIterator.fromArray(new GenericObject[] {});
      } catch (Exception e2) {
        Logger.error("error while loading dummy list, useless", e2);
        return null;
      }
    }
  }
예제 #7
0
 @Override
 public X509Certificate[] getAcceptedIssuers() {
   return tm.getAcceptedIssuers();
 }
 public X509Certificate[] getAcceptedIssuers() {
   LOGGER.log(Level.FINE, "getAcceptedIssuers()");
   return defaultTrustManager.getAcceptedIssuers();
 }
 @Override
 public X509Certificate[] getAcceptedIssuers() {
   return trustManager.getAcceptedIssuers();
 }
예제 #10
0
 /*
  * Merely pass this through.
  */
 public X509Certificate[] getAcceptedIssuers() {
   return pkixTrustManager.getAcceptedIssuers();
 }
예제 #11
0
 public X509Certificate[] getAcceptedIssuers() {
   return a.getAcceptedIssuers();
 }
 public X509Certificate[] getAcceptedIssuers() {
   Log.d(TAG, "getAcceptedIssuers()");
   return defaultTrustManager.getAcceptedIssuers();
 }