diff options
author | Andreas Fitzek <andreas.fitzek@iaik.tugraz.at> | 2013-11-28 12:33:02 +0100 |
---|---|---|
committer | Andreas Fitzek <andreas.fitzek@iaik.tugraz.at> | 2013-11-28 12:33:02 +0100 |
commit | 5225b6852938c91940e0b491286583aa263f61d5 (patch) | |
tree | 78d236438c222046cedde0351dbb063c0d0740d2 /pdf-as-cli/src/main/java/at/gv | |
parent | 7fdb06e32c43e99ec3599639348a3d758b9914a7 (diff) | |
download | pdf-as-4-5225b6852938c91940e0b491286583aa263f61d5.tar.gz pdf-as-4-5225b6852938c91940e0b491286583aa263f61d5.tar.bz2 pdf-as-4-5225b6852938c91940e0b491286583aa263f61d5.zip |
Verification with MOA SP working through PAdES Verifier
Diffstat (limited to 'pdf-as-cli/src/main/java/at/gv')
-rw-r--r-- | pdf-as-cli/src/main/java/at/gv/egiz/pdfas/cli/Main.java | 28 |
1 files changed, 25 insertions, 3 deletions
diff --git a/pdf-as-cli/src/main/java/at/gv/egiz/pdfas/cli/Main.java b/pdf-as-cli/src/main/java/at/gv/egiz/pdfas/cli/Main.java index 05fbbf67..dfd33c34 100644 --- a/pdf-as-cli/src/main/java/at/gv/egiz/pdfas/cli/Main.java +++ b/pdf-as-cli/src/main/java/at/gv/egiz/pdfas/cli/Main.java @@ -2,6 +2,7 @@ package at.gv.egiz.pdfas.cli; import java.io.File; import java.io.FileInputStream; +import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.util.Iterator; @@ -178,6 +179,12 @@ public class Main { if (cli.hasOption(CLI_ARG_PROFILE_SHORT)) { profilID = cli.getOptionValue(CLI_ARG_PROFILE_SHORT); } + + String outputFile = null; + + if(cli.hasOption(CLI_ARG_OUTPUT_SHORT)) { + outputFile = cli.getOptionValue(CLI_ARG_OUTPUT_SHORT); + } String pdfFile = null; @@ -189,11 +196,21 @@ public class Main { throw new Exception("Input file does not exists"); } + if(outputFile == null) { + if(pdfFile.endsWith(".pdf")) { + outputFile = pdfFile.subSequence(0, pdfFile.length() - ".pdf".length()) + "_signed.pdf"; + } else { + outputFile = pdfFile + "_signed.pdf"; + } + } + + File outputPdfFile = new File(outputFile); + DataSource dataSource = new ByteArrayDataSource( StreamUtils.inputStreamToByteArray(new FileInputStream( inputFile))); - DataSink dataSink = new ByteArrayDataSink(); + ByteArrayDataSink dataSink = new ByteArrayDataSink(); PdfAs pdfAs = null; @@ -214,8 +231,13 @@ public class Main { // signParameter.setPlainSigner(signer); SignResult result = pdfAs.sign(signParameter); - - // TODO write result to file + + if(outputPdfFile.exists()) { + } + + FileOutputStream fos = new FileOutputStream(outputPdfFile, false); + fos.write(dataSink.getData()); + fos.close(); } private static void perform_verify(CommandLine cli) throws Exception { |