diff options
Diffstat (limited to 'pdf-over/pdf-signer-interface/src/main/java/at/asit')
7 files changed, 120 insertions, 5 deletions
diff --git a/pdf-over/pdf-signer-interface/src/main/java/at/asit/pdfover/pdfsigner/CollimatingMark.java b/pdf-over/pdf-signer-interface/src/main/java/at/asit/pdfover/pdfsigner/CollimatingMark.java index ad956fa7..cfca74fa 100644 --- a/pdf-over/pdf-signer-interface/src/main/java/at/asit/pdfover/pdfsigner/CollimatingMark.java +++ b/pdf-over/pdf-signer-interface/src/main/java/at/asit/pdfover/pdfsigner/CollimatingMark.java @@ -1,5 +1,6 @@ package at.asit.pdfover.pdfsigner; -public class CollimatingMark { - +public interface CollimatingMark { + + public String GetFileName(); } diff --git a/pdf-over/pdf-signer-interface/src/main/java/at/asit/pdfover/pdfsigner/PDFSignator.java b/pdf-over/pdf-signer-interface/src/main/java/at/asit/pdfover/pdfsigner/PDFSignator.java new file mode 100644 index 00000000..9fb14b4a --- /dev/null +++ b/pdf-over/pdf-signer-interface/src/main/java/at/asit/pdfover/pdfsigner/PDFSignator.java @@ -0,0 +1,68 @@ +package at.asit.pdfover.pdfsigner; + +import java.util.HashMap; +import java.util.Map; + +/** + * PDF Signator Interface + * @author afitzek + */ +public class PDFSignator { + + protected static Map<PDFSigner, PDFSignerFactory> _factory; + + // Let Factory choose if instance can be cached or not + //protected static Map<PDFSigner, PDFSignerInterface> _signer; + + static { + //_signer = new HashMap<PDFSigner, PDFSignerInterface>(); + _factory = new HashMap<PDFSigner, PDFSignerFactory>(); + + + try { + @SuppressWarnings("rawtypes") + Class pdfAsClass = Class.forName("at.asit.pdfover.pdfsigner.pdfas.PDFASSignerFactory"); + PDFSignerFactory factory = (PDFSignerFactory)pdfAsClass.newInstance(); + RegisterPDFSigner(factory.GetPDFSignerType(), factory); + } catch (ClassNotFoundException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (InstantiationException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (IllegalAccessException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + } + + public static void RegisterPDFSigner(PDFSigner signer, PDFSignerFactory factory) { + _factory.put(signer, factory); + } + + protected static PDFSignerInterface GetSigner(PDFSigner signer) throws PDFSignatureException { + /*if (_signer.containsKey(signer)) { + return _signer.get(signer); + }*/ + + if(_factory.containsKey(signer)) { + //_signer.put(signer, _factory.get(signer).CreatePDFSigner()); + return _factory.get(signer).CreatePDFSigner(); + } else { + throw new PDFSignatureException("Unknown PDF Library: " + signer.toString()); + } + + //return _signer.get(signer); + } + + /** + * Gets a PDF Signer according to the chosen pdf signer library + * @param signer + * @return + * @throws PDFSignatureException + */ + public static PDFSignerInterface GetPDFSigner(PDFSigner signer) throws PDFSignatureException { + return GetSigner(signer); + } +} diff --git a/pdf-over/pdf-signer-interface/src/main/java/at/asit/pdfover/pdfsigner/PDFSigner.java b/pdf-over/pdf-signer-interface/src/main/java/at/asit/pdfover/pdfsigner/PDFSigner.java new file mode 100644 index 00000000..332c111b --- /dev/null +++ b/pdf-over/pdf-signer-interface/src/main/java/at/asit/pdfover/pdfsigner/PDFSigner.java @@ -0,0 +1,20 @@ +/** + * + */ +package at.asit.pdfover.pdfsigner; + +/** + * Available PDF Signer libraries + * @author afitzek + */ +public enum PDFSigner { + /** + * @uml.property name="pDFAS" + * @uml.associationEnd + */ + PDFAS { + public String toString() { + return "PDFAS"; + } + } +} diff --git a/pdf-over/pdf-signer-interface/src/main/java/at/asit/pdfover/pdfsigner/PDFSignerFactory.java b/pdf-over/pdf-signer-interface/src/main/java/at/asit/pdfover/pdfsigner/PDFSignerFactory.java new file mode 100644 index 00000000..348c649a --- /dev/null +++ b/pdf-over/pdf-signer-interface/src/main/java/at/asit/pdfover/pdfsigner/PDFSignerFactory.java @@ -0,0 +1,6 @@ +package at.asit.pdfover.pdfsigner; + +public abstract class PDFSignerFactory { + public abstract PDFSignerInterface CreatePDFSigner(); + public abstract PDFSigner GetPDFSignerType(); +} diff --git a/pdf-over/pdf-signer-interface/src/main/java/at/asit/pdfover/pdfsigner/SignResultImpl.java b/pdf-over/pdf-signer-interface/src/main/java/at/asit/pdfover/pdfsigner/SignResultImpl.java index 433ad093..72a08d1f 100644 --- a/pdf-over/pdf-signer-interface/src/main/java/at/asit/pdfover/pdfsigner/SignResultImpl.java +++ b/pdf-over/pdf-signer-interface/src/main/java/at/asit/pdfover/pdfsigner/SignResultImpl.java @@ -7,7 +7,7 @@ public class SignResultImpl implements SignResult { private SignaturePosition position; private DocumentSource source; private X509Certificate certificate; - + @Override public SignaturePosition GetSignaturePosition() { return position; diff --git a/pdf-over/pdf-signer-interface/src/main/java/at/asit/pdfover/pdfsigner/SignatureParameter.java b/pdf-over/pdf-signer-interface/src/main/java/at/asit/pdfover/pdfsigner/SignatureParameter.java index 422b2c75..5876f1ef 100644 --- a/pdf-over/pdf-signer-interface/src/main/java/at/asit/pdfover/pdfsigner/SignatureParameter.java +++ b/pdf-over/pdf-signer-interface/src/main/java/at/asit/pdfover/pdfsigner/SignatureParameter.java @@ -1,5 +1,7 @@ package at.asit.pdfover.pdfsigner; +import java.util.HashMap; + /** * The Signature Parameter * @author afitzek @@ -102,5 +104,23 @@ public abstract class SignatureParameter { this.collimark = value; } + protected HashMap<String, String> _properties = new HashMap<String, String>(); + + /** + * Sets generic properties + * @param key + * @param value + */ + public void SetProperty(String key, String value) { + this._properties.put(key, value); + } + /** + * Gets generic properties + * @param key + * @return + */ + public String GetProperty(String key) { + return this._properties.get(key); + } } diff --git a/pdf-over/pdf-signer-interface/src/main/java/at/asit/pdfover/pdfsigner/SigningState.java b/pdf-over/pdf-signer-interface/src/main/java/at/asit/pdfover/pdfsigner/SigningState.java index ac0c736a..d1920135 100644 --- a/pdf-over/pdf-signer-interface/src/main/java/at/asit/pdfover/pdfsigner/SigningState.java +++ b/pdf-over/pdf-signer-interface/src/main/java/at/asit/pdfover/pdfsigner/SigningState.java @@ -10,11 +10,11 @@ public interface SigningState { * Gets the Security Layer Request to create the signature * @return The SL Signature Request */ - public SLRequest GetSLSignatureRequest(); + public abstract SLRequest GetSLSignatureRequest(); /** * Sets the Security Layer Request to create the signature * @param value The SL Signature Request */ - public void SetSLSignatureResponse(SLResponse value); + public abstract void SetSLSignatureResponse(SLResponse value); } |