18 package org.turro.zkoss.print;
20 import com.lowagie.text.DocumentException;
21 import com.lowagie.text.Rectangle;
22 import com.lowagie.text.pdf.PdfReader;
23 import com.lowagie.text.pdf.PdfSignatureAppearance;
24 import com.lowagie.text.pdf.PdfStamper;
25 import java.io.ByteArrayOutputStream;
26 import java.io.IOException;
27 import java.util.logging.Level;
28 import java.util.logging.Logger;
29 import org.turro.elephant.context.Application;
30 import org.turro.elephant.context.ElephantContext;
31 import org.turro.elephant.impl.context.ContextFactory;
32 import org.turro.elephant.impl.security.CertificateStore;
33 import org.zkoss.util.media.AMedia;
34 import org.zkoss.util.media.Media;
35 import org.zkoss.zkex.zul.Jasperreport;
43 private String certificateStore;
46 return certificateStore;
50 this.certificateStore = certificateStore;
58 protected class SignCtrl extends Jasperreport.ExtraCtrl {
66 Media media = super.getMedia(pathInfo);
67 PdfReader in =
new PdfReader(media.getStreamData());
68 ByteArrayOutputStream out =
new ByteArrayOutputStream();
69 PdfStamper stp = PdfStamper.createSignature(in, out,
'\0');
70 PdfSignatureAppearance sap = stp.getSignatureAppearance();
71 sap.setCrypto(cs.
getKey(), cs.
getChain(),
null, PdfSignatureAppearance.WINCER_SIGNED);
74 if(
"true".equals((String) cs.
getAttributes().get(
"visible"))) {
75 sap.setVisibleSignature(
new Rectangle(
83 return new AMedia(media.getName(), media.getFormat(), media.getContentType(), out.toByteArray());
87 return super.getMedia(pathInfo);
92 }
catch (DocumentException | IOException ex) {
IConstructor getConstructor()
static Application getApplication()
static String logMsg(String msg)
KeyValueMap getAttributes()
Long getLongAttribute(String key)
static Object getImplementation(IElement iel, String name)
Media getMedia(String pathInfo)
String getCertificateStore()
void setCertificateStore(String certificateStore)