Digital Signature in PDF with BIRT

Pico
edited February 11, 2022 in Analytics #1
Hi,

Anyone knows if it`s possible generate pdf with digital signature usin BIRT?

Thanks in advance.

Comments

  • mwilliams
    edited December 31, 1969 #2
    Hi Pico,

    Can you explain what you're wanting exactly for your digital signature?
    Warning No formatter is installed for the format ipb
  • Elias123
    edited December 31, 1969 #3
    Please I need to find out how to generate and attach a
    digital signature to a report?



    The standard to use is X 509.


    Please I need your help urgently.


    Thank you in advance!
  • kclark
    kclark E
    edited December 31, 1969 #4
    You should be able to do this with iText. Here's a snippet of the code that will sign the PDF<br />
    <br />
    <pre class='_prettyXprint _lang-auto _linenums:0'>
    KeyStore ks = KeyStore.getInstance("pkcs12");
    ks.load(new FileInputStream("my_private_key.pfx"), "my_password".toCharArray());
    String alias = (String)ks.aliases().nextElement();
    PrivateKey key = (PrivateKey)ks.getKey(alias, "my_password".toCharArray());
    Certificate[] chain = ks.getCertificateChain(alias);
    PdfReader reader = new PdfReader("original.pdf");
    FileOutputStream fout = new FileOutputStream("signed.pdf");
    PdfStamper stp = PdfStamper.createSignature(reader, fout, '\0');
    PdfSignatureAppearance sap = stp.getSignatureAppearance();
    sap.setCrypto(key, chain, null, PdfSignatureAppearance.WINCER_SIGNED);
    sap.setReason("I'm the author");
    sap.setLocation("Lisbon");
    // comment next line to have an invisible signature
    sap.setVisibleSignature(new Rectangle(100, 100, 200, 200), 1, null);
    stp.close();
    </pre>
    <br />
    There appears to be a lot of good information <a class='bbc_url' href='http://itextpdf.sourceforge.net/howtosign.html'>at this sourceforge page</a>
    Warning No formatter is installed for the format ipb
  • Elias123
    edited December 31, 1969 #5
    Sorry I could not understand what is iText, is it a software to use with BIRT? Where should I insert this code?

    If you can send me the steps showing how to configure the report for this purpose.

    Thank you very much for your help.
  • smgomes
    edited December 31, 1969 #6
    <blockquote class='ipsBlockquote' data-author="'Elias123'" data-cid="110638" data-time="1350544234" data-date="18 October 2012 - 12:10 AM"><p>
    Sorry I could not understand what is iText, is it a software to use with BIRT? Where should I insert this code?<br />
    <br />
    If you can send me the steps showing how to configure the report for this purpose.<br />
    <br />
    Thank you very much for your help.<br /></p></blockquote>
    <br />
    iText is a library that allows you to create and manipulate PDF documents. With BIRT you create your report (PDF) so after that you can use iText to attach a digital signature, downlaod the JAR from <a class='bbc_url' href='http://itextpdf.com/'>http://itextpdf.com/</a&gt; and add to your project ;)
    Warning No formatter is installed for the format ipb
  • Elias123
    edited December 31, 1969 #7
    Hello,

    I included the JAR libraries in BIRT, still have to insert the below code, where should I insert it??

    KeyStore ks = KeyStore.getInstance("pkcs12");
    ks.load(new FileInputStream("my_private_key.pfx"), "my_password".toCharArray());
    String alias = (String)ks.aliases().nextElement();
    PrivateKey key = (PrivateKey)ks.getKey(alias, "my_password".toCharArray());
    Certificate[] chain = ks.getCertificateChain(alias);
    PdfReader reader = new PdfReader("original.pdf");
    FileOutputStream fout = new FileOutputStream("signed.pdf");
    PdfStamper stp = PdfStamper.createSignature(reader, fout, '\0');
    PdfSignatureAppearance sap = stp.getSignatureAppearance();
    sap.setCrypto(key, chain, null, PdfSignatureAppearance.WINCER_SIGNED);
    sap.setReason("I'm the author");
    sap.setLocation("Lisbon");
    // comment next line to have an invisible signature
    sap.setVisibleSignature(new Rectangle(100, 100, 200, 200), 1, null);
    stp.close();

    Thank you very much for your kind help!
  • Elias123
    edited October 24, 2012 #8
    <blockquote class='ipsBlockquote' data-author="'smgomes'" data-cid="110644" data-time="1350550521" data-date="18 October 2012 - 01:55 AM"><p>
    iText is a library that allows you to create and manipulate PDF documents. With BIRT you create your report (PDF) so after that you can use iText to attach a digital signature, downlaod the JAR from <a class='bbc_url' href='http://itextpdf.com/'>http://itextpdf.com/</a&gt; and add to your project ;)<br /></p></blockquote>
    <br />
    <br />
    I have added the jar files in BIRT and I inserted the code in initialize, but I couldn't!<br />
    <br />
    It says that there is a ';' missing. Please check the attached screenshot.<br />
    <br />
    Plus I couldn't find what should be the instance (first line)<br />
    <br />
    <br />
    Any help for this?