From 364cb2a6dc344804504636df7b890793a44077d6 Mon Sep 17 00:00:00 2001 From: tknall Date: Tue, 4 Mar 2008 13:18:44 +0000 Subject: SignatureProfile extended in order to retrieve further profile information via API call. git-svn-id: https://joinup.ec.europa.eu/svn/pdf-as/trunk@251 7b5415b0-85f9-ee4d-85bd-d5d0c3b42d1c --- .../at/gv/egiz/pdfas/impl/api/PdfAsObject.java | 23 ++++++++++- .../impl/api/commons/SignatureProfileImpl.java | 46 +++++++++++++++++++++- 2 files changed, 67 insertions(+), 2 deletions(-) (limited to 'src/main/java/at/gv/egiz/pdfas/impl/api') diff --git a/src/main/java/at/gv/egiz/pdfas/impl/api/PdfAsObject.java b/src/main/java/at/gv/egiz/pdfas/impl/api/PdfAsObject.java index 704f9fd..39b4aff 100644 --- a/src/main/java/at/gv/egiz/pdfas/impl/api/PdfAsObject.java +++ b/src/main/java/at/gv/egiz/pdfas/impl/api/PdfAsObject.java @@ -122,7 +122,28 @@ public class PdfAsObject implements PdfAs final String profileId = profile.getType(); final String moaKeyIdentifier = settings.getSetting("sig_obj." + profileId + "." + MOA_SIGN_KEY_IDENTIFIER_KEY, defaultMoaKeyIdentifiert); - SignatureProfile signatureProfile = new SignatureProfileImpl(profileId, moaKeyIdentifier); + // modified by tknall + SignatureProfileImpl signatureProfile = new SignatureProfileImpl(profileId, moaKeyIdentifier); + + // start - added by tknall + + // add key values + final String parentProperty = "sig_obj." + profileId + ".key."; + ArrayList keys = settings.getKeys(parentProperty); + if (keys != null) { + Iterator keyIt = keys.iterator(); + while (keyIt.hasNext()) { + String key = (String) keyIt.next(); + if (key != null && key.length() > 0) { + String value = settings.getValueFromKey(parentProperty + key); + if (value != null && value.length() > 0) { + signatureProfile.setField(key, value); + } + } + } + } + // stop - added by tknall + profileInformation.add(signatureProfile); } diff --git a/src/main/java/at/gv/egiz/pdfas/impl/api/commons/SignatureProfileImpl.java b/src/main/java/at/gv/egiz/pdfas/impl/api/commons/SignatureProfileImpl.java index 0d2bfdd..f0422f6 100644 --- a/src/main/java/at/gv/egiz/pdfas/impl/api/commons/SignatureProfileImpl.java +++ b/src/main/java/at/gv/egiz/pdfas/impl/api/commons/SignatureProfileImpl.java @@ -3,6 +3,10 @@ */ package at.gv.egiz.pdfas.impl.api.commons; +import java.util.Collections; +import java.util.Hashtable; +import java.util.Set; + import at.gv.egiz.pdfas.api.commons.SignatureProfile; /** @@ -22,7 +26,17 @@ public class SignatureProfileImpl implements SignatureProfile * The MOA key identifiert of this profile. */ protected String moaKeyIdentifier = null; - + + // start - added by tknall + + /** + * A Hashtable containing all field values (as String) for the current profiles + * (sig_obj.PROFILE.key.*). + */ + protected Hashtable fields = new Hashtable(); + + // stop - added by tknall + /** * Constructor. * @@ -53,4 +67,34 @@ public class SignatureProfileImpl implements SignatureProfile return this.moaKeyIdentifier; } + // start - added by tknall + + /** + * Returns the value of a field with a given key for the current profile. + *

e.g.
signaturProfile.getField(SignatureTypes.SIG_ISSUER)
+ * returns "Issuer-Certificate"

+ * null is returned if a field with key key could not be found. + * @param key The key for the field to be returned or null if there is not such field. + * @return The value of the field with key key. + * @see at.knowcenter.wag.egov.egiz.sig.SignatureTypes + */ + public String getField(String key) { + return (String) this.fields.get(key); + } + + /** + * Sets the value value for a certain field with key key. + * @param key The key of the field. + * @param value The value of the field with key key. + */ + public void setField(String key, String value) { + this.fields.put(key, value); + } + + public Set getFieldKeys() { + return Collections.unmodifiableSet(this.fields.keySet()); + } + + // stop - added by tknall + } -- cgit v1.2.3