aboutsummaryrefslogtreecommitdiff
path: root/pdf-as-lib/src/main/java/at
diff options
context:
space:
mode:
authorAndreas Fitzek <andreas.fitzek@iaik.tugraz.at>2014-10-21 10:28:54 +0200
committerAndreas Fitzek <andreas.fitzek@iaik.tugraz.at>2014-10-21 10:28:54 +0200
commitd16a7c27a77399806d1e2c6ae082e98d456c3baf (patch)
tree309ec8c90dd8274375ebb8480dfc3e5cafeeedb6 /pdf-as-lib/src/main/java/at
parent40841f154c31d8e9e6e670def11dcb5899f5db71 (diff)
downloadpdf-as-4-d16a7c27a77399806d1e2c6ae082e98d456c3baf.tar.gz
pdf-as-4-d16a7c27a77399806d1e2c6ae082e98d456c3baf.tar.bz2
pdf-as-4-d16a7c27a77399806d1e2c6ae082e98d456c3baf.zip
PDF API update to ouput signed documents via output stream
Diffstat (limited to 'pdf-as-lib/src/main/java/at')
-rw-r--r--pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/api/PdfAsFactory.java5
-rw-r--r--pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/api/sign/SignParameter.java8
-rw-r--r--pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/api/sign/SignResult.java7
-rw-r--r--pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/PdfAsImpl.java7
-rw-r--r--pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/SignParameterImpl.java19
-rw-r--r--pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/SignResultImpl.java9
6 files changed, 25 insertions, 30 deletions
diff --git a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/api/PdfAsFactory.java b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/api/PdfAsFactory.java
index 6570c419..acfb7ef5 100644
--- a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/api/PdfAsFactory.java
+++ b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/api/PdfAsFactory.java
@@ -31,6 +31,7 @@ import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
+import java.io.OutputStream;
import java.security.Provider;
import java.security.Security;
import java.util.zip.ZipEntry;
@@ -188,8 +189,8 @@ public class PdfAsFactory implements IConfigurationConstants {
* @return
*/
public static SignParameter createSignParameter(
- Configuration configuration, DataSource dataSource) {
- SignParameter param = new SignParameterImpl(configuration, dataSource);
+ Configuration configuration, DataSource dataSource, OutputStream output) {
+ SignParameter param = new SignParameterImpl(configuration, dataSource, output);
return param;
}
diff --git a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/api/sign/SignParameter.java b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/api/sign/SignParameter.java
index c1bfe53f..6a7ccf24 100644
--- a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/api/sign/SignParameter.java
+++ b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/api/sign/SignParameter.java
@@ -23,6 +23,8 @@
******************************************************************************/
package at.gv.egiz.pdfas.lib.api.sign;
+import java.io.OutputStream;
+
import at.gv.egiz.pdfas.lib.api.PdfAsParameter;
public interface SignParameter extends PdfAsParameter {
@@ -65,4 +67,10 @@ public interface SignParameter extends PdfAsParameter {
* @return
*/
public IPlainSigner getPlainSigner();
+
+ /**
+ * Gets the outputstream, where the signed document will be written to
+ * @return
+ */
+ public OutputStream getSignatureResult();
}
diff --git a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/api/sign/SignResult.java b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/api/sign/SignResult.java
index 180792ea..8084f8f1 100644
--- a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/api/sign/SignResult.java
+++ b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/api/sign/SignResult.java
@@ -23,18 +23,11 @@
******************************************************************************/
package at.gv.egiz.pdfas.lib.api.sign;
-import java.io.InputStream;
import java.security.cert.X509Certificate;
import at.gv.egiz.pdfas.lib.api.SignaturePosition;
public interface SignResult {
- /**
- * Returns the filled output data sink.
- *
- * @return Returns the filled output data sink.
- */
- public InputStream getOutputDocument();
/**
* Returns the certificate of the signer.
diff --git a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/PdfAsImpl.java b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/PdfAsImpl.java
index 387a6c31..4828bae3 100644
--- a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/PdfAsImpl.java
+++ b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/PdfAsImpl.java
@@ -26,7 +26,6 @@ package at.gv.egiz.pdfas.lib.impl;
import iaik.x509.X509Certificate;
import java.awt.Image;
-import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.IOException;
import java.util.Calendar;
@@ -450,9 +449,9 @@ public class PdfAsImpl implements PdfAs, IConfigurationConstants,
throws IOException {
// ================================================================
// Create SignResult
- SignResultImpl result = new SignResultImpl(new ByteArrayInputStream(
- status.getPdfObject().getSignedDocument()));
-
+ SignResultImpl result = new SignResultImpl();
+ status.getSignParamter().getSignatureResult().write(status.getPdfObject().getSignedDocument());
+ status.getSignParamter().getSignatureResult().flush();
result.setSignerCertificate(status.getRequestedSignature()
.getCertificate());
result.setSignaturePosition(status.getRequestedSignature()
diff --git a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/SignParameterImpl.java b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/SignParameterImpl.java
index f547b2b0..9584e1bf 100644
--- a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/SignParameterImpl.java
+++ b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/SignParameterImpl.java
@@ -23,6 +23,8 @@
******************************************************************************/
package at.gv.egiz.pdfas.lib.impl;
+import java.io.OutputStream;
+
import javax.activation.DataSource;
import at.gv.egiz.pdfas.lib.api.Configuration;
@@ -34,10 +36,12 @@ public class SignParameterImpl extends PdfAsParameterImpl implements SignParamet
protected String signaturePosition = null;
protected DataSource output = null;
protected IPlainSigner signer = null;
+ protected OutputStream outputStream = null;
public SignParameterImpl(Configuration configuration,
- DataSource dataSource) {
+ DataSource dataSource, OutputStream outputStream) {
super(configuration, dataSource);
+ this.outputStream = outputStream;
}
// ========================================================================
@@ -58,14 +62,6 @@ public class SignParameterImpl extends PdfAsParameterImpl implements SignParamet
this.signaturePosition = signaturePosition;
}
- public void setOutput(DataSource output) {
- this.output = output;
- }
-
- public DataSource getOutput() {
- return this.output;
- }
-
public void setPlainSigner(IPlainSigner signer) {
this.signer = signer;
}
@@ -73,5 +69,10 @@ public class SignParameterImpl extends PdfAsParameterImpl implements SignParamet
public IPlainSigner getPlainSigner() {
return this.signer;
}
+
+ @Override
+ public OutputStream getSignatureResult() {
+ return outputStream;
+ }
}
diff --git a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/SignResultImpl.java b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/SignResultImpl.java
index 1a0e6490..f713eb6a 100644
--- a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/SignResultImpl.java
+++ b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/SignResultImpl.java
@@ -23,7 +23,6 @@
******************************************************************************/
package at.gv.egiz.pdfas.lib.impl;
-import java.io.InputStream;
import java.security.cert.X509Certificate;
import at.gv.egiz.pdfas.lib.api.SignaturePosition;
@@ -31,16 +30,10 @@ import at.gv.egiz.pdfas.lib.api.sign.SignResult;
public class SignResultImpl implements SignResult {
- protected InputStream dataSink;
protected X509Certificate certificate;
protected SignaturePosition position;
- public SignResultImpl(InputStream dataSink) {
- this.dataSink = dataSink;
- }
-
- public InputStream getOutputDocument() {
- return this.dataSink;
+ public SignResultImpl() {
}
public X509Certificate getSignerCertificate() {