diff options
Diffstat (limited to 'src/main/java')
-rw-r--r-- | src/main/java/at/gv/egiz/pdfas/algorithmSuite/AlgorithmSuiteObject.java | 27 | ||||
-rw-r--r-- | src/main/java/at/gv/egiz/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
* <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));
|