summaryrefslogtreecommitdiff
path: root/trunk/pdf-over-signer/pdf-over-sigpdfas/src/main/java/at/asit/pdfover/signer/pdfas/PDFASHelper.java
diff options
context:
space:
mode:
authortkellner <tkellner@3a0b52a2-8410-0410-bc02-ff6273a87459>2012-08-07 14:52:00 +0000
committertkellner <tkellner@3a0b52a2-8410-0410-bc02-ff6273a87459>2012-08-07 14:52:00 +0000
commit94bf81d31e74a209d60f2fd4f1f20448770bf1a0 (patch)
treeee0a3ebc6e659360cbf822bf428034c33527ce39 /trunk/pdf-over-signer/pdf-over-sigpdfas/src/main/java/at/asit/pdfover/signer/pdfas/PDFASHelper.java
parentef8b65e36085eb8d113620cb91ae1f0b2695eea2 (diff)
downloadpdf-over-94bf81d31e74a209d60f2fd4f1f20448770bf1a0.tar.gz
pdf-over-94bf81d31e74a209d60f2fd4f1f20448770bf1a0.tar.bz2
pdf-over-94bf81d31e74a209d60f2fd4f1f20448770bf1a0.zip
Refactoring
git-svn-id: https://svn.iaik.tugraz.at/svn/egiz/prj/current/12PDF-OVER-4.0@12276 3a0b52a2-8410-0410-bc02-ff6273a87459
Diffstat (limited to 'trunk/pdf-over-signer/pdf-over-sigpdfas/src/main/java/at/asit/pdfover/signer/pdfas/PDFASHelper.java')
-rw-r--r--trunk/pdf-over-signer/pdf-over-sigpdfas/src/main/java/at/asit/pdfover/signer/pdfas/PDFASHelper.java73
1 files changed, 73 insertions, 0 deletions
diff --git a/trunk/pdf-over-signer/pdf-over-sigpdfas/src/main/java/at/asit/pdfover/signer/pdfas/PDFASHelper.java b/trunk/pdf-over-signer/pdf-over-sigpdfas/src/main/java/at/asit/pdfover/signer/pdfas/PDFASHelper.java
new file mode 100644
index 00000000..756478d3
--- /dev/null
+++ b/trunk/pdf-over-signer/pdf-over-sigpdfas/src/main/java/at/asit/pdfover/signer/pdfas/PDFASHelper.java
@@ -0,0 +1,73 @@
+package at.asit.pdfover.signer.pdfas;
+
+import at.asit.pdfover.signator.SignatureException;
+import at.gv.egiz.pdfas.api.PdfAs;
+import at.gv.egiz.pdfas.api.exceptions.PdfAsException;
+import at.gv.egiz.pdfas.api.internal.PdfAsInternal;
+
+/**
+ * Encapsulates PDF AS API Object to need just one initialization
+ * @author afitzek
+ */
+public class PDFASHelper {
+
+ /**
+ * PDF AS Object
+ */
+ private static PdfAs pdfAs = null;
+
+ /**
+ * Internal Pdf AS Object
+ */
+ private static PdfAsInternal pdfAsInternal = null;
+
+ /**
+ * Creates PDF AS Object
+ * @return
+ * @throws PdfAsException
+ */
+ private static PdfAs createPdfAs() throws PdfAsException {
+ return new at.gv.egiz.pdfas.impl.api.PdfAsObject();
+ }
+
+ /**
+ * Creates a PDF-AS Internal object
+ * @return the PDF-AS Internal object
+ * @throws PdfAsException
+ */
+ private static PdfAsInternal createPdfAsInternal() throws PdfAsException {
+ return new at.gv.egiz.pdfas.impl.api.internal.PdfAsInternalObject();
+ }
+
+ /**
+ * Gets PDF-AS Object
+ * @return the PDF-AS Object
+ * @throws SignatureException
+ */
+ public static synchronized PdfAs getPdfAs() throws SignatureException {
+ if (pdfAs == null) {
+ try {
+ pdfAs = createPdfAs();
+ } catch(PdfAsException e) {
+ throw new SignatureException(e);
+ }
+ }
+ return pdfAs;
+ }
+
+ /**
+ * Gets PDF-AS Internal object
+ * @return the PDF-AS Internal object
+ * @throws SignatureException
+ */
+ public static synchronized PdfAsInternal getPdfAsInternal() throws SignatureException {
+ if(pdfAsInternal == null) {
+ try {
+ pdfAsInternal = createPdfAsInternal();
+ } catch(PdfAsException e) {
+ throw new SignatureException(e);
+ }
+ }
+ return pdfAsInternal;
+ }
+}