aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/gv
diff options
context:
space:
mode:
authorferbas <ferbas@7b5415b0-85f9-ee4d-85bd-d5d0c3b42d1c>2009-11-02 09:11:21 +0000
committerferbas <ferbas@7b5415b0-85f9-ee4d-85bd-d5d0c3b42d1c>2009-11-02 09:11:21 +0000
commitd1d5c8bfbcc62967b7884a61b16b38a24cc2a366 (patch)
tree64b9383b2734f866baa24b7265bfe94fc9f61dc3 /src/main/java/at/gv
parent1e93c1b7d05cc2b2bfb05c7fa3e111325fa5e022 (diff)
downloadpdf-as-3-d1d5c8bfbcc62967b7884a61b16b38a24cc2a366.tar.gz
pdf-as-3-d1d5c8bfbcc62967b7884a61b16b38a24cc2a366.tar.bz2
pdf-as-3-d1d5c8bfbcc62967b7884a61b16b38a24cc2a366.zip
added hasprefix parameter
git-svn-id: https://joinup.ec.europa.eu/svn/pdf-as/trunk@377 7b5415b0-85f9-ee4d-85bd-d5d0c3b42d1c
Diffstat (limited to 'src/main/java/at/gv')
-rw-r--r--src/main/java/at/gv/egiz/pdfas/algorithmSuite/AlgorithmSuiteObject.java27
-rw-r--r--src/main/java/at/gv/egiz/pdfas/algorithmSuite/AlgorithmSuiteUtil.java4
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
* <code>etsi-moc-1.2:ecdsa-sha1:ripemd160@207c44ff</code>
+ * Prefix included
*
* @param parameterString
*/
public AlgorithmSuiteObject(String parameterString) {
- parseFrom(parameterString);
+ parseFrom(parameterString, true);
+ }
+
+ /**
+ * Create object from parameter string like <br>
+ * <code>etsi-moc-1.2:ecdsa-sha1:ripemd160@207c44ff</code> hasPrefix=true <br>
+ * <code>ecdsa-sha1:ripemd160@207c44ff</code> 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
- * <code>etsi-moc-1.2:ecdsa-sha1:ripemd160@207c44ff</code>
+ * <code>etsi-moc-1.2:ecdsa-sha1:ripemd160@207c44ff</code> hasPrefix=true <br>
+ * <code>ecdsa-sha1:ripemd160@207c44ff</code> 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));