private Object[] getNames() {
    GeneralNames name;

    if (form instanceof V2Form) {
      name = ((V2Form) form).getIssuerName();
    } else {
      name = (GeneralNames) form;
    }

    GeneralName[] names = name.getNames();

    List l = new ArrayList(names.length);

    for (int i = 0; i != names.length; i++) {
      if (names[i].getTagNo() == GeneralName.directoryName) {
        try {
          l.add(
              new X500Principal(
                  ((ASN1Encodable) names[i].getName()).toASN1Primitive().getEncoded()));
        } catch (IOException e) {
          throw new RuntimeException("badly formed Name object");
        }
      }
    }

    return l.toArray(new Object[l.size()]);
  }
  private boolean matchesDN(X500Principal 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 X500Principal(((ASN1Encodable) gn.getName()).toASN1Primitive().getEncoded())
              .equals(subject)) {
            return true;
          }
        } catch (IOException e) {
        }
      }
    }

    return false;
  }