diff options
author | tknall <tknall@7b5415b0-85f9-ee4d-85bd-d5d0c3b42d1c> | 2009-04-27 08:16:42 +0000 |
---|---|---|
committer | tknall <tknall@7b5415b0-85f9-ee4d-85bd-d5d0c3b42d1c> | 2009-04-27 08:16:42 +0000 |
commit | c4efec1daeb50b30d363bb9fb83aec5435dbf2ad (patch) | |
tree | e64dabcd20551714fb5f342d504927995e8c648a /src/main/java/at/knowcenter/wag/egov/egiz/sig/sigkz | |
parent | a8c39b215939a0ddd01f4c110fbc9070fbb8d9ca (diff) | |
download | pdf-as-3-c4efec1daeb50b30d363bb9fb83aec5435dbf2ad.tar.gz pdf-as-3-c4efec1daeb50b30d363bb9fb83aec5435dbf2ad.tar.bz2 pdf-as-3-c4efec1daeb50b30d363bb9fb83aec5435dbf2ad.zip |
New signature layout for new MOCCA bku integrated (etsi-moc-1.1).
New architecture implemented that allows different signature layouts for single types of BKUs.
git-svn-id: https://joinup.ec.europa.eu/svn/pdf-as/trunk@337 7b5415b0-85f9-ee4d-85bd-d5d0c3b42d1c
Diffstat (limited to 'src/main/java/at/knowcenter/wag/egov/egiz/sig/sigkz')
-rw-r--r-- | src/main/java/at/knowcenter/wag/egov/egiz/sig/sigkz/SigKZIDHelper.java | 62 |
1 files changed, 58 insertions, 4 deletions
diff --git a/src/main/java/at/knowcenter/wag/egov/egiz/sig/sigkz/SigKZIDHelper.java b/src/main/java/at/knowcenter/wag/egov/egiz/sig/sigkz/SigKZIDHelper.java index 67c5e15..5c3fc07 100644 --- a/src/main/java/at/knowcenter/wag/egov/egiz/sig/sigkz/SigKZIDHelper.java +++ b/src/main/java/at/knowcenter/wag/egov/egiz/sig/sigkz/SigKZIDHelper.java @@ -3,14 +3,22 @@ */
package at.knowcenter.wag.egov.egiz.sig.sigkz;
+import java.util.Iterator;
+import java.util.Vector;
+import java.util.regex.Pattern;
+
import org.apache.commons.lang.ArrayUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import at.gv.egiz.pdfas.exceptions.ErrorCode;
import at.knowcenter.wag.egov.egiz.PdfASID;
+import at.knowcenter.wag.egov.egiz.cfg.SettingsReader;
import at.knowcenter.wag.egov.egiz.exceptions.ConnectorException;
import at.knowcenter.wag.egov.egiz.exceptions.InvalidIDException;
+import at.knowcenter.wag.egov.egiz.exceptions.SettingNotFoundException;
+import at.knowcenter.wag.egov.egiz.exceptions.SettingsException;
import at.knowcenter.wag.egov.egiz.framework.SignatorFactory;
import at.knowcenter.wag.egov.egiz.sig.connectors.bku.SignSignatureObject;
import at.knowcenter.wag.egov.egiz.sig.sigid.DetachedLocRefMOAIdFormatter;
@@ -95,17 +103,34 @@ public final class SigKZIDHelper * @author tknall
*/
public static boolean isMOCCASigned(SignSignatureObject so) {
- String sig_kz = so.kz;
String sig_id = so.id;
- if (StringUtils.isEmpty(sig_kz) || StringUtils.isEmpty(sig_id)) {
+ if (StringUtils.isEmpty(sig_id)) {
return false;
}
String[] ids = sig_id.split("@");
if (ArrayUtils.isEmpty(ids)) {
return false;
}
- String prefix = ids[0];
- return DetachedMOCIdFormatter.SIG_ID_PREFIX.equals(prefix);
+ String algorithmId = parseAlgorithmId(sig_id);
+ if (algorithmId == null) {
+ return false;
+ } else {
+ return algorithmId.startsWith("etsi-moc-");
+ }
+ }
+
+ /**
+ * @author tknall
+ */
+ public static String parseAlgorithmId(String algorithmParameter) {
+ if (StringUtils.isEmpty(algorithmParameter)) {
+ return null;
+ }
+ String[] ids = algorithmParameter.split("@");
+ if (ArrayUtils.isEmpty(ids)) {
+ return null;
+ }
+ return ids[0];
}
public static boolean isOldBKU(PdfASID sig_kz, String sig_id) throws ConnectorException
@@ -158,5 +183,34 @@ public final class SigKZIDHelper return isOldBKU(kz, sig_id);
}
+
+ public static String getAlgorithmId(String bkuIdentifier) throws SettingsException, SettingNotFoundException, ConnectorException {
+ SettingsReader sr = SettingsReader.getInstance();
+
+ String base = "signaturelayout.pattern";
+ Vector v = sr.getSettingKeys(base);
+
+ Iterator it = v.iterator();
+ while (it.hasNext()) {
+ String subKey = (String) it.next();
+ String key = base + "." + subKey;
+ String value = sr.getSetting(key);
+ Pattern p = Pattern.compile(value);
+ if (p.matcher(bkuIdentifier).matches()) {
+ String algKey = "signaturelayout.algorithm.id." + subKey;
+ String algValue = sr.getSetting(algKey);
+ return algValue;
+ }
+ }
+
+ if ("true".equalsIgnoreCase(sr.getSetting("signaturelayout.strict", "false"))) {
+ logger.debug("Enforcing bku support check.");
+ throw new ConnectorException(ErrorCode.BKU_NOT_SUPPORTED, "Unsupported BKU: " + bkuIdentifier);
+ } else {
+ logger.debug("bku support check disabled.");
+ return null;
+ }
+
+ }
}
|