From d1d5c8bfbcc62967b7884a61b16b38a24cc2a366 Mon Sep 17 00:00:00 2001 From: ferbas Date: Mon, 2 Nov 2009 09:11:21 +0000 Subject: added hasprefix parameter git-svn-id: https://joinup.ec.europa.eu/svn/pdf-as/trunk@377 7b5415b0-85f9-ee4d-85bd-d5d0c3b42d1c --- .../pdfas/algorithmSuite/AlgorithmSuiteObject.java | 27 ++++++++++++++++++---- .../pdfas/algorithmSuite/AlgorithmSuiteUtil.java | 4 ++-- 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/src/main/java/at/gv/egiz/pdfas/algorithmSuite/AlgorithmSuiteObject.java b/src/main/java/at/gv/egiz/pdfas/algorithmSuite/AlgorithmSuiteObject.java index d95516e..2e17173 100644 --- a/src/main/java/at/gv/egiz/pdfas/algorithmSuite/AlgorithmSuiteObject.java +++ b/src/main/java/at/gv/egiz/pdfas/algorithmSuite/AlgorithmSuiteObject.java @@ -34,24 +34,43 @@ public class AlgorithmSuiteObject { /** * Create object from parameter string like * etsi-moc-1.2:ecdsa-sha1:ripemd160@207c44ff + * Prefix included * * @param parameterString */ public AlgorithmSuiteObject(String parameterString) { - parseFrom(parameterString); + parseFrom(parameterString, true); + } + + /** + * Create object from parameter string like
+ * etsi-moc-1.2:ecdsa-sha1:ripemd160@207c44ff hasPrefix=true
+ * ecdsa-sha1:ripemd160@207c44ff hasPrefix=false + * + * + * @param parameterString + * @param hasPrefix parse with/without prefix (e.g. etsi-moc-1.2) + */ + public AlgorithmSuiteObject(String parameterString, boolean hasPrefix) { + parseFrom(parameterString, hasPrefix); } /** * Initializes object from parameter string like - * etsi-moc-1.2:ecdsa-sha1:ripemd160@207c44ff + * etsi-moc-1.2:ecdsa-sha1:ripemd160@207c44ff hasPrefix=true
+ * ecdsa-sha1:ripemd160@207c44ff hasPrefix=false * * @param parameterString + * @param hasPrefix parse with/without prefix (e.g. etsi-moc-1.2) */ - public void parseFrom(String parameterString) { + public void parseFrom(String parameterString, boolean hasPrefix) { log.debug("parsing algorithmSuite from " + parameterString); if (parameterString != null) { parameterString = parameterString.split("@")[0]; - String[] arr = parameterString.split(":"); + if (!hasPrefix) { + parameterString = "bla:" + parameterString; // fake prefix + } + String[] arr = parameterString.split(":"); if (arr.length > 1) { this.signatureMethod = arr[1]; this.dataDigestMethod = this.propertiesDigestMethod = this.certDigestMethod = AlgorithmMapper diff --git a/src/main/java/at/gv/egiz/pdfas/algorithmSuite/AlgorithmSuiteUtil.java b/src/main/java/at/gv/egiz/pdfas/algorithmSuite/AlgorithmSuiteUtil.java index 0a1a5e4..0ab9729 100644 --- a/src/main/java/at/gv/egiz/pdfas/algorithmSuite/AlgorithmSuiteUtil.java +++ b/src/main/java/at/gv/egiz/pdfas/algorithmSuite/AlgorithmSuiteUtil.java @@ -41,7 +41,7 @@ public class AlgorithmSuiteUtil { String ids_string = so.getSigID(); //AlgorithmSuiteObject algSuite = new AlgorithmSuiteObject(ids_string); - algSuite.parseFrom(ids_string); + algSuite.parseFrom(ids_string, true); if (algSuite.isSpecified()) { log.debug("Algorithm suite defined as parameter. Using new dynamic template replacement."); cert_alg = AlgorithmMapper.getUri(algSuite.getSignatureMethod()); @@ -107,7 +107,7 @@ public class AlgorithmSuiteUtil { } private static String createSigDevString(String suite, List digAlgs) { - StringBuilder sb = new StringBuilder(AlgorithmMapper.getAbbreviation(suite)); + StringBuffer sb = new StringBuffer(AlgorithmMapper.getAbbreviation(suite)); for (Iterator iterator = digAlgs.iterator(); iterator.hasNext();) { String dig = (String) iterator.next(); sb.append(":").append(AlgorithmMapper.getAbbreviation(dig)); -- cgit v1.2.3