aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/knowcenter/wag/egov/egiz/sig
diff options
context:
space:
mode:
authornetconomy <netconomy@7b5415b0-85f9-ee4d-85bd-d5d0c3b42d1c>2007-08-17 06:10:56 +0000
committernetconomy <netconomy@7b5415b0-85f9-ee4d-85bd-d5d0c3b42d1c>2007-08-17 06:10:56 +0000
commit3d982813b34f6f230baf4a467cdc37ec92a77595 (patch)
tree85319d39cee2ded1bb7a2b2dd9e8ea37e3778248 /src/main/java/at/knowcenter/wag/egov/egiz/sig
parent07f6c8f33b2d700276fe6ec6339ff836c8710131 (diff)
downloadpdf-as-3-3d982813b34f6f230baf4a467cdc37ec92a77595.tar.gz
pdf-as-3-3d982813b34f6f230baf4a467cdc37ec92a77595.tar.bz2
pdf-as-3-3d982813b34f6f230baf4a467cdc37ec92a77595.zip
Performance
git-svn-id: https://joinup.ec.europa.eu/svn/pdf-as/trunk@167 7b5415b0-85f9-ee4d-85bd-d5d0c3b42d1c
Diffstat (limited to 'src/main/java/at/knowcenter/wag/egov/egiz/sig')
-rw-r--r--src/main/java/at/knowcenter/wag/egov/egiz/sig/ConnectorFactory.java2
-rw-r--r--src/main/java/at/knowcenter/wag/egov/egiz/sig/LocalConnector.java6
-rw-r--r--src/main/java/at/knowcenter/wag/egov/egiz/sig/SignatureData.java10
-rw-r--r--src/main/java/at/knowcenter/wag/egov/egiz/sig/SignatureDataImpl.java55
-rw-r--r--src/main/java/at/knowcenter/wag/egov/egiz/sig/SignatureObject.java8
-rw-r--r--src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/BKUConnector.java35
-rw-r--r--src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/BKUPostConnection.java4
-rw-r--r--src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/ConnectorChooser.java154
-rw-r--r--src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/MOAConnector.java18
-rw-r--r--src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/bku/BKUHelper.java21
-rw-r--r--src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/bku/BKUPostConnection.java27
-rw-r--r--src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/bku/DetachedBKUConnector.java15
-rw-r--r--src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/bku/EnvelopedBase64BKUConnector.java8
-rw-r--r--src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/bku/OldEnvelopingBase64BKUConnector.java6
-rw-r--r--src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/moa/DetachedLocRefMOAConnector.java69
-rw-r--r--src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/moa/EnvelopingBase64MOAConnector.java7
-rw-r--r--src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/moa/MOASoapConnection.java2
-rw-r--r--src/main/java/at/knowcenter/wag/egov/egiz/sig/sigid/DetachedLocRefMOAIdFormatter.java1
18 files changed, 234 insertions, 214 deletions
diff --git a/src/main/java/at/knowcenter/wag/egov/egiz/sig/ConnectorFactory.java b/src/main/java/at/knowcenter/wag/egov/egiz/sig/ConnectorFactory.java
index 690a913..9d744e1 100644
--- a/src/main/java/at/knowcenter/wag/egov/egiz/sig/ConnectorFactory.java
+++ b/src/main/java/at/knowcenter/wag/egov/egiz/sig/ConnectorFactory.java
@@ -34,6 +34,8 @@ import at.knowcenter.wag.egov.egiz.sig.connectors.MOAConnector;
* This is a factory for creating the appropriate connector according to the
* connector identifier.
*
+ * @deprecated this code is far too complicated
+ *
* @see at.knowcenter.wag.egov.egiz.sig.ConnectorInformation
* @author wprinz
*/
diff --git a/src/main/java/at/knowcenter/wag/egov/egiz/sig/LocalConnector.java b/src/main/java/at/knowcenter/wag/egov/egiz/sig/LocalConnector.java
index 65c79a9..3b647a0 100644
--- a/src/main/java/at/knowcenter/wag/egov/egiz/sig/LocalConnector.java
+++ b/src/main/java/at/knowcenter/wag/egov/egiz/sig/LocalConnector.java
@@ -39,6 +39,8 @@ import at.knowcenter.wag.egov.egiz.exceptions.SignatureException;
* whereas the connection to the local service is made from the local client.
* </p>
*
+ * @deprecated use the new connectory instead
+ *
* @author wprinz
*/
public interface LocalConnector extends Connector
@@ -82,7 +84,7 @@ public interface LocalConnector extends Connector
* @throws SignatureException
* F.e.
*/
- // TODO hotfix
+ // TODO hotfix - already deprecated
public SignatureObject analyzeSignResponse(Properties response_properties,
String signature_type) throws SignatureException;
@@ -93,7 +95,7 @@ public interface LocalConnector extends Connector
* @throws SignatureException
* F.e.
*/
- // TODO hotfix
+ // TODO hotfix - already deprecated
public SignatureResponse analyzeVerifyResponse(Properties response_properties) throws SignatureException;
/**
diff --git a/src/main/java/at/knowcenter/wag/egov/egiz/sig/SignatureData.java b/src/main/java/at/knowcenter/wag/egov/egiz/sig/SignatureData.java
index 015831e..8c9ab12 100644
--- a/src/main/java/at/knowcenter/wag/egov/egiz/sig/SignatureData.java
+++ b/src/main/java/at/knowcenter/wag/egov/egiz/sig/SignatureData.java
@@ -3,6 +3,8 @@
*/
package at.knowcenter.wag.egov.egiz.sig;
+import at.gv.egiz.pdfas.framework.input.DataSource;
+
/**
* This encapsuilates the content data to be signed or verified.
*
@@ -20,14 +22,12 @@ package at.knowcenter.wag.egov.egiz.sig;
*/
public interface SignatureData
{
-
- // TODO Performance: make this to an InputStream
/**
- * Returns the data to be signed or verified.
+ * Returns the DataSource that provides the data for this SignatureData.
*
- * @return Returns the data to be signed or verified.
+ * @return Returns the DataSource.
*/
- public byte[] getData();
+ public DataSource getDataSource();
/**
* Returns the mime type of the data.
diff --git a/src/main/java/at/knowcenter/wag/egov/egiz/sig/SignatureDataImpl.java b/src/main/java/at/knowcenter/wag/egov/egiz/sig/SignatureDataImpl.java
index 5b9304d..320c511 100644
--- a/src/main/java/at/knowcenter/wag/egov/egiz/sig/SignatureDataImpl.java
+++ b/src/main/java/at/knowcenter/wag/egov/egiz/sig/SignatureDataImpl.java
@@ -5,6 +5,8 @@ package at.knowcenter.wag.egov.egiz.sig;
import java.io.Serializable;
+import at.gv.egiz.pdfas.framework.input.DataSource;
+
/**
* Generic implementation of the SignatureData interface for being used by
* signators and verificators.
@@ -21,8 +23,8 @@ public class SignatureDataImpl implements SignatureData, Serializable
/**
* The signature data.
*/
- protected byte[] data = null;
-
+ protected DataSource data = null;
+
/**
* The mime type of the data.
*/
@@ -46,43 +48,50 @@ public class SignatureDataImpl implements SignatureData, Serializable
* @param mime_type
* The mime type of the data.
*/
- public SignatureDataImpl(byte[] data, String mime_type)
+ public SignatureDataImpl(DataSource data, String mime_type)
{
this.data = data;
this.mimeType = mime_type;
this.characterEncoding = null;
}
- /**
- * Constructor that fills the SignatureData.
- *
- * <p>
- * Use this constructor for textual data as it allows to provide the character
- * encoding.
- * </p>
- *
- * @param data
- * The signature data.
- * @param mime_type
- * The mime type of the data.
- * @param character_encoding
- * The character encoding of the data if appropriate, or null if not.
- */
- public SignatureDataImpl(byte[] data, String mime_type, String character_encoding)
+// /**
+// * Constructor that fills the SignatureData.
+// *
+// * <p>
+// * Use this constructor for textual data as it allows to provide the character
+// * encoding.
+// * </p>
+// *
+// * @param data
+// * The signature data.
+// * @param mime_type
+// * The mime type of the data.
+// * @param character_encoding
+// * The character encoding of the data if appropriate, or null if not.
+// */
+// public SignatureDataImpl(byte[] data, String mime_type, String character_encoding)
+// {
+// this.data = data;
+// this.mimeType = mime_type;
+// this.characterEncoding = character_encoding;
+// }
+ public SignatureDataImpl(DataSource data, String mime_type, String character_encoding)
{
this.data = data;
this.mimeType = mime_type;
this.characterEncoding = character_encoding;
}
-
+
/**
- * @see at.knowcenter.wag.egov.egiz.sig.SignatureData#getData()
+ * @see at.knowcenter.wag.egov.egiz.sig.SignatureData#getDataSource()
*/
- public byte[] getData()
+ public DataSource getDataSource()
{
return this.data;
}
-
+
+
/**
* @see at.knowcenter.wag.egov.egiz.sig.SignatureData#getMimeType()
*/
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 a48893c..52c986a 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
@@ -252,9 +252,7 @@ public class SignatureObject implements Serializable
{
String log_message = "Can not load pdf signature settings. Cause:\n" + e.getMessage();
logger_.error(log_message);
- SignatureException se = new SignatureException(101, log_message, e);
- se.setErrorCode(101);
- throw se;
+ throw new SignatureException(101, log_message, e);
}
}
// pTree_ = settings_.getPTree();
@@ -829,7 +827,7 @@ public class SignatureObject implements Serializable
public static boolean decideNewEtsiByBKUVersion(String productVersion)
{
boolean new_etsi = true;
- // TODO make better
+ // TODO hotfix
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;
@@ -1540,7 +1538,7 @@ public class SignatureObject implements Serializable
}
catch (NormalizeException e)
{
- throw new SignatureTypesException("Can not set normalizer Version:" + value);
+ throw new SignatureTypesException(e);
}
}
// value = new String(CodingHelper.encodeUTF8(value));
diff --git a/src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/BKUConnector.java b/src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/BKUConnector.java
index d6301a9..75e4c31 100644
--- a/src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/BKUConnector.java
+++ b/src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/BKUConnector.java
@@ -22,6 +22,8 @@ import java.util.Properties;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
+import at.gv.egiz.pdfas.exceptions.external.ExternalErrorException;
+
import org.apache.log4j.Level;
import org.apache.log4j.Logger;
@@ -41,6 +43,8 @@ import at.knowcenter.wag.egov.egiz.tools.FileHelper;
/**
* Connector for communicating with BKU.
*
+ * @deprecated use the new connectors.
+ *
* @author wlackner
* @author wprinz
*/
@@ -270,7 +274,7 @@ public class BKUConnector implements LocalConnector
ids[3] = extractId(xmlResponse, "etsi-data-reference-");
ids[4] = extractId(xmlResponse, "etsi-data-object-");
- //TODO hotfix
+ //TODO hotfix - already deprecated
String final_ids =SignatureObject.formatSigIds(response_properties, ids);
//sigObj.setSignationIDs(ids);
sigObj.setSignationIDs(final_ids);
@@ -291,11 +295,11 @@ public class BKUConnector implements LocalConnector
int start_idx = text.indexOf(name) + name.length();
int end_idx = text.indexOf("\"", start_idx);
- // TODO hotfix!
+ // TODO hotfix! - already deprecated
final int quot_end_idx = end_idx;
final int squot_end_idx = text.indexOf("'", start_idx);
end_idx = Math.min(quot_end_idx, squot_end_idx);
- // TODO hotfix end!
+ // TODO hotfix end! - already deprecated
id = text.substring(start_idx, end_idx);
if (logger_.isDebugEnabled())
@@ -342,7 +346,7 @@ public class BKUConnector implements LocalConnector
logger_.debug("ids_string = " + ids_string);
String[] ids = SignatureObject.parseSigIds(ids_string);
- // TODO hotfix
+ // TODO hotfix - already deprecated
final boolean neue_bku = ids[5] != null;
logger_.debug("ids[5] = " + ids[5]);
logger_.debug("neue_bku = " + neue_bku);
@@ -391,7 +395,7 @@ public class BKUConnector implements LocalConnector
ver_temp_str = ver_temp_str.replaceFirst("TemplateQualifyingPropertiesReplace", sig_prop_str);
byte[] sig_prop_code = CodingHelper.buildDigest(sig_prop_str.getBytes("UTF-8"));
- // TODO hotfix
+ // TODO hotfix - already deprecated
if (neue_bku)
{
final String ETSI_SIGNED_PROPERTIES_START_TAG = "<etsi:SignedProperties"; // xml name spaces follow, so this is not a complete tag...
@@ -697,7 +701,7 @@ public class BKUConnector implements LocalConnector
{
//String sign_request_filename = getSignRequestTemplateFileName(sigType);
- // TODO hotfix
+ // TODO hotfix - already deprecated
String response_string = response_properties.getProperty("response_string");
SignatureObject sig_obj = new SignatureObject();
@@ -736,15 +740,13 @@ public class BKUConnector implements LocalConnector
Pattern erm_p_e = Pattern.compile("</[\\w]*:?Info>");
Matcher erm_m_s = erm_p_s.matcher(response_string);
Matcher erm_m_e = erm_p_e.matcher(response_string);
- SignatureException se = new SignatureException(0, "BKUSigExc");
String error_code = response_string.substring(erc_m_s.end(), erc_m_e.start());
- se.setExternalErrorCode(error_code);
+ String error_mess = null;
if (erm_m_s.find() && erm_m_e.find())
{
- String error_mess = response_string.substring(erm_m_s.end(), erm_m_e.start());
- se.setExternalErrorMessage(error_mess);
+ error_mess = response_string.substring(erm_m_s.end(), erm_m_e.start());
}
- throw se;
+ throw new SignatureException(new ExternalErrorException(error_code, error_mess));
}
else
{
@@ -781,18 +783,17 @@ public class BKUConnector implements LocalConnector
Pattern erm_p_e = Pattern.compile("</[\\w]*:?Info>");
Matcher erm_m_s = erm_p_s.matcher(response_string);
Matcher erm_m_e = erm_p_e.matcher(response_string);
- SignatureException se = new SignatureException(0, "BKUSigExc");
+ String error_code = null;
if (erc_m_s.find() && erc_m_e.find())
{
- String error_code = response_string.substring(erc_m_s.end(), erc_m_e.start());
- se.setExternalErrorCode(error_code);
+ error_code = response_string.substring(erc_m_s.end(), erc_m_e.start());
}
+ String error_mess = null;
if (erm_m_s.find() && erm_m_e.find())
{
- String error_mess = response_string.substring(erm_m_s.end(), erm_m_e.start());
- se.setExternalErrorMessage(error_mess);
+ error_mess = response_string.substring(erm_m_s.end(), erm_m_e.start());
}
- throw se;
+ throw new SignatureException(new ExternalErrorException(error_code, error_mess));
}
else
{
diff --git a/src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/BKUPostConnection.java b/src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/BKUPostConnection.java
index 1ddef5f..a1ebe31 100644
--- a/src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/BKUPostConnection.java
+++ b/src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/BKUPostConnection.java
@@ -118,7 +118,9 @@ public abstract class BKUPostConnection
// TODO hotfix
public static void parseBKUVersion(String header_value, Properties properties)
{
- Pattern pattern = Pattern.compile("^citizen-card-environment/(\\d+\\.\\d+) (.+)/(\\d+\\.\\d+\\.\\d+)$");
+ // dummy bku header starts with Apache Coyote...
+ //Pattern pattern = Pattern.compile("^citizen-card-environment/(\\d+\\.\\d+) (.+)/(\\d+\\.\\d+\\.\\d+)$");
+ Pattern pattern = Pattern.compile("^.*citizen-card-environment/(\\d+\\.\\d+) (.+)/(\\d+\\.\\d+\\.\\d+)$");
Matcher m = pattern.matcher(header_value);
m.matches();
diff --git a/src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/ConnectorChooser.java b/src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/ConnectorChooser.java
index 4dcd1b5..dd22b1d 100644
--- a/src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/ConnectorChooser.java
+++ b/src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/ConnectorChooser.java
@@ -21,6 +21,8 @@ import at.knowcenter.wag.egov.egiz.sig.sigid.HotfixIdFormatter;
* Helper class that provides static methods that help the application to
* "choose" the right connector for a given task.
*
+ * @deprecated functionality split to ConnectorChooser implementations in framework commandline and web
+ *
* @author wprinz
*/
public final class ConnectorChooser
@@ -62,28 +64,28 @@ public final class ConnectorChooser
return new DetachedLocRefMOAConnector(profile, loc_ref_url);
}
- public static Connector chooseCommandlineConnectorForSign(String connector,
- String profile) throws ConnectorException
- {
- log.debug("Choosing Connector for commandline signation...");
-
- log.debug("connector type = " + connector);
-
- if (connector.equals(BKU))
- {
- log.debug("sig_app is BKU ==> MultipartDetachedBKUConnector"); //$NON-NLS-1$
-
- return new MultipartDetachedBKUConnector(profile);
- }
- if (connector.equals(MOA))
- {
- // TODO MOA detached signing is not allowed at the commandline
- log.warn("Detached MOA is not supported on the commandline. -> choosing Base64 temporarily.");
- return new EnvelopingBase64MOAConnector(profile);
- }
-
- throw new ConnectorException(300, "Unknown connector type '" + connector + "' specified.");
- }
+// public static Connector chooseCommandlineConnectorForSign(String connector,
+// String profile) throws ConnectorException
+// {
+// log.debug("Choosing Connector for commandline signation...");
+//
+// log.debug("connector type = " + connector);
+//
+// if (connector.equals(BKU))
+// {
+// log.debug("sig_app is BKU ==> MultipartDetachedBKUConnector"); //$NON-NLS-1$
+//
+// return new MultipartDetachedBKUConnector(profile);
+// }
+// if (connector.equals(MOA))
+// {
+// // TODO MOA detached signing is not allowed at the commandline
+// log.warn("Detached MOA is not supported on the commandline. -> choosing Base64 temporarily.");
+// return new EnvelopingBase64MOAConnector(profile);
+// }
+//
+// throw new ConnectorException(300, "Unknown connector type '" + connector + "' specified.");
+// }
public static LocalConnector chooseLocalConnectorForVerify(String connector,
PdfASID sig_kz, String sig_id, String profile, String loc_ref_url) throws ConnectorException
@@ -177,60 +179,60 @@ public final class ConnectorChooser
throw new ConnectorException(310, "The SIG_KZ version '" + sig_kz.getVersion() + "' is unknown.");
}
- public static Connector chooseCommandlineConnectorForVerify(String connector,
- PdfASID sig_kz, String sig_id, String profile) throws ConnectorException
- {
- log.debug("Choosing Connector for Commandline verification...");
-
- log.debug("connector type = " + connector);
- log.debug("sig_kz = " + sig_kz); //$NON-NLS-1$
- log.debug("sig_id = " + sig_id); //$NON-NLS-1$
-
- if (sig_kz == null)
- {
- log.debug("sig_kz is null -> chose an old enveloped base64 connector"); //$NON-NLS-1$
-
- return chooseEnvelopedBase64ConnectorOld(profile, connector);
- }
-
- log.debug("sig_kz is not null -> one of the newer signatures");
-
- if (sig_kz.getVersion().equals(SignatorFactory.VERSION_1_0_0))
- {
- log.debug("Version is 1.0.0 -> Base64 Signatur (old or Hotfix).");
-
- if (sig_id == null)
- {
- log.debug("sig_id is null, which means that it is a MOA signature -> choose a hotfix base64 connector (thus it is moa - it doesn't matter).");
-
- return chooseEnvelopedBase64ConnectorHotfix(profile, connector);
- }
-
- String[] sig_id_parts = sig_id.split("@");
- if (sig_id_parts.length == 2)
- {
- log.debug("sig_id has 2 @-separated parts -> choosing old base64 connector");
-
- return chooseEnvelopedBase64ConnectorOld(profile, connector);
- }
- if (sig_id_parts[0].equals(HotfixIdFormatter.SIG_ID_PREFIX))
- {
- log.debug("sig_id prefix is hotfix -> choosing hotfix base64 connector");
-
- return chooseEnvelopedBase64ConnectorHotfix(profile, connector);
- }
-
- throw new ConnectorException(300, "The SIG_KZ version is 1.0.0, but SIG_ID is neither MOA nor Old base64 nor Hotfix base64 ???'");
- }
- if (sig_kz.getVersion().equals(SignatorFactory.VERSION_1_1_0))
- {
- log.debug("Version is 1.1.0 -> chose a detached connector.");
-
- return chooseDetachedMultipartConnector(profile, connector);
- }
-
- throw new ConnectorException(310, "The SIG_KZ version '" + sig_kz.getVersion() + "' is unknown.");
- }
+// public static Connector chooseCommandlineConnectorForVerify(String connector,
+// PdfASID sig_kz, String sig_id, String profile) throws ConnectorException
+// {
+// log.debug("Choosing Connector for Commandline verification...");
+//
+// log.debug("connector type = " + connector);
+// log.debug("sig_kz = " + sig_kz); //$NON-NLS-1$
+// log.debug("sig_id = " + sig_id); //$NON-NLS-1$
+//
+// if (sig_kz == null)
+// {
+// log.debug("sig_kz is null -> chose an old enveloped base64 connector"); //$NON-NLS-1$
+//
+// return chooseEnvelopedBase64ConnectorOld(profile, connector);
+// }
+//
+// log.debug("sig_kz is not null -> one of the newer signatures");
+//
+// if (sig_kz.getVersion().equals(SignatorFactory.VERSION_1_0_0))
+// {
+// log.debug("Version is 1.0.0 -> Base64 Signatur (old or Hotfix).");
+//
+// if (sig_id == null)
+// {
+// log.debug("sig_id is null, which means that it is a MOA signature -> choose a hotfix base64 connector (thus it is moa - it doesn't matter).");
+//
+// return chooseEnvelopedBase64ConnectorHotfix(profile, connector);
+// }
+//
+// String[] sig_id_parts = sig_id.split("@");
+// if (sig_id_parts.length == 2)
+// {
+// log.debug("sig_id has 2 @-separated parts -> choosing old base64 connector");
+//
+// return chooseEnvelopedBase64ConnectorOld(profile, connector);
+// }
+// if (sig_id_parts[0].equals(HotfixIdFormatter.SIG_ID_PREFIX))
+// {
+// log.debug("sig_id prefix is hotfix -> choosing hotfix base64 connector");
+//
+// return chooseEnvelopedBase64ConnectorHotfix(profile, connector);
+// }
+//
+// throw new ConnectorException(300, "The SIG_KZ version is 1.0.0, but SIG_ID is neither MOA nor Old base64 nor Hotfix base64 ???'");
+// }
+// if (sig_kz.getVersion().equals(SignatorFactory.VERSION_1_1_0))
+// {
+// log.debug("Version is 1.1.0 -> chose a detached connector.");
+//
+// return chooseDetachedMultipartConnector(profile, connector);
+// }
+//
+// throw new ConnectorException(310, "The SIG_KZ version '" + sig_kz.getVersion() + "' is unknown.");
+// }
protected static final String BKU = "bku"; //$NON-NLS-1$
diff --git a/src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/MOAConnector.java b/src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/MOAConnector.java
index 3c53b54..4dd3d5e 100644
--- a/src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/MOAConnector.java
+++ b/src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/MOAConnector.java
@@ -31,6 +31,8 @@ import javax.xml.rpc.Call;
import javax.xml.rpc.Service;
import javax.xml.rpc.ServiceFactory;
+import at.gv.egiz.pdfas.exceptions.external.ExternalErrorException;
+
import org.apache.axis.message.SOAPBodyElement;
import org.apache.log4j.Level;
import org.apache.log4j.Logger;
@@ -55,6 +57,7 @@ import at.knowcenter.wag.egov.egiz.tools.FileHelper;
/**
* Connector to access the MOA service.
*
+ * @deprecated
* @author wlackner
* @author wprinz
*/
@@ -252,10 +255,7 @@ public class MOAConnector implements Connector
error_mess = response_string.substring(erm_m_s.end(), erm_m_e.start());
logger_.debug(error_mess);
}
- SignatureException se = new SignatureException(0, "MOASigExc ext error code = " + error_code + ", err_mess = " + error_mess);
- se.setExternalErrorCode(error_code);
- se.setExternalErrorMessage(error_mess);
- throw se;
+ throw new SignatureException(new ExternalErrorException(error_code, error_mess));
}
else
{
@@ -581,15 +581,13 @@ public class MOAConnector implements Connector
Pattern erm_p_e = Pattern.compile("</[\\w]*:?Info>");
Matcher erm_m_s = erm_p_s.matcher(response_string);
Matcher erm_m_e = erm_p_e.matcher(response_string);
- SignatureException se = new SignatureException(0, "MOASigExc2");
String error_code = response_string.substring(erc_m_s.end(), erc_m_e.start());
- se.setExternalErrorCode(error_code);
+ String error_mess = null;
if (erm_m_s.find() && erm_m_e.find())
{
- String error_mess = response_string.substring(erm_m_s.end(), erm_m_e.start());
- se.setExternalErrorMessage(error_mess);
+ error_mess = response_string.substring(erm_m_s.end(), erm_m_e.start());
}
- throw se;
+ throw new SignatureException(new ExternalErrorException(error_code, error_mess));
}
else
{
@@ -868,7 +866,7 @@ public class MOAConnector implements Connector
}
catch (Exception e)
{
- throw new WebException(330, e);
+ throw new WebException(e);
}
// serialize signature only
diff --git a/src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/bku/BKUHelper.java b/src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/bku/BKUHelper.java
index c05c688..5e3033e 100644
--- a/src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/bku/BKUHelper.java
+++ b/src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/bku/BKUHelper.java
@@ -2,6 +2,7 @@ package at.knowcenter.wag.egov.egiz.sig.connectors.bku;
import java.io.ByteArrayInputStream;
import java.io.IOException;
+import java.io.InputStream;
import java.io.UnsupportedEncodingException;
import java.security.cert.CertificateException;
import java.security.cert.CertificateFactory;
@@ -9,6 +10,9 @@ import java.security.cert.X509Certificate;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
+import at.gv.egiz.pdfas.exceptions.external.ExternalErrorException;
+import at.gv.egiz.pdfas.impl.input.helper.DataSourceHelper;
+
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -47,7 +51,10 @@ public final class BKUHelper
*/
public static String prepareBase64Content(SignatureData data)
{
- String base64 = CodingHelper.encodeBase64(data.getData());
+ // PERF: base64 encoding needs byte array
+ byte [] d = DataSourceHelper.convertDataSourceToByteArray(data.getDataSource());
+
+ String base64 = CodingHelper.encodeBase64(d);
if (data.getMimeType().equals("application/pdf")) //$NON-NLS-1$
{
log.debug("The data is application/pdf - so the binary data is Base64 encoded."); //$NON-NLS-1$
@@ -69,7 +76,9 @@ public final class BKUHelper
*/
public static byte[] prepareEnvelopingData(SignatureData data)
{
- byte[] enc = data.getData();
+ // PERF: prepareEnvelopingData needs byte array
+ byte[] enc = DataSourceHelper.convertDataSourceToByteArray(data.getDataSource());
+
if (data.getMimeType().equals("application/pdf")) //$NON-NLS-1$
{
log.debug("The data is application/pdf - so the binary data is Base64 encoded."); //$NON-NLS-1$
@@ -111,15 +120,13 @@ public final class BKUHelper
Pattern erm_p_e = Pattern.compile("</[\\w]*:?Info>"); //$NON-NLS-1$
Matcher erm_m_s = erm_p_s.matcher(response_string);
Matcher erm_m_e = erm_p_e.matcher(response_string);
- ConnectorException se = new ConnectorException(0, "BKUSigExc"); //$NON-NLS-1$
String error_code = response_string.substring(erc_m_s.end(), erc_m_e.start());
- se.setExternalErrorCode(error_code);
+ String error_mess = null;
if (erm_m_s.find() && erm_m_e.find())
{
- String error_mess = response_string.substring(erm_m_s.end(), erm_m_e.start());
- se.setExternalErrorMessage(error_mess);
+ error_mess = response_string.substring(erm_m_s.end(), erm_m_e.start());
}
- throw se;
+ throw new ExternalErrorException(error_code, error_mess);
}
}
diff --git a/src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/bku/BKUPostConnection.java b/src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/bku/BKUPostConnection.java
index 321287d..02013a5 100644
--- a/src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/bku/BKUPostConnection.java
+++ b/src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/bku/BKUPostConnection.java
@@ -4,16 +4,17 @@
package at.knowcenter.wag.egov.egiz.sig.connectors.bku;
import java.io.IOException;
+import java.io.InputStream;
import java.util.Properties;
import org.apache.commons.httpclient.Header;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.HttpException;
import org.apache.commons.httpclient.methods.PostMethod;
-import org.apache.commons.httpclient.methods.multipart.ByteArrayPartSource;
import org.apache.commons.httpclient.methods.multipart.FilePart;
import org.apache.commons.httpclient.methods.multipart.MultipartRequestEntity;
import org.apache.commons.httpclient.methods.multipart.Part;
+import org.apache.commons.httpclient.methods.multipart.PartSource;
import org.apache.commons.httpclient.methods.multipart.StringPart;
import org.apache.commons.httpclient.params.HttpMethodParams;
import org.apache.commons.logging.Log;
@@ -55,7 +56,7 @@ public final class BKUPostConnection
* @throws IOException
*/
public static Properties doPostRequestMultipart(String url, String request,
- SignatureData data) throws HttpException, IOException
+ final SignatureData data) throws HttpException, IOException
{
log.debug("doPostRequestMultipart:"); //$NON-NLS-1$
@@ -68,9 +69,25 @@ public final class BKUPostConnection
// xmlpart.setContentType("text/xml");
// xmlpart.setTransferEncoding(null);
- String filename = data.getMimeType().equals("application/pdf") ? "myfile.pdf" : "myfile.txt"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- ByteArrayPartSource baps = new ByteArrayPartSource(filename, data.getData());
- FilePart filepart = new FilePart("fileupload", baps); //$NON-NLS-1$
+ final String filename = data.getMimeType().equals("application/pdf") ? "myfile.pdf" : "myfile.txt"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ PartSource ps = new PartSource() {
+ public InputStream createInputStream() throws IOException
+ {
+ return data.getDataSource().createInputStream();
+ }
+
+ public String getFileName()
+ {
+ return filename;
+ }
+
+ public long getLength()
+ {
+ return data.getDataSource().getLength();
+ }
+ };
+ //ByteArrayPartSource baps = new ByteArrayPartSource(filename, data.getData());
+ FilePart filepart = new FilePart("fileupload", ps); //$NON-NLS-1$
filepart.setContentType(data.getMimeType());
// this is optional
// filepart.setCharSet(data.getCharacterEncoding());
diff --git a/src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/bku/DetachedBKUConnector.java b/src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/bku/DetachedBKUConnector.java
index 410c46e..c84ce8a 100644
--- a/src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/bku/DetachedBKUConnector.java
+++ b/src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/bku/DetachedBKUConnector.java
@@ -10,6 +10,7 @@ import java.util.Properties;
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.cfg.SettingsReader;
import at.knowcenter.wag.egov.egiz.exceptions.ConnectorException;
import at.knowcenter.wag.egov.egiz.exceptions.SettingsException;
@@ -231,7 +232,6 @@ public class DetachedBKUConnector implements Connector, LocalConnector
SignSignatureObject sso = analyzeSignResponse(response_properties);
- // TODO this could be made more generic
sso.response_properties = response_properties;
log.debug("doSign finished."); //$NON-NLS-1$
@@ -256,7 +256,7 @@ public class DetachedBKUConnector implements Connector, LocalConnector
String verify_request_xml = prepareVerifyRequest(data, so);
log.debug("verify_request_xml = " + verify_request_xml); //$NON-NLS-1$
- // TODO debug
+ // TODO debug - remove
// try
// {
// FileOutputStream fos = new
@@ -351,8 +351,9 @@ public class DetachedBKUConnector implements Connector, LocalConnector
// data digest replace
{
- byte[] data_value = data.getData();
- byte[] data_value_hash = CodingHelper.buildDigest(data_value);
+// byte[] data_value = data.getData();
+// byte[] data_value_hash = CodingHelper.buildDigest(data_value);
+ byte[] data_value_hash = CodingHelper.buildDigest(data.getDataSource());
String object_data_hash = CodingHelper.encodeBase64(data_value_hash);
verify_xml = verify_xml.replaceFirst(TemplateReplaces.DIGEST_VALUE_SIGNED_DATA_REPLACE, object_data_hash);
@@ -583,8 +584,7 @@ public class DetachedBKUConnector implements Connector, LocalConnector
if (this.verify_request_template == null)
{
- // TODO make this a settings exception
- throw new ConnectorException(300, "Can not read the verify xml request template"); //$NON-NLS-1$
+ throw new ConnectorException(ErrorCode.SETTING_NOT_FOUND, "Can not read the verify xml request template"); //$NON-NLS-1$
}
// load template key file
@@ -599,8 +599,7 @@ public class DetachedBKUConnector implements Connector, LocalConnector
if (this.verify_template == null)
{
- // TODO make this a settings exception
- throw new ConnectorException(300, "Can not read the verify template"); //$NON-NLS-1$
+ throw new ConnectorException(ErrorCode.SETTING_NOT_FOUND, "Can not read the verify template"); //$NON-NLS-1$
}
this.verify_url = getConnectorValueFromProfile(settings, profile, VERIFY_URL_KEY);
diff --git a/src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/bku/EnvelopedBase64BKUConnector.java b/src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/bku/EnvelopedBase64BKUConnector.java
index 4983da7..82ec9bd 100644
--- a/src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/bku/EnvelopedBase64BKUConnector.java
+++ b/src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/bku/EnvelopedBase64BKUConnector.java
@@ -10,6 +10,7 @@ import java.util.Properties;
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.cfg.SettingsReader;
import at.knowcenter.wag.egov.egiz.exceptions.ConnectorException;
import at.knowcenter.wag.egov.egiz.exceptions.SettingsException;
@@ -83,7 +84,6 @@ public class EnvelopedBase64BKUConnector implements Connector, LocalConnector
// DebugHelper.debugStringToFile(response_properties.getProperty(BKUPostConnection.RESPONSE_STRING_KEY), "BKU_EnvB64_sign_response.xml"); //$NON-NLS-1$
SignSignatureObject sso = analyzeSignResponse(response_properties);
- // TODO this could be made more generic
sso.response_properties = response_properties;
log.debug("doSign finished."); //$NON-NLS-1$
@@ -487,16 +487,14 @@ public class EnvelopedBase64BKUConnector implements Connector, LocalConnector
this.verify_request_template = FileHelper.readFromFile(SettingsReader.relocateFile(verify_request_filename));
if (this.verify_request_template == null)
{
- // TODO make this a settings exception
- throw new ConnectorException(300, "Can not read the verify xml request template"); //$NON-NLS-1$
+ throw new ConnectorException(ErrorCode.SETTING_NOT_FOUND, "Can not read the verify xml request template"); //$NON-NLS-1$
}
String verify_filename = getConnectorValueFromProfile(settings, profile, VERIFY_TEMPLATE_KEY);
this.verify_template = FileHelper.readFromFile(SettingsReader.relocateFile(verify_filename));
if (this.verify_template == null)
{
- // TODO make this a settings exception
- throw new ConnectorException(300, "Can not read the verify template"); //$NON-NLS-1$
+ throw new ConnectorException(ErrorCode.SETTING_NOT_FOUND, "Can not read the verify template"); //$NON-NLS-1$
}
this.verify_url = getConnectorValueFromProfile(settings, profile, VERIFY_URL_KEY);
diff --git a/src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/bku/OldEnvelopingBase64BKUConnector.java b/src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/bku/OldEnvelopingBase64BKUConnector.java
index d1fffb1..586879a 100644
--- a/src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/bku/OldEnvelopingBase64BKUConnector.java
+++ b/src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/bku/OldEnvelopingBase64BKUConnector.java
@@ -8,6 +8,7 @@ import java.io.UnsupportedEncodingException;
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.cfg.SettingsReader;
import at.knowcenter.wag.egov.egiz.exceptions.ConnectorException;
import at.knowcenter.wag.egov.egiz.exceptions.SettingsException;
@@ -95,15 +96,14 @@ public class OldEnvelopingBase64BKUConnector extends EnvelopedBase64BKUConnector
}
catch (SettingsException e)
{
- throw new ConnectorException(300, e);
+ throw new ConnectorException(ErrorCode.SETTING_NOT_FOUND, e);
}
String verify_filename = getConnectorValueFromProfile(settings, profile, VERIFY_TEMPLATE_KEY);
this.verify_template = FileHelper.readFromFile(SettingsReader.relocateFile(verify_filename));
if (this.verify_template == null)
{
- // TODO make this a settings exception
- throw new ConnectorException(300, "Can not read the verify template"); //$NON-NLS-1$
+ throw new ConnectorException(ErrorCode.SETTING_NOT_FOUND, "Can not read the verify template"); //$NON-NLS-1$
}
}
diff --git a/src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/moa/DetachedLocRefMOAConnector.java b/src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/moa/DetachedLocRefMOAConnector.java
index 31b62f0..3bf0719 100644
--- a/src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/moa/DetachedLocRefMOAConnector.java
+++ b/src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/moa/DetachedLocRefMOAConnector.java
@@ -9,6 +9,7 @@ import java.util.Properties;
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.cfg.SettingsReader;
import at.knowcenter.wag.egov.egiz.exceptions.ConnectorException;
import at.knowcenter.wag.egov.egiz.exceptions.SettingsException;
@@ -38,7 +39,6 @@ public class DetachedLocRefMOAConnector implements Connector
* The SIG_ID prefix.
*/
// public static final String SIG_ID_PREFIX = "etsi-bku-detached@"; //$NON-NLS-1$
-
/**
* The log.
*/
@@ -128,7 +128,6 @@ public class DetachedLocRefMOAConnector implements Connector
// DebugHelper.debugStringToFile(response_properties.getProperty(BKUPostConnection.RESPONSE_STRING_KEY), "MOA_DetLocRef_sign_response.xml"); //$NON-NLS-1$
SignSignatureObject sso = analyzeSignResponse(response_properties);
- // TODO this could be made more generic
sso.response_properties = response_properties;
log.debug("doSign finished."); //$NON-NLS-1$
@@ -187,7 +186,7 @@ public class DetachedLocRefMOAConnector implements Connector
verify_request_xml = verify_request_xml.replaceFirst(TemplateReplaces.LOC_REF_CONTENT_REPLACE, this.environment.getSignatureDataUrl());
log.debug("\r\n\r\n" + verify_request_xml + "\r\n\r\n");
-
+
return verify_request_xml;
}
@@ -234,8 +233,9 @@ public class DetachedLocRefMOAConnector implements Connector
// data digest replace
{
- byte[] data_value = data.getData();
- byte[] data_value_hash = CodingHelper.buildDigest(data_value);
+// byte[] data_value = data.getData();
+// byte[] data_value_hash = CodingHelper.buildDigest(data_value);
+ byte[] data_value_hash = CodingHelper.buildDigest(data.getDataSource());
String object_data_hash = CodingHelper.encodeBase64(data_value_hash);
verify_xml = verify_xml.replaceFirst(TemplateReplaces.DIGEST_VALUE_SIGNED_DATA_REPLACE, object_data_hash);
@@ -289,8 +289,7 @@ public class DetachedLocRefMOAConnector implements Connector
}
}
- protected Properties sendRequest(String url, String mode,
- String request_string) throws ConnectorException
+ protected Properties sendRequest(String url, String mode, String request_string) throws ConnectorException
{
try
{
@@ -324,21 +323,21 @@ public class DetachedLocRefMOAConnector implements Connector
* The configuration key of the sign URL.
*/
protected static final String SIGN_URL_KEY = "moa.sign.url"; //$NON-NLS-1$
-
+
/**
* MOA template file prefix
*/
protected static final String TEMPLATE_FILE_PREFIX = "./templates/moa.";
-
+
/**
* signing file template sufix
*/
protected static final String SIGN_TEMPLATE_FILE_SUFIX = ".sign.xml";
-
+
/**
* verifing template file sufix
*/
- protected static final String VERIFY_REQUEST_TEMPLATE_FILE_SUFIX = ".verify.request.xml";
+ protected static final String VERIFY_REQUEST_TEMPLATE_FILE_SUFIX = ".verify.request.xml";
/**
* verifing file template key sufix
@@ -374,7 +373,7 @@ public class DetachedLocRefMOAConnector implements Connector
* The configuration key for the RSA cert alg property.
*/
protected static final String RSA_CERT_ALG_KEY = "cert.alg.rsa"; //$NON-NLS-1$
-
+
protected String profile = null;
protected String signature_data_url = null;
@@ -410,7 +409,7 @@ public class DetachedLocRefMOAConnector implements Connector
public Environment(String profile, String signature_data_url) throws ConnectorException
{
this.profile = profile;
-
+
this.signature_data_url = signature_data_url;
SettingsReader settings = null;
@@ -424,33 +423,32 @@ public class DetachedLocRefMOAConnector implements Connector
}
this.sign_key_identifier = getConnectorValueFromProfile(settings, profile, SIGN_KEY_IDENTIFIER_KEY);
-
+
String sign_request_filename = TEMPLATE_FILE_PREFIX + settings.getValueFromKey("default.moa.algorithm.id") + SIGN_TEMPLATE_FILE_SUFIX;
-
+
// try to load template from file
this.sign_request_template = FileHelper.readFromFile(SettingsReader.relocateFile(sign_request_filename));
-
- if(this.sign_request_template == null)
+
+ if (this.sign_request_template == null)
{
- sign_request_filename = getConnectorValueFromProfile(settings, profile, SIGN_REQUEST_TEMPLATE_KEY);
- this.sign_request_template = FileHelper.readFromFile(SettingsReader.relocateFile(sign_request_filename));
+ sign_request_filename = getConnectorValueFromProfile(settings, profile, SIGN_REQUEST_TEMPLATE_KEY);
+ this.sign_request_template = FileHelper.readFromFile(SettingsReader.relocateFile(sign_request_filename));
}
//this.sign_request_template = FileHelper.readFromFile(SettingsReader.relocateFile(sign_request_filename));
if (this.sign_request_template == null)
{
- // TODO make this a settings exception
- throw new ConnectorException(300, "Can not read the create xml request template"); //$NON-NLS-1$
+ throw new ConnectorException(ErrorCode.SETTING_NOT_FOUND, "Can not read the create xml request template"); //$NON-NLS-1$
}
this.sign_url = getConnectorValueFromProfile(settings, profile, SIGN_URL_KEY);
-
+
String verify_request_filename = TEMPLATE_FILE_PREFIX + settings.getValueFromKey("default.moa.algorithm.id") + VERIFY_REQUEST_TEMPLATE_FILE_SUFIX;
-
+
// try to load template file for verifing
this.verify_request_template = FileHelper.readFromFile(SettingsReader.relocateFile(verify_request_filename));
-
- if(this.verify_request_template == null)
+
+ if (this.verify_request_template == null)
{
verify_request_filename = getConnectorValueFromProfile(settings, profile, VERIFY_REQUEST_TEMPLATE_KEY);
this.verify_request_template = FileHelper.readFromFile(SettingsReader.relocateFile(verify_request_filename));
@@ -458,24 +456,22 @@ public class DetachedLocRefMOAConnector implements Connector
if (this.verify_request_template == null)
{
- // TODO make this a settings exception
- throw new ConnectorException(300, "Can not read the verify xml request template"); //$NON-NLS-1$
+ throw new ConnectorException(ErrorCode.SETTING_NOT_FOUND, "Can not read the verify xml request template"); //$NON-NLS-1$
}
-
+
// load template key file
String verify_filename = TEMPLATE_FILE_PREFIX + settings.getValueFromKey("default.moa.algorithm.id") + VERIFY_TEMPLATE_SUFIX;
this.verify_template = FileHelper.readFromFile(SettingsReader.relocateFile(verify_filename));
-
- if(this.verify_template == null)
+
+ if (this.verify_template == null)
{
- verify_filename = getConnectorValueFromProfile(settings, profile, VERIFY_TEMPLATE_KEY);
- this.verify_template = FileHelper.readFromFile(SettingsReader.relocateFile(verify_filename));
+ verify_filename = getConnectorValueFromProfile(settings, profile, VERIFY_TEMPLATE_KEY);
+ this.verify_template = FileHelper.readFromFile(SettingsReader.relocateFile(verify_filename));
}
if (this.verify_template == null)
{
- // TODO make this a settings exception
- throw new ConnectorException(300, "Can not read the verify template"); //$NON-NLS-1$
+ throw new ConnectorException(ErrorCode.SETTING_NOT_FOUND, "Can not read the verify template"); //$NON-NLS-1$
}
this.verify_url = getConnectorValueFromProfile(settings, profile, VERIFY_URL_KEY);
@@ -488,8 +484,6 @@ public class DetachedLocRefMOAConnector implements Connector
}
-
-
public String getProfile()
{
return this.profile;
@@ -607,8 +601,7 @@ public class DetachedLocRefMOAConnector implements Connector
* The configuration key.
* @return Returns the configuration entry.
*/
- public static String getConnectorValueFromProfile(SettingsReader settings,
- String profile, String key)
+ public static String getConnectorValueFromProfile(SettingsReader settings, String profile, String key)
{
String value = settings.getValueFromKey("sig_obj." + profile + "." + key); //$NON-NLS-1$//$NON-NLS-2$
if (value == null)
diff --git a/src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/moa/EnvelopingBase64MOAConnector.java b/src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/moa/EnvelopingBase64MOAConnector.java
index aedb7e3..c8a8717 100644
--- a/src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/moa/EnvelopingBase64MOAConnector.java
+++ b/src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/moa/EnvelopingBase64MOAConnector.java
@@ -3,11 +3,6 @@
*/
package at.knowcenter.wag.egov.egiz.sig.connectors.moa;
-import java.io.BufferedWriter;
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.FileWriter;
-import java.io.IOException;
import java.security.cert.X509Certificate;
import java.util.Properties;
@@ -20,7 +15,6 @@ import at.knowcenter.wag.egov.egiz.exceptions.SettingsException;
import at.knowcenter.wag.egov.egiz.sig.SignatureData;
import at.knowcenter.wag.egov.egiz.sig.SignatureResponse;
import at.knowcenter.wag.egov.egiz.sig.connectors.Connector;
-import at.knowcenter.wag.egov.egiz.sig.connectors.ConnectorChooser;
import at.knowcenter.wag.egov.egiz.sig.connectors.TemplateReplaces;
import at.knowcenter.wag.egov.egiz.sig.connectors.bku.BKUHelper;
import at.knowcenter.wag.egov.egiz.sig.connectors.bku.BKUPostConnection;
@@ -84,7 +78,6 @@ public class EnvelopingBase64MOAConnector implements Connector
log.debug("response_string = " + response_properties.getProperty(BKUPostConnection.RESPONSE_STRING_KEY));; //$NON-NLS-1$
SignSignatureObject sso = analyzeSignResponse(response_properties);
- // TODO this could be made more generic
sso.response_properties = response_properties;
log.debug("doSign finished."); //$NON-NLS-1$
diff --git a/src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/moa/MOASoapConnection.java b/src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/moa/MOASoapConnection.java
index 11e7d2f..73ef71b 100644
--- a/src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/moa/MOASoapConnection.java
+++ b/src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/moa/MOASoapConnection.java
@@ -129,7 +129,7 @@ public final class MOASoapConnection
}
catch (Exception e)
{
- throw new WebException(330, e);
+ throw new WebException(e);
}
// serialize signature only
diff --git a/src/main/java/at/knowcenter/wag/egov/egiz/sig/sigid/DetachedLocRefMOAIdFormatter.java b/src/main/java/at/knowcenter/wag/egov/egiz/sig/sigid/DetachedLocRefMOAIdFormatter.java
index 460694d..89f9503 100644
--- a/src/main/java/at/knowcenter/wag/egov/egiz/sig/sigid/DetachedLocRefMOAIdFormatter.java
+++ b/src/main/java/at/knowcenter/wag/egov/egiz/sig/sigid/DetachedLocRefMOAIdFormatter.java
@@ -8,7 +8,6 @@ import org.apache.log4j.Logger;
import at.knowcenter.wag.egov.egiz.cfg.ConfigLogger;
import at.knowcenter.wag.egov.egiz.cfg.SettingsReader;
import at.knowcenter.wag.egov.egiz.exceptions.SettingsException;
-import at.knowcenter.wag.egov.egiz.sig.ConnectorFactory;
/**
* @author wprinz