aboutsummaryrefslogtreecommitdiff
path: root/pdf-as-legacy/src
diff options
context:
space:
mode:
authorAndreas Fitzek <andreas.fitzek@iaik.tugraz.at>2014-10-15 14:23:04 +0200
committerAndreas Fitzek <andreas.fitzek@iaik.tugraz.at>2014-10-15 14:23:04 +0200
commitcfbd5f9d8af638aa830aa535feadb094109e6455 (patch)
tree5d65bb93b64314f7e3f3455002b4c909242e5bc5 /pdf-as-legacy/src
parent0e31e524b419cd898139d1b8afa92cb794a3f821 (diff)
downloadpdf-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-legacy/src')
-rw-r--r--pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/wrapper/PdfAsObject.java2
-rw-r--r--pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/wrapper/SignParameterWrapper.java12
2 files changed, 6 insertions, 8 deletions
diff --git a/pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/wrapper/PdfAsObject.java b/pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/wrapper/PdfAsObject.java
index bef3b01f..ac76a56b 100644
--- a/pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/wrapper/PdfAsObject.java
+++ b/pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/wrapper/PdfAsObject.java
@@ -101,7 +101,7 @@ public class PdfAsObject implements PdfAs {
request = (StatusRequestImpl) this.pdfas4.process(request);
if(request.isReady()) {
at.gv.egiz.pdfas.lib.api.sign.SignResult result = this.pdfas4.finishSign(request);
- sdi.wrapper.syncNewToOld();
+ sdi.wrapper.syncNewToOld(result);
SignResultImpl oldresult = new SignResultImpl(sdi.wrapper.getSignParameters().getOutput(),
sdi.getX509Certificate(), new at.gv.egiz.pdfas.wrapper.SignaturePositionImpl(
result.getSignaturePosition()));
diff --git a/pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/wrapper/SignParameterWrapper.java b/pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/wrapper/SignParameterWrapper.java
index 7043baaa..12395bde 100644
--- a/pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/wrapper/SignParameterWrapper.java
+++ b/pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/wrapper/SignParameterWrapper.java
@@ -26,14 +26,15 @@ package at.gv.egiz.pdfas.wrapper;
import java.io.OutputStream;
import java.util.Enumeration;
+import org.apache.commons.io.IOUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import at.gv.egiz.pdfas.api.exceptions.ErrorCode;
import at.gv.egiz.pdfas.api.exceptions.PdfAsException;
import at.gv.egiz.pdfas.api.sign.SignParameters;
-import at.gv.egiz.pdfas.lib.api.ByteArrayDataSink;
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.sl.util.BKUSLConnector;
@@ -45,7 +46,6 @@ public class SignParameterWrapper {
private SignParameter signParameter4;
private SignParameters signParameters;
- private ByteArrayDataSink output;
public SignParameterWrapper(SignParameters signParameters,
SignParameter signParameter4) {
@@ -54,9 +54,7 @@ public class SignParameterWrapper {
}
public void syncOldToNew() throws PdfAsException {
- output = new ByteArrayDataSink();
- this.signParameter4.setOutput(output);
-
+
if (this.signParameters.getSignaturePositioning() != null) {
// Create positioning string
String posString = this.signParameters.getSignaturePositioning()
@@ -106,11 +104,11 @@ public class SignParameterWrapper {
}
}
- public void syncNewToOld() throws PdfAsException {
+ public void syncNewToOld(SignResult result) throws PdfAsException {
try {
OutputStream os = this.signParameters.getOutput()
.createOutputStream("application/pdf");
- os.write(output.getData());
+ IOUtils.copy(result.getOutputDocument(), os);
os.close();
} catch (Exception e) {
throw new PdfAsException(ErrorCode.SIGNATURE_COULDNT_BE_CREATED,