summaryrefslogtreecommitdiff
path: root/pdf-over-signer/pdf-over-sigpdfas/src/main/java/at/asit/pdfover/signer/pdfas/PDFASHelper.java
diff options
context:
space:
mode:
authortkellner <tkellner@174cde9d-5d70-4d2a-aa98-46368bc2aaf7>2013-04-10 18:51:24 +0000
committertkellner <tkellner@174cde9d-5d70-4d2a-aa98-46368bc2aaf7>2013-04-10 18:51:24 +0000
commit782e41eee1f04f86bc895a95cd2d51353284987a (patch)
tree746d56e559d27f6a54a1ad63901dc5135d7128d2 /pdf-over-signer/pdf-over-sigpdfas/src/main/java/at/asit/pdfover/signer/pdfas/PDFASHelper.java
parent5793f0dc194ae3519de7a12808d99aa2a555cd73 (diff)
downloadmocca-782e41eee1f04f86bc895a95cd2d51353284987a.tar.gz
mocca-782e41eee1f04f86bc895a95cd2d51353284987a.tar.bz2
mocca-782e41eee1f04f86bc895a95cd2d51353284987a.zip
Refactoring
git-svn-id: https://joinup.ec.europa.eu/svn/pdf-over/trunk@11 174cde9d-5d70-4d2a-aa98-46368bc2aaf7
Diffstat (limited to 'pdf-over-signer/pdf-over-sigpdfas/src/main/java/at/asit/pdfover/signer/pdfas/PDFASHelper.java')
-rw-r--r--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/pdf-over-signer/pdf-over-sigpdfas/src/main/java/at/asit/pdfover/signer/pdfas/PDFASHelper.java b/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/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;
+ }
+}