From add4460d9619f3586a02ae0d8c028f01903494bc Mon Sep 17 00:00:00 2001 From: Andreas Fitzek Date: Tue, 1 Oct 2013 15:27:32 +0200 Subject: + Extracting information from Certificate (Ognl) + CMS KeyStore Signer (still wrong format) --- .../src/main/java/at/gv/egiz/pdfas/cli/DeveloperMain.java | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'pdf-as-cli/src/main/java') diff --git a/pdf-as-cli/src/main/java/at/gv/egiz/pdfas/cli/DeveloperMain.java b/pdf-as-cli/src/main/java/at/gv/egiz/pdfas/cli/DeveloperMain.java index cae1171e..4b9a4e33 100644 --- a/pdf-as-cli/src/main/java/at/gv/egiz/pdfas/cli/DeveloperMain.java +++ b/pdf-as-cli/src/main/java/at/gv/egiz/pdfas/cli/DeveloperMain.java @@ -13,22 +13,34 @@ import at.gv.egiz.pdfas.lib.api.ByteArrayDataSource; import at.gv.egiz.pdfas.lib.api.Configuration; import at.gv.egiz.pdfas.lib.api.PdfAs; import at.gv.egiz.pdfas.lib.api.PdfAsFactory; +import at.gv.egiz.pdfas.lib.api.sign.IPlainSigner; import at.gv.egiz.pdfas.lib.api.sign.SignParameter; +import at.gv.egiz.pdfas.lib.impl.signing.IPdfSigner; +import at.gv.egiz.pdfas.lib.impl.signing.sig_interface.JKSSigner; public class DeveloperMain { + public static final String keyStoreFile = "/home/afitzek/devel/pdfas_neu/test.p12"; + public static final String keyStoreType = "PKCS12"; + public static final String keyStorePass = "123456"; + //public static final String keyAlias = "pdf"; + public static final String keyAlias = "ecc_test"; + public static final String keyPass = "123456"; + public static void main(String[] args) { String user_home = System.getProperty("user.home"); String pdfas_dir = user_home + File.separator + "PDF-AS"; PdfAs pdfas = PdfAsFactory.createPdfAs(new File(pdfas_dir)); Configuration config = pdfas.getConfiguration(); - byte[] data; try { + IPlainSigner signer = new JKSSigner(keyStoreFile, keyAlias, keyStorePass, keyPass, keyStoreType); data = StreamUtils.inputStreamToByteArray(new FileInputStream("/home/afitzek/devel/pdfas_neu/simple.pdf")); SignParameter parameter = PdfAsFactory.createSignParameter(config, new ByteArrayDataSource(data)); ByteArrayDataSink bads = new ByteArrayDataSink(); + parameter.setSignatureProfileId("SIGNATURBLOCK_DE_NEU"); parameter.setOutput(bads); + parameter.setPlainSigner(signer); pdfas.sign(parameter); FileOutputStream fos = new FileOutputStream("/home/afitzek/devel/pdfas_neu/simple_out.pdf"); fos.write(bads.getData()); -- cgit v1.2.3