private String getSignatureText(X509Certificate cert, Calendar timestamp) {
   SimpleDateFormat df = new SimpleDateFormat("dd/MM/yyyy HH:mm"); // $NON-NLS-1$
   StringBuilder sb = new StringBuilder();
   sb.append(Messages.getString("PDFSignatureImpl.5"))
       .append(PdfPKCS7.getSubjectFields(cert).getField("CN")); // $NON-NLS-1$ //$NON-NLS-2$
   sb.append(Messages.getString("PDFSignatureImpl.7"))
       .append(df.format(timestamp.getTime())); // $NON-NLS-1$
   return sb.toString();
 }
 public ExtensionFileFilter getFilter() {
   return new ExtensionFileFilter(
       Messages.getString("PDFSignatureImpl.36"),
       new String[] {"PDF"}); // $NON-NLS-1$ //$NON-NLS-2$
 }
 public String validateForm() {
   if (null == entry) return Messages.getString("PDFSignatureImpl.34"); // $NON-NLS-1$
   else if (!entry.isValid()) return Messages.getString("PDFSignatureImpl.35"); // $NON-NLS-1$
   return null;
 }
  public DynamicForm getForm() {
    DynamicForm form = new DynamicForm(Messages.getString("PDFSignatureImpl.0")); // $NON-NLS-1$
    DynamicField fld = null;

    form.addField(
        fld =
            new DynamicField(
                Type.TEXTFIELD, Messages.getString("PDFSignatureImpl.28")) { // $NON-NLS-1$
              public void setValue(Object value) {
                super.setValue(value);
                setReason((String) value);
              }
            });
    fld.setValue(getReason());

    form.addField(
        fld =
            new DynamicField(
                Type.TEXTFIELD, Messages.getString("PDFSignatureImpl.29")) { // $NON-NLS-1$
              public void setValue(Object value) {
                super.setValue(value);
                setLocation((String) value);
              }
            });
    fld.setValue(getLocation());

    form.addField(
        fld =
            new DynamicField(
                Type.TEXTFIELD, Messages.getString("PDFSignatureImpl.30")) { // $NON-NLS-1$
              public void setValue(Object value) {
                super.setValue(value);
                setContact((String) value);
              }
            });
    fld.setValue(getContact());

    form.addField(
        fld =
            new DynamicField(
                Type.CHECKBOX, Messages.getString("PDFSignatureImpl.31")) { // $NON-NLS-1$
              public void setValue(Object value) {
                super.setValue(value);
                setSignatureVisible(value == null ? false : (Boolean) value);
              }
            });
    fld.setValue(isSignatureVisible());

    if (tsaLocation != null) {
      form.addField(
          fld =
              new DynamicField(
                  Type.CHECKBOX, Messages.getString("PDFSignatureImpl.32")) { // $NON-NLS-1$
                public void setValue(Object value) {
                  super.setValue(value);
                  setUseTSA(value == null ? false : (Boolean) value);
                }
              });
      fld.setValue(isUseTSA());
    }

    form.addField(
        new DynamicField(
            Type.SIGNATURE_CERTIFICATE, Messages.getString("PDFSignatureImpl.33")) { // $NON-NLS-1$
          public void setValue(Object value) {
            super.setValue(value);
            entry = (IDEntry) value;
          }
        });

    form.addField(
        new DynamicField(Type.IMAGE, Messages.getString("SignatureImage.4")) { // $NON-NLS-1$
          public void setValue(Object value) {
            super.setValue(value);
          }
        });

    return form;
  }
  // TODO concluir e validar a verifica��o de PDFs
  public String verify(final IVFile pdf) {
    // Certificados adicionados localmente
    KeyStore kall = PdfPKCS7.loadCacertsKeyStore();

    StringBuffer sb = new StringBuffer();
    final String nl = System.getProperty("line.separator"); // $NON-NLS-1$
    InputStream fin = null;
    try {
      boolean second = false;
      PdfReader reader = new PdfReader(fin = pdf.getInputStream());
      AcroFields af = reader.getAcroFields();
      ArrayList<?> names = af.getSignatureNames();
      if (names.isEmpty()) return Messages.getString("PDFSignatureImpl.9"); // $NON-NLS-1$
      for (Iterator<?> iter = names.iterator(); iter.hasNext(); ) {
        if (second) {
          sb.append(nl).append("  ======  ").append(nl).append(nl); // $NON-NLS-1$
        }
        String name = (String) iter.next();
        sb.append(Messages.getString("PDFSignatureImpl.11")).append(name).append(nl); // $NON-NLS-1$
        sb.append(Messages.getString("PDFSignatureImpl.12"))
            .append(
                af.signatureCoversWholeDocument(name)
                    ? Messages.getString("PDFSignatureImpl.13")
                    : Messages.getString("PDFSignatureImpl.14"))
            .append(nl); // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
        sb.append(Messages.getString("PDFSignatureImpl.15"))
            .append(af.getRevision(name))
            .append(Messages.getString("PDFSignatureImpl.16"))
            .append(af.getTotalRevisions())
            .append(nl); // $NON-NLS-1$ //$NON-NLS-2$

        PdfPKCS7 pk = af.verifySignature(name);
        Calendar cal = pk.getSignDate();
        Certificate pkc[] = pk.getCertificates();
        sb.append(Messages.getString("PDFSignatureImpl.17"))
            .append(PdfPKCS7.getSubjectFields(pk.getSigningCertificate()))
            .append(nl); // $NON-NLS-1$
        sb.append(Messages.getString("PDFSignatureImpl.18"))
            .append(
                !pk.verify()
                    ? Messages.getString("PDFSignatureImpl.19")
                    : Messages.getString("PDFSignatureImpl.20"))
            .append(nl); // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
        Object fails[] = PdfPKCS7.verifyCertificates(pkc, kall, null, cal);
        if (fails == null)
          sb.append(Messages.getString("PDFSignatureImpl.21")).append(nl); // $NON-NLS-1$
        else
          sb.append(Messages.getString("PDFSignatureImpl.22"))
              .append(nl); // : " + fails[1]); //$NON-NLS-1$
      }
    } catch (Exception e) {
      log.error("error verifying file", e); // $NON-NLS-1$
      return Messages.getString("PDFSignatureImpl.24"); // $NON-NLS-1$
    } finally {
      try {
        if (fin != null) {
          fin.close();
        }
      } catch (IOException e) {
      }
    }
    return sb.toString();
  }