private Principal[] getPrincipals(GeneralNames names) {
    Object[] p = this.getNames(names.getNames());
    List l = new ArrayList();

    for (int i = 0; i != p.length; i++) {
      if (p[i] instanceof Principal) {
        l.add(p[i]);
      }
    }

    return (Principal[]) l.toArray(new Principal[l.size()]);
  }
  private boolean matchesDN(X509Principal subject, GeneralNames targets) {
    GeneralName[] names = targets.getNames();

    for (int i = 0; i != names.length; i++) {
      GeneralName gn = names[i];

      if (gn.getTagNo() == GeneralName.directoryName) {
        try {
          if (new X509Principal(((ASN1Encodable) gn.getName()).getEncoded()).equals(subject)) {
            return true;
          }
        } catch (IOException e) {
        }
      }
    }

    return false;
  }