public byte[] getEncoded() throws CRLException {
   try {
     return c.getEncoded(ASN1Encoding.DER);
   } catch (IOException e) {
     throw new CRLException(e.toString());
   }
 }
  private Extension getExtension(ASN1ObjectIdentifier oid) {
    Extensions exts = c.getExtensions();

    if (exts != null) {
      return exts.getExtension(oid);
    }

    return null;
  }
  public String toString() {
    StringBuffer buf = new StringBuffer();
    String nl = System.getProperty("line.separator");

    buf.append("      userCertificate: ").append(this.getSerialNumber()).append(nl);
    buf.append("       revocationDate: ").append(this.getRevocationDate()).append(nl);
    buf.append("       certificateIssuer: ").append(this.getCertificateIssuer()).append(nl);

    Extensions extensions = c.getExtensions();

    if (extensions != null) {
      Enumeration e = extensions.oids();
      if (e.hasMoreElements()) {
        buf.append("   crlEntryExtensions:").append(nl);

        while (e.hasMoreElements()) {
          ASN1ObjectIdentifier oid = (ASN1ObjectIdentifier) e.nextElement();
          Extension ext = extensions.getExtension(oid);
          if (ext.getExtnValue() != null) {
            byte[] octs = ext.getExtnValue().getOctets();
            ASN1InputStream dIn = new ASN1InputStream(octs);
            buf.append("                       critical(").append(ext.isCritical()).append(") ");
            try {
              if (oid.equals(X509Extension.reasonCode)) {
                buf.append(CRLReason.getInstance(ASN1Enumerated.getInstance(dIn.readObject())))
                    .append(nl);
              } else if (oid.equals(X509Extension.certificateIssuer)) {
                buf.append("Certificate issuer: ")
                    .append(GeneralNames.getInstance(dIn.readObject()))
                    .append(nl);
              } else {
                buf.append(oid.getId());
                buf.append(" value = ").append(ASN1Dump.dumpAsString(dIn.readObject())).append(nl);
              }
            } catch (Exception ex) {
              buf.append(oid.getId());
              buf.append(" value = ").append("*****").append(nl);
            }
          } else {
            buf.append(nl);
          }
        }
      }
    }

    return buf.toString();
  }
  public byte[] getExtensionValue(String oid) {
    Extensions exts = c.getExtensions();

    if (exts != null) {
      Extension ext = exts.getExtension(new ASN1ObjectIdentifier(oid));

      if (ext != null) {
        try {
          return ext.getExtnValue().getEncoded();
        } catch (Exception e) {
          throw new RuntimeException("error encoding " + e.toString());
        }
      }
    }

    return null;
  }
  private Set getExtensionOIDs(boolean critical) {
    Extensions extensions = c.getExtensions();

    if (extensions != null) {
      Set set = new HashSet();
      Enumeration e = extensions.oids();

      while (e.hasMoreElements()) {
        ASN1ObjectIdentifier oid = (ASN1ObjectIdentifier) e.nextElement();
        Extension ext = extensions.getExtension(oid);

        if (critical == ext.isCritical()) {
          set.add(oid.getId());
        }
      }

      return set;
    }

    return null;
  }
 public boolean hasExtensions() {
   return c.getExtensions() != null;
 }
 public Date getRevocationDate() {
   return c.getRevocationDate().getDate();
 }
 public BigInteger getSerialNumber() {
   return c.getUserCertificate().getValue();
 }