aboutsummaryrefslogtreecommitdiff
path: root/pdf-as-cli/src/main
diff options
context:
space:
mode:
authorAndreas Fitzek <andreas.fitzek@iaik.tugraz.at>2013-10-03 13:38:33 +0200
committerAndreas Fitzek <andreas.fitzek@iaik.tugraz.at>2013-10-03 13:38:33 +0200
commit62434d4f7d4bf80b4c236c4153bffab703916ee3 (patch)
treed98ce0cd92e7e772e27d667a8b67cfcdc1d94db6 /pdf-as-cli/src/main
parentf076fe1f5f9c10b1f1c304956eb305987d48591a (diff)
downloadpdf-as-4-62434d4f7d4bf80b4c236c4153bffab703916ee3.tar.gz
pdf-as-4-62434d4f7d4bf80b4c236c4153bffab703916ee3.tar.bz2
pdf-as-4-62434d4f7d4bf80b4c236c4153bffab703916ee3.zip
no callback API implemted
Diffstat (limited to 'pdf-as-cli/src/main')
-rw-r--r--pdf-as-cli/src/main/java/at/gv/egiz/pdfas/cli/DeveloperMain.java32
1 files changed, 32 insertions, 0 deletions
diff --git a/pdf-as-cli/src/main/java/at/gv/egiz/pdfas/cli/DeveloperMain.java b/pdf-as-cli/src/main/java/at/gv/egiz/pdfas/cli/DeveloperMain.java
index 0e114eae..8087da19 100644
--- a/pdf-as-cli/src/main/java/at/gv/egiz/pdfas/cli/DeveloperMain.java
+++ b/pdf-as-cli/src/main/java/at/gv/egiz/pdfas/cli/DeveloperMain.java
@@ -13,6 +13,7 @@ import at.gv.egiz.pdfas.lib.api.ByteArrayDataSource;
import at.gv.egiz.pdfas.lib.api.Configuration;
import at.gv.egiz.pdfas.lib.api.PdfAs;
import at.gv.egiz.pdfas.lib.api.PdfAsFactory;
+import at.gv.egiz.pdfas.lib.api.StatusRequest;
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.verify.VerifyParameter;
@@ -42,6 +43,34 @@ public class DeveloperMain {
parameter.setSignatureProfileId("SIGNATURBLOCK_DE_NEU");
parameter.setOutput(bads);
parameter.setPlainSigner(signer);
+
+ StatusRequest request = pdfas.startSign(parameter);
+
+ if(request.needCertificate()) {
+ request.setCertificate(signer.getCertificate().getEncoded());
+ } else {
+ throw new Exception("Invalid status");
+ }
+
+ request = pdfas.process(request);
+
+ if(request.needSignature()) {
+ FileOutputStream fos2 = new FileOutputStream("/home/afitzek/devel/pdfas_neu/sign1.pdf");
+ fos2.write(request.getSignatureData());
+ fos2.close();
+ request.setSigature(signer.sign(request.getSignatureData()));
+ } else {
+ throw new Exception("Invalid status");
+ }
+
+ request = pdfas.process(request);
+
+ if(request.isReady()) {
+ pdfas.finishSign(request);
+ } else {
+ throw new Exception("Invalid status");
+ }
+
pdfas.sign(parameter);
FileOutputStream fos = new FileOutputStream("/home/afitzek/devel/pdfas_neu/simple_out.pdf");
fos.write(bads.getData());
@@ -59,6 +88,9 @@ public class DeveloperMain {
}catch (PdfAsException e) {
// TODO Auto-generated catch block
e.printStackTrace();
+ } catch (Exception e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
}
}