Node nodo = new Node(actionedUponNodeRef);
String nombreDoc = nodo.toString();
File archivoFirma = new File(nombreDoc);
logger.info("Entra en la firma del doc");
KeyStore ks = KeyStore.getInstance("pkcs12");
logger.info("Segundo paso para leer doc");
ks.load(new FileInputStream("C:/Luis.pfx"), "martin".toCharArray());
logger.info("Tercer paso para leer doc");
String alias = (String)ks.aliases().nextElement();
logger.info("Cuarto paso para leer doc");
PrivateKey key = (PrivateKey)ks.getKey(alias, "martin".toCharArray());
logger.info("Quinto paso para leer doc");
Certificate[] chain = ks.getCertificateChain(alias);
logger.info("Sexto paso para leer doc");
PdfReader reader = new PdfReader();
logger.info("Leyo el documento");
FileOutputStream fout = new FileOutputStream(archivoFirma);
logger.info("Creo el documento auxiliar");
PdfStamper stp = PdfStamper.createSignature(reader, fout, '\0');
PdfSignatureAppearance sap = stp.getSignatureAppearance();
sap.setCrypto(key, chain, null, PdfSignatureAppearance.WINCER_SIGNED);
sap.setCertificationLevel(PdfSignatureAppearance.CERTIFIED_NO_CHANGES_ALLOWED);
sap.setReason("Martin es el autor");
sap.setLocation("Santiago");
// comment next line to have an invisible signature
//sap.setVisibleSignature(new Rectangle(100, 100, 200, 200), 1, null);
stp.close();
PdfReader reader = new PdfReader();
Content from pre 2016 and from language groups that have been closed.
Content is read-only.
By using this site, you are agreeing to allow us to collect and use cookies as outlined in Alfresco’s Cookie Statement and Terms of Use (and you have a legitimate interest in Alfresco and our products, authorizing us to contact you in such methods). If you are not ok with these terms, please do not use this website.