diff options
author | Andreas Fitzek <andreas.fitzek@iaik.tugraz.at> | 2014-10-15 14:23:04 +0200 |
---|---|---|
committer | Andreas Fitzek <andreas.fitzek@iaik.tugraz.at> | 2014-10-15 14:23:04 +0200 |
commit | cfbd5f9d8af638aa830aa535feadb094109e6455 (patch) | |
tree | 5d65bb93b64314f7e3f3455002b4c909242e5bc5 /pdf-as-tests | |
parent | 0e31e524b419cd898139d1b8afa92cb794a3f821 (diff) | |
download | pdf-as-4-cfbd5f9d8af638aa830aa535feadb094109e6455.tar.gz pdf-as-4-cfbd5f9d8af638aa830aa535feadb094109e6455.tar.bz2 pdf-as-4-cfbd5f9d8af638aa830aa535feadb094109e6455.zip |
Rebuild API to support Java DataSource and Streams for in and output
Diffstat (limited to 'pdf-as-tests')
-rw-r--r-- | pdf-as-tests/src/test/java/at/gv/egiz/param_tests/SignatureTest.java | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/pdf-as-tests/src/test/java/at/gv/egiz/param_tests/SignatureTest.java b/pdf-as-tests/src/test/java/at/gv/egiz/param_tests/SignatureTest.java index 64b302c4..e4ff9325 100644 --- a/pdf-as-tests/src/test/java/at/gv/egiz/param_tests/SignatureTest.java +++ b/pdf-as-tests/src/test/java/at/gv/egiz/param_tests/SignatureTest.java @@ -11,6 +11,8 @@ import java.security.cert.CertificateException; import java.util.Map; import java.util.UUID; +import javax.activation.DataSource; + import org.apache.commons.io.IOUtils; import org.junit.Rule; import org.junit.rules.TestRule; @@ -21,14 +23,13 @@ import at.gv.egiz.param_tests.provider.BaseSignatureDataProvider; import at.gv.egiz.param_tests.provider.BaseSignatureTestData; import at.gv.egiz.pdfas.common.exceptions.PdfAsException; import at.gv.egiz.pdfas.common.utils.StreamUtils; -import at.gv.egiz.pdfas.lib.api.ByteArrayDataSink; import at.gv.egiz.pdfas.lib.api.ByteArrayDataSource; import at.gv.egiz.pdfas.lib.api.Configuration; -import at.gv.egiz.pdfas.lib.api.DataSource; 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.api.sign.SignResult; import at.gv.egiz.pdfas.moa.MOAConnector; import at.gv.egiz.pdfas.sigs.pades.PAdESSigner; import at.gv.egiz.pdfas.sigs.pades.PAdESSignerKeystore; @@ -94,7 +95,6 @@ public class SignatureTest { DataSource dataSource = new ByteArrayDataSource( StreamUtils.inputStreamToByteArray(new FileInputStream( inputFile))); - ByteArrayDataSink dataSink = new ByteArrayDataSink(); pdfAs = null; pdfAs = PdfAsFactory.createPdfAs(new File(baseTestData @@ -148,7 +148,6 @@ public class SignatureTest { slConnector = new PAdESSigner(new BKUSLConnector(configuration)); } - signParameter.setOutput(dataSink); signParameter.setPlainSigner(slConnector); signParameter.setDataSource(dataSource); // this is not needed for PDF-A test @@ -157,11 +156,11 @@ public class SignatureTest { signParameter.setSignatureProfileId(baseTestData.getProfilID()); logger.debug("Starting signature for " + baseTestData.getPdfFile()); logger.debug("Selected signature Profile " + baseTestData.getProfilID()); - /* SignResult result = */pdfAs.sign(signParameter); + SignResult result = pdfAs.sign(signParameter); FileOutputStream fos = null; try { fos = new FileOutputStream(outputPdfFile, false); - fos.write(dataSink.getData()); + IOUtils.copy(result.getOutputDocument(), fos); fos.close(); } catch (IOException e) { logger.debug("IO exception occured while writing PDF output file", |