public Principal getIssuerDN() {
   try {
     return new X509Principal(X500Name.getInstance(c.getIssuer().getEncoded()));
   } catch (IOException e) {
     return null;
   }
 }
 public X500Principal getCertificateIssuer() {
   if (certificateIssuer == null) {
     return null;
   }
   try {
     return new X500Principal(certificateIssuer.getEncoded());
   } catch (IOException e) {
     return null;
   }
 }
  private static Collection getAlternativeNames(byte[] extVal) throws CertificateParsingException {
    if (extVal == null) {
      return null;
    }
    try {
      Collection temp = new ArrayList();
      Enumeration it = ASN1Sequence.getInstance(extVal).getObjects();
      while (it.hasMoreElements()) {
        GeneralName genName = GeneralName.getInstance(it.nextElement());
        List list = new ArrayList();
        list.add(Integers.valueOf(genName.getTagNo()));
        switch (genName.getTagNo()) {
          case GeneralName.ediPartyName:
          case GeneralName.x400Address:
          case GeneralName.otherName:
            list.add(genName.getEncoded());
            break;
          case GeneralName.directoryName:
            list.add(X500Name.getInstance(RFC4519Style.INSTANCE, genName.getName()).toString());
            break;
          case GeneralName.dNSName:
          case GeneralName.rfc822Name:
          case GeneralName.uniformResourceIdentifier:
            list.add(((ASN1String) genName.getName()).getString());
            break;
          case GeneralName.registeredID:
            list.add(ASN1ObjectIdentifier.getInstance(genName.getName()).getId());
            break;
          case GeneralName.iPAddress:
            byte[] addrBytes = DEROctetString.getInstance(genName.getName()).getOctets();
            final String addr;
            try {
              addr = InetAddress.getByAddress(addrBytes).getHostAddress();
            } catch (UnknownHostException e) {
              continue;
            }
            list.add(addr);
            break;
          default:
            throw new IOException("Bad tag number: " + genName.getTagNo());
        }

        temp.add(Collections.unmodifiableList(list));
      }
      if (temp.size() == 0) {
        return null;
      }
      return Collections.unmodifiableCollection(temp);
    } catch (Exception e) {
      throw new CertificateParsingException(e.getMessage());
    }
  }
  private X500Name loadCertificateIssuer(boolean isIndirect, X500Name previousCertificateIssuer) {
    if (!isIndirect) {
      return null;
    }

    Extension ext = getExtension(Extension.certificateIssuer);
    if (ext == null) {
      return previousCertificateIssuer;
    }

    try {
      GeneralName[] names = GeneralNames.getInstance(ext.getParsedValue()).getNames();
      for (int i = 0; i < names.length; i++) {
        if (names[i].getTagNo() == GeneralName.directoryName) {
          return X500Name.getInstance(names[i].getName());
        }
      }
      return null;
    } catch (Exception e) {
      return null;
    }
  }
 public Principal getSubjectDN() {
   return new X509Principal(X500Name.getInstance(c.getSubject().toASN1Primitive()));
 }