From 65a98c4640f7ddb9d0ab3c5061ba42dd6169c202 Mon Sep 17 00:00:00 2001 From: ferbas Date: Mon, 2 Nov 2009 09:27:49 +0000 Subject: added algorithm git-svn-id: https://joinup.ec.europa.eu/svn/pdf-as/trunk@384 7b5415b0-85f9-ee4d-85bd-d5d0c3b42d1c --- .../sig/connectors/bku/SignSignatureObject.java | 107 +++++++++++++++++++++ 1 file changed, 107 insertions(+) (limited to 'src/main') diff --git a/src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/bku/SignSignatureObject.java b/src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/bku/SignSignatureObject.java index 67d5497..1d7895e 100644 --- a/src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/bku/SignSignatureObject.java +++ b/src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/bku/SignSignatureObject.java @@ -5,8 +5,15 @@ package at.knowcenter.wag.egov.egiz.sig.connectors.bku; import java.io.Serializable; import java.security.cert.X509Certificate; +import java.util.Arrays; +import java.util.HashMap; +import java.util.Map; import java.util.Properties; +import org.apache.tools.ant.taskdefs.Length; + +import at.gv.egiz.pdfas.algorithmSuite.AlgorithmSuiteUtil; +import at.knowcenter.wag.egov.egiz.sig.SignatureTypes; import at.knowcenter.wag.egov.egiz.sig.signatureobject.AdditionalSignatureInformation; import at.knowcenter.wag.egov.egiz.sig.signatureobject.AlgorithmSignatureInformation; import at.knowcenter.wag.egov.egiz.sig.signatureobject.ConnectorSignatureInformation; @@ -30,6 +37,8 @@ public class SignSignatureObject implements Serializable, MandatorySignatureInfo public String id = null; public String kz = null; + public String sigAlgorithm; + /** * This is used to transport the response properties to the Detached signator. */ @@ -107,5 +116,103 @@ public class SignSignatureObject implements Serializable, MandatorySignatureInfo { return this.x509Certificate; } + + public String getSigAlgorithm() { + return this.sigAlgorithm; + } + + public String retrieveStringValue(String sigKey) + { + // mandatory + if (sigKey.equals(SignatureTypes.SIG_DATE)) + { + return getDate(); + } + if (sigKey.equals(SignatureTypes.SIG_VALUE)) + { + return getSignatureValue(); + } + if (sigKey.equals(SignatureTypes.SIG_ISSUER)) + { + return getIssuer(); + } + if (sigKey.equals(SignatureTypes.SIG_NUMBER)) + { + return getSerialNumber(); + } + + // connector + if (sigKey.equals(SignatureTypes.SIG_ID)) + { + return getSigID(); + } + + // algorithm + if (sigKey.equals(SignatureTypes.SIG_KZ)) + { + return getSigKZ(); + } + + // additional + if (sigKey.equals(SignatureTypes.SIG_NAME)) + { + return getName(); + } + + if (sigKey.equals(SignatureTypes.SIG_ALG)) { + return getSigAlgorithm(); + } + + throw new RuntimeException("The key '" + sigKey + "' is not a recognized SignatorObject member."); //$NON-NLS-1$ //$NON-NLS-2$ + } + +// public String certSubjectDNPart(String key) { +// String val = null; +// if (subjectDNMap == null) { +// if (this.getX509Certificate() != null) { +// val = extractDNPart(key, this.getX509Certificate().getSubjectX500Principal().getName()); +// } +// return val; +// } +// +// public String certIssuerDNPart(String key) { +// String val = null; +// if (this.getX509Certificate() != null) { +// val = extractDNPart(key, this.getX509Certificate().getIssuerX500Principal().getName()); +// } +// return val; +// } + + public String certSubjectDNPart(String key) { + if (this.subjectDNMap.size() == 0) { + if (this.getX509Certificate() != null) { + fillDNMap(this.getX509Certificate().getSubjectX500Principal().getName(), this.subjectDNMap); + } + } + return this.subjectDNMap.get(key).toString(); + } + + + public String certIssuerDNPart(String key) { + if (this.issuerDNMap.size() == 0) { + if (this.getX509Certificate() != null) { + fillDNMap(this.getX509Certificate().getIssuerX500Principal().getName(), this.issuerDNMap); + } + } + return this.issuerDNMap.get(key).toString(); + } + + private Map subjectDNMap = new HashMap(); + private Map issuerDNMap = new HashMap(); + + private void fillDNMap(String dn, Map dnMap) { + + String[] arr = dn.split("\\s*(,|;)\\s*"); + for (int i = 0; i < arr.length; i++) { + String[] entry = arr[i].split("\\s*(=)\\s*"); + dnMap.put(entry[0], entry[1]); + } + } + } -- cgit v1.2.3