diff options
Diffstat (limited to 'pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl')
5 files changed, 128 insertions, 1 deletions
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 e4132e91..adef37af 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 @@ -2,6 +2,7 @@ package at.gv.egiz.pdfas.lib.impl; import java.io.ByteArrayInputStream; import java.io.File; +import java.io.OutputStream; import java.util.List; import org.apache.pdfbox.pdmodel.PDDocument; @@ -145,7 +146,18 @@ public class PdfAsImpl implements PdfAs, IConfigurationConstants { // TODO: Create signature - return null; + status.getPdfObject().setSignedDocument(status.getPdfObject().getStampedDocument()); + + // ================================================================ + // Create SignResult + SignResultImpl result = new SignResultImpl(status.getSignParamter().getOutput()); + OutputStream outputStream = result.getOutputDocument().createOutputStream(); + + outputStream.write(status.getPdfObject().getSignedDocument()); + + outputStream.close(); + + return result; } catch (Throwable e) { logger.error("sign failed " + e.getMessage(), e); throw new PdfAsException("sign Failed", e); diff --git a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/PdfAsParameterImpl.java b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/PdfAsParameterImpl.java new file mode 100644 index 00000000..d4bb44e6 --- /dev/null +++ b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/PdfAsParameterImpl.java @@ -0,0 +1,33 @@ +package at.gv.egiz.pdfas.lib.impl; + +import at.gv.egiz.pdfas.lib.api.Configuration; +import at.gv.egiz.pdfas.lib.api.DataSource; +import at.gv.egiz.pdfas.lib.api.PdfAsParameter; + +public class PdfAsParameterImpl implements PdfAsParameter { +protected Configuration configuration; + + protected DataSource dataSource; + + public PdfAsParameterImpl(Configuration configuration, + DataSource dataSource) { + this.configuration = configuration; + this.dataSource = dataSource; + } + + public Configuration getConfiguration() { + return configuration; + } + + public void setConfiguration(Configuration configuration) { + this.configuration = configuration; + } + + public DataSource getDataSource() { + return dataSource; + } + + public void setDataSource(DataSource dataSource) { + this.dataSource = dataSource; + } +} 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 new file mode 100644 index 00000000..7989bca7 --- /dev/null +++ b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/SignParameterImpl.java @@ -0,0 +1,45 @@ +package at.gv.egiz.pdfas.lib.impl; + +import at.gv.egiz.pdfas.lib.api.Configuration; +import at.gv.egiz.pdfas.lib.api.DataSink; +import at.gv.egiz.pdfas.lib.api.DataSource; +import at.gv.egiz.pdfas.lib.api.sign.SignParameter; + +public class SignParameterImpl extends PdfAsParameterImpl implements SignParameter { + protected String signatureProfileId = null; + protected String signaturePosition = null; + protected DataSink output = null; + + public SignParameterImpl(Configuration configuration, + DataSource dataSource) { + super(configuration, dataSource); + } + + // ======================================================================== + + public String getSignatureProfileId() { + return signatureProfileId; + } + + public void setSignatureProfileId(String signatureProfileId) { + this.signatureProfileId = signatureProfileId; + } + + public String getSignaturePosition() { + return signaturePosition; + } + + public void setSignaturePosition(String signaturePosition) { + this.signaturePosition = signaturePosition; + } + + public void setOutput(DataSink output) { + this.output = output; + } + + public DataSink getOutput() { + return this.output; + } + + +} 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 new file mode 100644 index 00000000..dcb27be9 --- /dev/null +++ b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/SignResultImpl.java @@ -0,0 +1,25 @@ +package at.gv.egiz.pdfas.lib.impl; + +import java.security.cert.X509Certificate; + +import at.gv.egiz.pdfas.lib.api.DataSink; +import at.gv.egiz.pdfas.lib.api.sign.SignResult; + +public class SignResultImpl implements SignResult { + + protected DataSink dataSink; + + public SignResultImpl(DataSink dataSink) { + this.dataSink = dataSink; + } + + public DataSink getOutputDocument() { + return this.dataSink; + } + + public X509Certificate getSignerCertificate() { + // TODO Auto-generated method stub + return null; + } + +} diff --git a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/VerifyParameterImpl.java b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/VerifyParameterImpl.java new file mode 100644 index 00000000..a82daba8 --- /dev/null +++ b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/VerifyParameterImpl.java @@ -0,0 +1,12 @@ +package at.gv.egiz.pdfas.lib.impl; + +import at.gv.egiz.pdfas.lib.api.Configuration; +import at.gv.egiz.pdfas.lib.api.DataSource; +import at.gv.egiz.pdfas.lib.api.verify.VerifyParameter; + +public class VerifyParameterImpl extends PdfAsParameterImpl implements VerifyParameter { + public VerifyParameterImpl(Configuration configuration, + DataSource dataSource) { + super(configuration, dataSource); + } +} |