10-09-2009 06:54 AM
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();
09-08-2012 11:36 AM
Tags
Find what you came for
We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.