Example usage for org.apache.pdfbox.pdmodel.interactive.digitalsignature PDSignature getReason

List of usage examples for org.apache.pdfbox.pdmodel.interactive.digitalsignature PDSignature getReason

Introduction

In this page you can find the example usage for org.apache.pdfbox.pdmodel.interactive.digitalsignature PDSignature getReason.

Prototype

public String getReason() 

Source Link

Document

Returns the reason for the signing, such as (I agree...).

Usage

From source file:eu.europa.esig.dss.pades.signature.PAdESLevelBWithContentTimestampTest.java

License:Open Source License

@Override
protected void onDocumentSigned(byte[] byteArray) {
    super.onDocumentSigned(byteArray);

    try (PDDocument doc = PDDocument.load(byteArray)) {
        List<PDSignature> signatureDictionaries = doc.getSignatureDictionaries();
        assertEquals(1, signatureDictionaries.size());
        PDSignature pdSignature = signatureDictionaries.get(0);
        assertNotNull(pdSignature.getName());
        assertNotNull(pdSignature.getReason());
        assertNotNull(pdSignature.getLocation());
        assertNotNull(pdSignature.getContactInfo());
        assertNotNull(pdSignature.getSignDate()); // M
        assertEquals("Adobe.PPKLite", pdSignature.getFilter());
        assertEquals("ETSI.CAdES.detached", pdSignature.getSubFilter());
    } catch (IOException e) {
        throw new DSSException(e);
    }//ww  w.  j a v a 2  s.  co m
}

From source file:eu.europa.esig.dss.pdf.pdfbox.PdfBoxCMSInfo.java

License:Open Source License

/**
 *
 * @param signature The signature object
 * @param dssDictionary the DSS dictionary
 * @param cms the signature binary/*from  w  ww  .  ja  v a 2s  . c o  m*/
 * @param signedContent the signed content
 */
PdfBoxCMSInfo(PDSignature signature, PdfDssDict dssDictionary, byte[] cms, byte[] signedContent) {
    this.cms = cms;
    this.location = signature.getLocation();
    this.reason = signature.getReason();
    this.contactInfo = signature.getContactInfo();
    this.subFilter = signature.getSubFilter();
    this.signingDate = signature.getSignDate() != null ? signature.getSignDate().getTime() : null;
    this.signatureByteRange = signature.getByteRange();
    this.dssDictionary = dssDictionary;
    this.signedBytes = signedContent;
}

From source file:mj.ocraptor.extraction.tika.parser.pdf.PDF2XHTML.java

License:Apache License

private void handleSignature(AttributesImpl parentAttributes, PDSignatureField sigField,
        XHTMLContentHandler handler) throws SAXException {

    PDSignature sig = sigField.getSignature();
    if (sig == null) {
        return;/*from ww  w.j a  v a  2 s  .  c  om*/
    }
    Map<String, String> vals = new TreeMap<String, String>();
    vals.put("name", sig.getName());
    vals.put("contactInfo", sig.getContactInfo());
    vals.put("location", sig.getLocation());
    vals.put("reason", sig.getReason());

    Calendar cal = sig.getSignDate();
    if (cal != null) {
        dateFormat.setTimeZone(cal.getTimeZone());
        vals.put("date", dateFormat.format(cal.getTime()));
    }
    // see if there is any data
    int nonNull = 0;
    for (String val : vals.keySet()) {
        if (val != null && !val.equals("")) {
            nonNull++;
        }
    }
    // if there is, process it
    if (nonNull > 0) {
        handler.startElement("li", parentAttributes);

        AttributesImpl attrs = new AttributesImpl();
        attrs.addAttribute("", "type", "type", "CDATA", "signaturedata");

        handler.startElement("ol", attrs);
        for (Map.Entry<String, String> e : vals.entrySet()) {
            if (e.getValue() == null || e.getValue().equals("")) {
                continue;
            }
            attrs = new AttributesImpl();
            attrs.addAttribute("", "signdata", "signdata", "CDATA", e.getKey());
            handler.startElement("li", attrs);
            handler.characters(e.getValue());
            handler.endElement("li");
        }
        handler.endElement("ol");
        handler.endElement("li");
    }
}

From source file:org.apache.tika.parser.pdf.AbstractPDF2XHTML.java

License:Apache License

private void handleSignature(AttributesImpl parentAttributes, PDSignatureField sigField) throws SAXException {

    PDSignature sig = sigField.getSignature();
    if (sig == null) {
        return;//from   w w  w . j av  a 2s .  com
    }
    Map<String, String> vals = new TreeMap<>();
    vals.put("name", sig.getName());
    vals.put("contactInfo", sig.getContactInfo());
    vals.put("location", sig.getLocation());
    vals.put("reason", sig.getReason());

    Calendar cal = sig.getSignDate();
    if (cal != null) {
        dateFormat.setTimeZone(cal.getTimeZone());
        vals.put("date", dateFormat.format(cal.getTime()));
    }
    //see if there is any data
    int nonNull = 0;
    for (String val : vals.keySet()) {
        if (val != null && !val.equals("")) {
            nonNull++;
        }
    }
    //if there is, process it
    if (nonNull > 0) {
        xhtml.startElement("li", parentAttributes);

        AttributesImpl attrs = new AttributesImpl();
        attrs.addAttribute("", "type", "type", "CDATA", "signaturedata");

        xhtml.startElement("ol", attrs);
        for (Map.Entry<String, String> e : vals.entrySet()) {
            if (e.getValue() == null || e.getValue().equals("")) {
                continue;
            }
            attrs = new AttributesImpl();
            attrs.addAttribute("", "signdata", "signdata", "CDATA", e.getKey());
            xhtml.startElement("li", attrs);
            xhtml.characters(e.getValue());
            xhtml.endElement("li");
        }
        xhtml.endElement("ol");
        xhtml.endElement("li");
    }
}

From source file:org.apache.tika.parser.pdf.EnhancedPDF2XHTML.java

License:Apache License

private void handleSignature(AttributesImpl parentAttributes, PDSignatureField sigField,
        XHTMLContentHandler handler) throws SAXException {

    PDSignature sig = sigField.getSignature();
    if (sig == null) {
        return;/*from w w  w .j a  va  2  s. c  o m*/
    }
    Map<String, String> vals = new TreeMap<String, String>();
    vals.put("name", sig.getName());
    vals.put("contactInfo", sig.getContactInfo());
    vals.put("location", sig.getLocation());
    vals.put("reason", sig.getReason());

    Calendar cal = sig.getSignDate();
    if (cal != null) {
        dateFormat.setTimeZone(cal.getTimeZone());
        vals.put("date", dateFormat.format(cal.getTime()));
    }
    //see if there is any data
    int nonNull = 0;
    for (String val : vals.keySet()) {
        if (val != null && !val.equals("")) {
            nonNull++;
        }
    }
    //if there is, process it
    if (nonNull > 0) {
        handler.startElement("li", parentAttributes);

        AttributesImpl attrs = new AttributesImpl();
        attrs.addAttribute("", "type", "type", "CDATA", "signaturedata");

        handler.startElement("ol", attrs);
        for (Map.Entry<String, String> e : vals.entrySet()) {
            if (e.getValue() == null || e.getValue().equals("")) {
                continue;
            }
            attrs = new AttributesImpl();
            attrs.addAttribute("", "signdata", "signdata", "CDATA", e.getKey());
            handler.startElement("li", attrs);
            handler.characters(e.getValue());
            handler.endElement("li");
        }
        handler.endElement("ol");
        handler.endElement("li");
    }
}