aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/knowcenter/wag/egov/egiz/sig/SignatureObject.java
diff options
context:
space:
mode:
authortknall <tknall@7b5415b0-85f9-ee4d-85bd-d5d0c3b42d1c>2007-02-07 10:08:21 +0000
committertknall <tknall@7b5415b0-85f9-ee4d-85bd-d5d0c3b42d1c>2007-02-07 10:08:21 +0000
commita0de2a3b2a5f4a99f280f5caebbca0d183ae109a (patch)
tree7479e30c10c3994cba18c6bf8784f61748bb6cd3 /src/main/java/at/knowcenter/wag/egov/egiz/sig/SignatureObject.java
parent8f7cebd9c2c5c0f6e33863ba57ad1c215f35605c (diff)
downloadpdf-as-3-a0de2a3b2a5f4a99f280f5caebbca0d183ae109a.tar.gz
pdf-as-3-a0de2a3b2a5f4a99f280f5caebbca0d183ae109a.tar.bz2
pdf-as-3-a0de2a3b2a5f4a99f280f5caebbca0d183ae109a.zip
Bugfix: Querformat, BKU 2.7.x, ...
git-svn-id: https://joinup.ec.europa.eu/svn/pdf-as/trunk@35 7b5415b0-85f9-ee4d-85bd-d5d0c3b42d1c
Diffstat (limited to 'src/main/java/at/knowcenter/wag/egov/egiz/sig/SignatureObject.java')
-rw-r--r--src/main/java/at/knowcenter/wag/egov/egiz/sig/SignatureObject.java175
1 files changed, 147 insertions, 28 deletions
diff --git a/src/main/java/at/knowcenter/wag/egov/egiz/sig/SignatureObject.java b/src/main/java/at/knowcenter/wag/egov/egiz/sig/SignatureObject.java
index 9a7a036..ae50c5e 100644
--- a/src/main/java/at/knowcenter/wag/egov/egiz/sig/SignatureObject.java
+++ b/src/main/java/at/knowcenter/wag/egov/egiz/sig/SignatureObject.java
@@ -31,6 +31,7 @@ import java.util.Hashtable;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
+import java.util.Properties;
import java.util.Set;
import java.util.Vector;
@@ -41,13 +42,14 @@ import at.knowcenter.wag.egov.egiz.cfg.ConfigLogger;
import at.knowcenter.wag.egov.egiz.cfg.SettingsReader;
import at.knowcenter.wag.egov.egiz.exceptions.InvalidIDException;
import at.knowcenter.wag.egov.egiz.exceptions.NormalizeException;
+import at.knowcenter.wag.egov.egiz.exceptions.SettingNotFoundException;
import at.knowcenter.wag.egov.egiz.exceptions.SettingsException;
import at.knowcenter.wag.egov.egiz.exceptions.SignatureException;
import at.knowcenter.wag.egov.egiz.exceptions.SignatureTypesException;
-import at.knowcenter.wag.egov.egiz.framework.SignatorFactory;
import at.knowcenter.wag.egov.egiz.ldap.api.LDAPAPIException;
import at.knowcenter.wag.egov.egiz.ldap.api.LDAPAPIFactory;
import at.knowcenter.wag.egov.egiz.ldap.client.LDAPIssuerNameFilter;
+import at.knowcenter.wag.egov.egiz.framework.SignatorFactory;
import at.knowcenter.wag.egov.egiz.table.Entry;
import at.knowcenter.wag.egov.egiz.table.Style;
import at.knowcenter.wag.egov.egiz.table.Table;
@@ -181,7 +183,7 @@ public class SignatureObject implements Serializable
* </p>
*/
protected String raw_signature_response = null;
-
+
/**
* Filters the issuer name in order to find matches.
* @author tknall
@@ -199,8 +201,6 @@ public class SignatureObject implements Serializable
}
};
-
-
/**
* The empty constructor. It initilize the normlizer, load the settings and
* set the default styles.
@@ -270,7 +270,6 @@ public class SignatureObject implements Serializable
defaultImageStyle_.setPadding(3);
defaultImageStyle_.setHAlign(Style.CENTER);
defaultImageStyle_.setVAlign(Style.MIDDLE);
-// defaultImageStyle_.setBgColor(new Color(255, 255, 255));
defaultImageStyle_.setBgColor(null);
defaultCaptionStyle_.setHAlign(Style.CENTER);
@@ -737,20 +736,42 @@ public class SignatureObject implements Serializable
setSigValue(SignatureTypes.SIG_ID, sigIds);
}
- /**
- * Set the signation id's build by a BKU signated SignatureObject.
- *
- * @param sigIds
- * The sination id's are defined into five parts, that have the same
- * base as prefix. Therefore the ids's are reduced by the base prefix
- * and stored in the SignatureObject.
- */
- public void setSignationIDs(String[] sigIds)
+ // /**
+ // * Set the signation id's build by a BKU signated SignatureObject.
+ // *
+ // * @param sigIds
+ // * The sination id's are defined into five parts, that have the same
+ // * base as prefix. Therefore the ids's are reduced by the base prefix
+ // * and stored in the SignatureObject.
+ // */
+ // public void setSignationIDs(String[] sigIds)
+ // {
+ // String join = "";
+ // String base = null;
+ // for (int arr_idx = 0; arr_idx < sigIds.length; arr_idx++)
+ // {
+ // String id = sigIds[arr_idx];
+ // if (logger_.isDebugEnabled())
+ // {
+ // logger_.debug("Set BKU id:" + id);
+ // }
+ // int id_idx = id.lastIndexOf("-");
+ // if (arr_idx == 0)
+ // {
+ // base = id.substring(0, id_idx);
+ // }
+ // String cur_id = id.substring(id_idx + 1);
+ // join += "-" + cur_id;
+ // }
+ // setSignationIDs(base + "@" + join.substring(1));
+ // }
+
+ // TODO hotfix
+ public static String formatSigIds(Properties response_properties,
+ String[] sigIds) throws SignatureException
{
-
- // FIXME[tknall]: implement workaround resp. failsafe behaviour for ids like "Signature-123456789"
-
- String join = "";
+ // ids algorithm:
+ String join = "";
String base = null;
for (int arr_idx = 0; arr_idx < sigIds.length; arr_idx++)
{
@@ -767,7 +788,47 @@ public class SignatureObject implements Serializable
String cur_id = id.substring(id_idx + 1);
join += "-" + cur_id;
}
- setSignationIDs(base + "@" + join.substring(1));
+ // setSignationIDs(base + "@" + join.substring(1));
+ String ids = base + "@" + join.substring(1);
+ // :ids algorithm
+
+ String productName = response_properties.getProperty("productName");
+ logger_.debug("productName = " + productName);
+ if (!productName.equals("trustDeskbasic"))
+ {
+ final String msg = "The BKU environment " + productName + " is not trustDeskbasic and therefore the productVersion cannot be decided.";
+ logger_.error(msg);
+ throw new SignatureException(0, msg);
+ }
+
+ String productVersion = response_properties.getProperty("productVersion");
+ logger_.debug("productVersion = " + productVersion);
+ boolean new_etsi = decideNewEtsiByBKUVersion(productVersion);
+ logger_.debug("verwende neue etsi properties = " + new_etsi);
+
+ String etsi_prefix = "";
+ if (new_etsi)
+ {
+ // TODO hotfix
+ etsi_prefix = "etsi-bka-1.0@";
+ }
+
+ String final_ids = etsi_prefix + ids;
+ logger_.debug("final_ids = " + final_ids);
+
+ return final_ids;
+ }
+
+ // TODO hotfix
+ public static boolean decideNewEtsiByBKUVersion(String productVersion)
+ {
+ boolean new_etsi = true;
+ // TODO make better
+ if (productVersion.startsWith("2.5") || productVersion.startsWith("2.4") || productVersion.startsWith("2.3") || productVersion.startsWith("2.2") || productVersion.startsWith("2.1") || productVersion.startsWith("1") || productVersion.startsWith("0"))
+ {
+ new_etsi = false;
+ }
+ return new_etsi;
}
/**
@@ -837,9 +898,51 @@ public class SignatureObject implements Serializable
*
* @return the id array
*/
- public String[] getSignationIds()
+ // TODO hotifx
+ public String getSignationIds()
{
String sig_ids = getSigValue(SignatureTypes.SIG_ID);
+ return sig_ids;
+
+ // if (sig_ids == null || sig_ids.length() == 0)
+ // {
+ // return null;
+ // }
+ //
+ // // int index = sig_ids.indexOf(PdfAS.IDS);
+ // // if (index < 0)
+ // // {
+ // // return null;
+ // // }
+ // // sig_ids = sig_ids.substring(index + PdfAS.IDS.length());
+ // //
+ // // if (sig_ids == null || sig_ids.length() == 0)
+ // // {
+ // // return null;
+ // // }
+ //
+ // String[] ids_str = sig_ids.split("@");
+ // String base = ids_str[0];
+ // String[] ids = ids_str[1].split("-");
+ // String[] real_ids = new String[5];
+ // real_ids[0] = base + "-" + ids[0];
+ // real_ids[1] = "0-" + base + "-" + ids[1];
+ // real_ids[2] = "0-" + base + "-" + ids[2];
+ // real_ids[3] = "0-" + base + "-" + ids[3];
+ // real_ids[4] = "0-" + base + "-" + ids[4];
+ // if (logger_.isDebugEnabled())
+ // {
+ // for (int id_idx = 0; id_idx < real_ids.length; id_idx++)
+ // {
+ // logger_.debug("Set BKU id:" + real_ids[id_idx]);
+ // }
+ // }
+ // return real_ids;
+ }
+
+ // TODO hotfix
+ public static String[] parseSigIds(String sig_ids)
+ {
if (sig_ids == null || sig_ids.length() == 0)
{
return null;
@@ -858,21 +961,33 @@ public class SignatureObject implements Serializable
// }
String[] ids_str = sig_ids.split("@");
+
+ String etsi_string = null;
+ if (ids_str.length == 3)
+ {
+ etsi_string = ids_str[0];
+ String[] rest_ids = new String[] { ids_str[1], ids_str[2] };
+ ids_str = rest_ids;
+ }
+
String base = ids_str[0];
String[] ids = ids_str[1].split("-");
- String[] real_ids = new String[5];
+ String[] real_ids = new String[6]; // the last one contains the etsi string
real_ids[0] = base + "-" + ids[0];
real_ids[1] = "0-" + base + "-" + ids[1];
real_ids[2] = "0-" + base + "-" + ids[2];
real_ids[3] = "0-" + base + "-" + ids[3];
real_ids[4] = "0-" + base + "-" + ids[4];
+ real_ids[5] = etsi_string;
+
if (logger_.isDebugEnabled())
{
for (int id_idx = 0; id_idx < real_ids.length; id_idx++)
{
- logger_.debug("Set BKU id:" + real_ids[id_idx]);
+ logger_.debug("real_ids[" + id_idx + "] = " + real_ids[id_idx]);
}
}
+
return real_ids;
}
@@ -1364,6 +1479,12 @@ public class SignatureObject implements Serializable
}
SignatureTypes sig_types = SignatureTypes.getInstance();
signatureDefinition_ = sig_types.getSignatureTypeDefinition(sigType_);
+ if (signatureDefinition_ == null)
+ {
+ final String msg = "The SignatureObject's sigType '" + sigType_ + "' wasn't found in the configuration file's specified signature profiles. This usually happens if the sig_obj.type.default object has been turned off or is misspelled.";
+ logger_.error(msg);
+ throw new SignatureTypesException(msg);
+ }
Map key_cap_map = signatureDefinition_.getKeyCaptionMap();
if (key_cap_map != null)
{
@@ -1409,10 +1530,10 @@ public class SignatureObject implements Serializable
}
}
// value = new String(CodingHelper.encodeUTF8(value));
-// if (logger_.isDebugEnabled())
-// {
-// logger_.debug("key:" + key + " value:" + value);
-// }
+ // if (logger_.isDebugEnabled())
+ // {
+ // logger_.debug("key:" + key + " value:" + value);
+ // }
setSigValue(key, value);
}
}
@@ -1534,6 +1655,4 @@ public class SignatureObject implements Serializable
return strg;
}
-
-
} \ No newline at end of file