summaryrefslogtreecommitdiff
path: root/pdf-over-signator/src/main
diff options
context:
space:
mode:
authorJakob Heher <jakob.heher@iaik.tugraz.at>2022-08-02 14:18:37 +0200
committerJakob Heher <jakob.heher@iaik.tugraz.at>2022-08-02 14:18:37 +0200
commit62a3115ce4d55a7a3b3fbf202bac0fff85dc412b (patch)
tree21259582d60491447e06e941682df7ada3437c46 /pdf-over-signator/src/main
parent2513de9079b48864c89d7a633a0a4fa43d2f313f (diff)
downloadpdf-over-62a3115ce4d55a7a3b3fbf202bac0fff85dc412b.tar.gz
pdf-over-62a3115ce4d55a7a3b3fbf202bac0fff85dc412b.tar.bz2
pdf-over-62a3115ce4d55a7a3b3fbf202bac0fff85dc412b.zip
YAGNI: PDF signer factory pattern
Diffstat (limited to 'pdf-over-signator/src/main')
-rw-r--r--pdf-over-signator/src/main/java/at/asit/pdfover/signator/Signator.java86
-rw-r--r--pdf-over-signator/src/main/java/at/asit/pdfover/signator/Signer.java48
-rw-r--r--pdf-over-signator/src/main/java/at/asit/pdfover/signator/SignerFactory.java28
3 files changed, 0 insertions, 162 deletions
diff --git a/pdf-over-signator/src/main/java/at/asit/pdfover/signator/Signator.java b/pdf-over-signator/src/main/java/at/asit/pdfover/signator/Signator.java
deleted file mode 100644
index 798788d2..00000000
--- a/pdf-over-signator/src/main/java/at/asit/pdfover/signator/Signator.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * Copyright 2012 by A-SIT, Secure Information Technology Center Austria
- *
- * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by
- * the European Commission - subsequent versions of the EUPL (the "Licence");
- * You may not use this work except in compliance with the Licence.
- * You may obtain a copy of the Licence at:
- * http://joinup.ec.europa.eu/software/page/eupl
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the Licence is distributed on an "AS IS" basis,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the Licence for the specific language governing permissions and
- * limitations under the Licence.
- */
-package at.asit.pdfover.signator;
-
-//Imports
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.lang.reflect.InvocationTargetException;
-import java.util.EnumMap;
-import java.util.Map;
-
-/**
- * PDF Signator Interface
- */
-public class Signator {
-
- /**
- * SLF4J Logger instance
- **/
- private static Logger log = LoggerFactory.getLogger(Signator.class);
-
- /**
- * List of available PDF signing libraries
- */
- public enum Signers {
- /**
- * PDF-AS 3
- */
- PDFAS,
- /**
- * PDF-AS 4
- */
- PDFAS4
- };
-
- private static Map<Signers, SignerFactory> factoryMap;
-
- static {
- factoryMap = new EnumMap<Signers, SignerFactory>(Signers.class);
-
- try {
-// Class<?> pdfAsClass = Class.forName("at.asit.pdfover.signer.pdfas.PDFASSignerFactory");
-// SignerFactory factory = (SignerFactory)pdfAsClass.newInstance();
-// registerSigner(Signers.PDFAS, factory);
- Class<?> pdfAs4Class = Class.forName("at.asit.pdfover.signer.pdfas.PdfAs4SignerFactory");
- SignerFactory factory = (SignerFactory)pdfAs4Class.getDeclaredConstructor().newInstance();
- registerSigner(Signers.PDFAS4, factory);
- } catch (ClassNotFoundException e) {
- log.error("PDF Signer Factory not found", e);
- throw new RuntimeException("PDF Signer Factory not found", e);
- } catch (InstantiationException | InvocationTargetException | NoSuchMethodException e) {
- log.error("PDF Signer Factory could not be instantiated", e);
- throw new RuntimeException("PDF Signer Factory could not be instantiated", e);
- } catch (IllegalAccessException e) {
- log.error("PDF Signer Factory could not accessed", e);
- throw new RuntimeException("PDF Signer Factory could not accessed", e);
- }
- }
-
- private static void registerSigner(Signers signer, SignerFactory factory) {
- factoryMap.put(signer, factory);
- }
-
- /**
- * Gets a PDF Signer according to the chosen signer library
- * @param signer the chosen Signer type
- * @return the PDF Signer
- */
- public static Signer getSigner(Signers signer) {
- return factoryMap.get(signer).createSigner();
- }
-}
diff --git a/pdf-over-signator/src/main/java/at/asit/pdfover/signator/Signer.java b/pdf-over-signator/src/main/java/at/asit/pdfover/signator/Signer.java
deleted file mode 100644
index 5140f0e0..00000000
--- a/pdf-over-signator/src/main/java/at/asit/pdfover/signator/Signer.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Copyright 2012 by A-SIT, Secure Information Technology Center Austria
- *
- * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by
- * the European Commission - subsequent versions of the EUPL (the "Licence");
- * You may not use this work except in compliance with the Licence.
- * You may obtain a copy of the Licence at:
- * http://joinup.ec.europa.eu/software/page/eupl
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the Licence is distributed on an "AS IS" basis,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the Licence for the specific language governing permissions and
- * limitations under the Licence.
- */
-package at.asit.pdfover.signator;
-
-/**
- * PDF Signer base Class
- * This class should be extended to support libraries such as PDF-AS or PADES.
- */
-public interface Signer {
-
- /**
- * Prepare a signature
- * Defines signature parameters, the pdf library prepares the pdf document to sign and
- * creates a Security Layer Request.
- * @param parameter The signature parameters
- * @return The signing state (contains the prepared document and the signature request
- * @throws SignatureException
- */
- public SigningState prepare(SignatureParameter parameter) throws SignatureException;
-
- /**
- * Adds the signature to the document.
- * The SL Response has to be set in the state
- * @param state The signing state
- * @return The signature Result
- * @throws SignatureException
- */
- public SignResult sign(SigningState state) throws SignatureException;
-
- /**
- * Creates new signing profile
- * @return The new Profile
- */
- public SignatureParameter newParameter();
-}
diff --git a/pdf-over-signator/src/main/java/at/asit/pdfover/signator/SignerFactory.java b/pdf-over-signator/src/main/java/at/asit/pdfover/signator/SignerFactory.java
deleted file mode 100644
index cde150f8..00000000
--- a/pdf-over-signator/src/main/java/at/asit/pdfover/signator/SignerFactory.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Copyright 2012 by A-SIT, Secure Information Technology Center Austria
- *
- * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by
- * the European Commission - subsequent versions of the EUPL (the "Licence");
- * You may not use this work except in compliance with the Licence.
- * You may obtain a copy of the Licence at:
- * http://joinup.ec.europa.eu/software/page/eupl
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the Licence is distributed on an "AS IS" basis,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the Licence for the specific language governing permissions and
- * limitations under the Licence.
- */
-package at.asit.pdfover.signator;
-
-/**
- * A Signer factory
- * Creates Signer instances
- */
-public abstract class SignerFactory {
- /**
- * Create a Signer
- * @return the new Signer
- */
- public abstract Signer createSigner();
-}