aboutsummaryrefslogtreecommitdiff
path: root/pdf-as-cli
diff options
context:
space:
mode:
Diffstat (limited to 'pdf-as-cli')
-rw-r--r--pdf-as-cli/src/main/java/at/gv/egiz/pdfas/cli/Main.java12
-rw-r--r--pdf-as-cli/src/test/java/at/gv/egiz/pdfas/cli/test/SignaturProfileTest.java13
2 files changed, 10 insertions, 15 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 3ce215c8..d847f31b 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
@@ -39,7 +39,6 @@ import org.apache.commons.cli.HelpFormatter;
import org.apache.commons.cli.Option;
import org.apache.commons.cli.Options;
import org.apache.commons.cli.ParseException;
-import org.apache.commons.io.IOUtils;
import at.gv.egiz.pdfas.common.exceptions.PDFASError;
import at.gv.egiz.pdfas.common.utils.StreamUtils;
@@ -51,8 +50,8 @@ import at.gv.egiz.pdfas.lib.api.sign.IPlainSigner;
import at.gv.egiz.pdfas.lib.api.sign.SignParameter;
import at.gv.egiz.pdfas.lib.api.sign.SignResult;
import at.gv.egiz.pdfas.lib.api.verify.VerifyParameter;
-import at.gv.egiz.pdfas.lib.api.verify.VerifyResult;
import at.gv.egiz.pdfas.lib.api.verify.VerifyParameter.SignatureVerificationLevel;
+import at.gv.egiz.pdfas.lib.api.verify.VerifyResult;
import at.gv.egiz.pdfas.moa.MOAConnector;
import at.gv.egiz.pdfas.sigs.pades.PAdESSigner;
import at.gv.egiz.pdfas.sigs.pades.PAdESSignerKeystore;
@@ -334,9 +333,9 @@ public class Main {
pdfAs = PdfAsFactory.createPdfAs(new File(configurationFile));
Configuration configuration = pdfAs.getConfiguration();
-
+ FileOutputStream fos = new FileOutputStream(outputPdfFile, false);
SignParameter signParameter = PdfAsFactory.createSignParameter(
- configuration, dataSource);
+ configuration, dataSource, fos);
String id = UUID.randomUUID().toString();
signParameter.setTransactionId(id);
@@ -415,11 +414,10 @@ public class Main {
signParameter.setSignatureProfileId(profilID);
System.out.println("Starting signature for " + pdfFile);
System.out.println("Selected signature Profile " + profilID);
+
+ @SuppressWarnings("unused")
SignResult result = pdfAs.sign(signParameter);
- FileOutputStream fos = new FileOutputStream(outputPdfFile, false);
- IOUtils.copy(result.getOutputDocument(), fos);
-
fos.close();
System.out.println("Signed document " + outputFile);
}
diff --git a/pdf-as-cli/src/test/java/at/gv/egiz/pdfas/cli/test/SignaturProfileTest.java b/pdf-as-cli/src/test/java/at/gv/egiz/pdfas/cli/test/SignaturProfileTest.java
index 6b1eeaa9..75f19c71 100644
--- a/pdf-as-cli/src/test/java/at/gv/egiz/pdfas/cli/test/SignaturProfileTest.java
+++ b/pdf-as-cli/src/test/java/at/gv/egiz/pdfas/cli/test/SignaturProfileTest.java
@@ -98,17 +98,16 @@ public class SignaturProfileTest {
System.out.println("Testing " + profile);
DataSource source = new ByteArrayDataSource(input);
-
+
+ FileOutputStream fos = new FileOutputStream(targetFolder + profile + ".pdf");
SignParameter signParameter = PdfAsFactory.createSignParameter(
- config, source);
+ config, source, fos);
signParameter.setPlainSigner(signer);
signParameter.setSignatureProfileId(profile);
SignResult result = pdfas.sign(signParameter);
- FileOutputStream fos = new FileOutputStream(targetFolder + profile + ".pdf");
- IOUtils.copy(result.getOutputDocument(), fos);
fos.close();
}
@@ -120,17 +119,15 @@ public class SignaturProfileTest {
System.out.println("Testing " + profile);
DataSource source = new ByteArrayDataSource(inputPDFA);
-
+ FileOutputStream fos = new FileOutputStream(targetFolder + "PDFA_" + profile + ".pdf");
SignParameter signParameter = PdfAsFactory.createSignParameter(
- config, source);
+ config, source, fos);
signParameter.setPlainSigner(signer);
signParameter.setSignatureProfileId(profile);
SignResult result = pdfas.sign(signParameter);
- FileOutputStream fos = new FileOutputStream(targetFolder + "PDFA_" + profile + ".pdf");
- IOUtils.copy(result.getOutputDocument(), fos);
fos.close();
}
} catch (Throwable e) {