diff options
author | Andreas Fitzek <andreas.fitzek@iaik.tugraz.at> | 2013-09-26 16:09:12 +0200 |
---|---|---|
committer | Andreas Fitzek <andreas.fitzek@iaik.tugraz.at> | 2013-09-26 16:09:12 +0200 |
commit | 25f5495b60fb0fb089c7af216986d2f3abf92375 (patch) | |
tree | 3410f086b3f1a3458fb8d6756d2774d4abad6819 /pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/api | |
parent | d85cbb74b8fe9c2bcc31a4b55ad17ae889d6b578 (diff) | |
download | pdf-as-4-25f5495b60fb0fb089c7af216986d2f3abf92375.tar.gz pdf-as-4-25f5495b60fb0fb089c7af216986d2f3abf92375.tar.bz2 pdf-as-4-25f5495b60fb0fb089c7af216986d2f3abf92375.zip |
first version of API IO implemented
Diffstat (limited to 'pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/api')
-rw-r--r-- | pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/api/ByteArrayDataSink.java | 18 | ||||
-rw-r--r-- | pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/api/ByteArrayDataSource.java | 2 | ||||
-rw-r--r-- | pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/api/DataSink.java | 7 | ||||
-rw-r--r-- | pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/api/DataSource.java (renamed from pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/api/IDataSource.java) | 2 | ||||
-rw-r--r-- | pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/api/PdfAsFactory.java | 7 | ||||
-rw-r--r-- | pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/api/PdfAsParameter.java | 28 | ||||
-rw-r--r-- | pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/api/sign/SignParameter.java | 34 | ||||
-rw-r--r-- | pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/api/sign/SignResult.java | 35 | ||||
-rw-r--r-- | pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/api/verify/VerifyParameter.java | 9 |
9 files changed, 83 insertions, 59 deletions
diff --git a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/api/ByteArrayDataSink.java b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/api/ByteArrayDataSink.java new file mode 100644 index 00000000..6cc63338 --- /dev/null +++ b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/api/ByteArrayDataSink.java @@ -0,0 +1,18 @@ +package at.gv.egiz.pdfas.lib.api; + +import java.io.ByteArrayOutputStream; +import java.io.OutputStream; + +public class ByteArrayDataSink implements DataSink { + + protected ByteArrayOutputStream bos = new ByteArrayOutputStream(); + + public OutputStream createOutputStream() { + bos = new ByteArrayOutputStream(); + return bos; + } + + public byte[] getData() { + return bos.toByteArray(); + } +} diff --git a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/api/ByteArrayDataSource.java b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/api/ByteArrayDataSource.java index 72c02b08..cd670cea 100644 --- a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/api/ByteArrayDataSource.java +++ b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/api/ByteArrayDataSource.java @@ -1,6 +1,6 @@ package at.gv.egiz.pdfas.lib.api; -public class ByteArrayDataSource implements IDataSource { +public class ByteArrayDataSource implements DataSource { private byte[] byteData; diff --git a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/api/DataSink.java b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/api/DataSink.java new file mode 100644 index 00000000..4a3fb52c --- /dev/null +++ b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/api/DataSink.java @@ -0,0 +1,7 @@ +package at.gv.egiz.pdfas.lib.api; + +import java.io.OutputStream; + +public interface DataSink { + public OutputStream createOutputStream(); +} diff --git a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/api/IDataSource.java b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/api/DataSource.java index 6fea788c..73487c7b 100644 --- a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/api/IDataSource.java +++ b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/api/DataSource.java @@ -1,6 +1,6 @@ package at.gv.egiz.pdfas.lib.api; -public interface IDataSource { +public interface DataSource { public String getMIMEType(); public byte[] getByteData(); } 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 444480cf..518f458d 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 @@ -4,7 +4,9 @@ import java.io.File; import org.apache.log4j.PropertyConfigurator; +import at.gv.egiz.pdfas.lib.api.sign.SignParameter; import at.gv.egiz.pdfas.lib.impl.PdfAsImpl; +import at.gv.egiz.pdfas.lib.impl.SignParameterImpl; public class PdfAsFactory { @@ -15,4 +17,9 @@ public class PdfAsFactory { public static PdfAs createPdfAs(File configuration) { return new PdfAsImpl(configuration); } + + public static SignParameter createSignParameter(Configuration configuration, DataSource dataSource) { + SignParameter param = new SignParameterImpl(configuration, dataSource); + return param; + } } diff --git a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/api/PdfAsParameter.java b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/api/PdfAsParameter.java index 999c91bc..8ffcf998 100644 --- a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/api/PdfAsParameter.java +++ b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/api/PdfAsParameter.java @@ -1,32 +1,14 @@ package at.gv.egiz.pdfas.lib.api; -public abstract class PdfAsParameter { +public interface PdfAsParameter { - protected Configuration configuration; - - protected IDataSource dataSource; - - public PdfAsParameter(Configuration configuration, - IDataSource dataSource) { - this.configuration = configuration; - this.dataSource = dataSource; - } - - public Configuration getConfiguration() { - return configuration; - } + public Configuration getConfiguration() ; - public void setConfiguration(Configuration configuration) { - this.configuration = configuration; - } + public void setConfiguration(Configuration configuration); - public IDataSource getDataSource() { - return dataSource; - } + public DataSource getDataSource(); - public void setDataSource(IDataSource dataSource) { - this.dataSource = dataSource; - } + public void setDataSource(DataSource dataSource); } 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 1eee841a..0b4a076c 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 @@ -1,37 +1,19 @@ package at.gv.egiz.pdfas.lib.api.sign; -import at.gv.egiz.pdfas.lib.api.Configuration; -import at.gv.egiz.pdfas.lib.api.IDataSource; +import at.gv.egiz.pdfas.lib.api.DataSink; import at.gv.egiz.pdfas.lib.api.PdfAsParameter; -public class SignParameter extends PdfAsParameter { - - protected String signatureProfileId = null; - protected String signaturePosition = null; +public interface SignParameter extends PdfAsParameter { - public SignParameter(Configuration configuration, - IDataSource dataSource) { - super(configuration, dataSource); - } + public String getSignatureProfileId(); - // ======================================================================== - - public String getSignatureProfileId() { - return signatureProfileId; - } + public void setSignatureProfileId(String signatureProfileId); - public void setSignatureProfileId(String signatureProfileId) { - this.signatureProfileId = signatureProfileId; - } + public String getSignaturePosition(); - public String getSignaturePosition() { - return signaturePosition; - } + public void setSignaturePosition(String signaturePosition); - public void setSignaturePosition(String signaturePosition) { - this.signaturePosition = signaturePosition; - } - - + public void setOutput(DataSink output); + public DataSink getOutput(); } 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 91da083e..03e48d73 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 @@ -1,5 +1,38 @@ package at.gv.egiz.pdfas.lib.api.sign; -public class SignResult { +import java.security.cert.X509Certificate; +import at.gv.egiz.pdfas.lib.api.DataSink; + +public interface SignResult { + /** + * Returns the filled output data sink. + * + * @return Returns the filled output data sink. + */ + public DataSink getOutputDocument(); + + /** + * Returns the certificate of the signer. + * + * @return Returns the certificate of the signer. + */ + public X509Certificate getSignerCertificate(); + + /** + * Returns the position where the signature is finally placed. + * + * <p> + * This information can be useful for post-processing the document. + * </p> + * + * <p> + * Consult the PDF-AS documentation section Commandline for further + * information about positioning. + * </p> + * + * @return Returns the position where the signature is finally placed. May + * return null if no position information is available. + */ + //public SignaturePosition getSignaturePosition(); } diff --git a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/api/verify/VerifyParameter.java b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/api/verify/VerifyParameter.java index 8c53ad47..914838ed 100644 --- a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/api/verify/VerifyParameter.java +++ b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/api/verify/VerifyParameter.java @@ -1,14 +1,9 @@ package at.gv.egiz.pdfas.lib.api.verify; -import at.gv.egiz.pdfas.lib.api.Configuration; -import at.gv.egiz.pdfas.lib.api.IDataSource; import at.gv.egiz.pdfas.lib.api.PdfAsParameter; -public class VerifyParameter extends PdfAsParameter { +public interface VerifyParameter extends PdfAsParameter { - public VerifyParameter(Configuration configuration, - IDataSource dataSource) { - super(configuration, dataSource); - } + } |