aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors')
-rw-r--r--src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/ConnectorChooser.java86
-rw-r--r--src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/bku/DetachedBKUConnector.java24
-rw-r--r--src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/bku/EnvelopedBase64BKUConnector.java4
-rw-r--r--src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/moa/DetachedLocRefMOAConnector.java8
4 files changed, 55 insertions, 67 deletions
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 32dcb72..38680c4 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
@@ -9,7 +9,6 @@ import org.apache.commons.logging.LogFactory;
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.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.EnvelopedBase64BKUConnector;
@@ -31,19 +30,17 @@ public final class ConnectorChooser
/**
* The log.
*/
- private static Log log = LogFactory.getLog(ConnectorChooser.class);
- private static final String MOA_CMD_LINE_SUPPORTED_KEY = "moa.sign.cmd.detached";
+ private static Log log = LogFactory.getLog(ConnectorChooser.class);
+
+ private static final String MOA_DETACHED_ENABLED_KEY = "moa.sign.console.detached.enabled";
- /*
- * Called when we try to connect BKU over Web interface
- */
public static LocalConnector chooseLocalConnectorForSign(String connector,
String profile, String loc_ref_url) throws ConnectorException
{
log.debug("Choosing LocalConnector for signation...");
log.debug("connector type = " + connector);
-
+
if (!connector.equals("bku"))
{
log.error("Currently only the BKU connector is fully implemented.");
@@ -70,43 +67,37 @@ public final class ConnectorChooser
}
public static Connector chooseCommandlineConnectorForSign(String connector,
- String profile) throws ConnectorException, SettingNotFoundException
+ 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
-
+ {
+ log.debug("sig_app is BKU ==> MultipartDetachedBKUConnector"); //$NON-NLS-1$
+
return new MultipartDetachedBKUConnector(profile);
}
-
if (connector.equals(MOA))
- {
- try {
- String cmd_supported = SettingsReader.getInstance().getValueFromKey(MOA_CMD_LINE_SUPPORTED_KEY);
-
- if(cmd_supported.equals("true"))
- {
- //TODO: replace hardcoded constants!!!
- return new DetachedLocRefMOAConnector(profile, "formdata:fileupload");
- }
- else
- {
- // 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);
- }
-
- } catch (SettingsException e) {
+ {
+ // is detached mode enabled from console
+ String detached_mode_enabled = null;
+
+ try
+ {
+ detached_mode_enabled = SettingsReader.getInstance().getValueFromKey(MOA_DETACHED_ENABLED_KEY);
+ } catch (SettingsException e)
+ {
e.printStackTrace();
- }
- //if()
- //return new DetachedLocRefMOAConnector(profile, "formdata:fileupload");
- //return new EnvelopingBase64MOAConnector(profile);
+ }
+
+ // currently MOA does'nt support detached mode in command line
+ if(detached_mode_enabled == null || detached_mode_enabled.equals("true"))
+ return new DetachedLocRefMOAConnector(profile, "formdata:fileupload");
+
+ 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.");
@@ -232,6 +223,13 @@ public final class ConnectorChooser
return chooseEnvelopedBase64ConnectorHotfix(profile, connector);
}
+ // test
+ if (sig_id.equals(""))
+ {
+ 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)
@@ -249,7 +247,6 @@ public final class ConnectorChooser
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.");
@@ -315,22 +312,9 @@ public final class ConnectorChooser
{
log.debug("sig_app is MOA ==> DetachedMOAConnector"); //$NON-NLS-1$
- try
- {
- if(SettingsReader.getInstance().getValueFromKey(MOA_CMD_LINE_SUPPORTED_KEY).equals("false"))
- {
- String msg = "A Detached signature cannot be verified with the MOA connector (yet)."; //$NON-NLS-1$
- log.error(msg);
- throw new ConnectorException(370, msg);
- } else
- {
- // TODO: replace hardcoded constants
- return new DetachedLocRefMOAConnector(profile, "formdata:fileupload");
- }
- } catch (SettingsException e)
- {
- e.printStackTrace();
- }
+ String msg = "A Detached signature cannot be verified with the MOA connector (yet)."; //$NON-NLS-1$
+ log.error(msg);
+ throw new ConnectorException(370, msg);
}
throw new ConnectorException(310, "Unknown sig_app '" + sig_app + "'."); //$NON-NLS-1$ //$NON-NLS-2$
}
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 a48b04c..9713a4a 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
@@ -295,16 +295,16 @@ public class DetachedBKUConnector implements Connector, LocalConnector
String verify_request_template = this.environment.getVerifyRequestTemplate();
String xml_content = null;
-// if (SigKZIDHelper.isMOASigned(so))
-// {
-// log.debug("The signature is MOA signed -> getting XML content from DetachedLocRefMOA connector.");
-// DetachedLocRefMOAConnector moa_conn = new DetachedLocRefMOAConnector(this.environment.getProfile(), "loc ref not needed here");
-// xml_content = moa_conn.prepareXMLContent(data, so);
-// }
-// else
-// {
+ if (SigKZIDHelper.isMOASigned(so))
+ {
+ log.debug("The signature is MOA signed -> getting XML content from DetachedLocRefMOA connector.");
+ DetachedLocRefMOAConnector moa_conn = new DetachedLocRefMOAConnector(this.environment.getProfile(), "loc ref not needed here");
+ xml_content = moa_conn.prepareXMLContent(data, so);
+ }
+ else
+ {
xml_content = prepareXMLContent(data, so);
-// }
+ }
String verify_request_xml = verify_request_template.replaceFirst(TemplateReplaces.XML_CONTENT_REPLACE, xml_content);
verify_request_xml = verify_request_xml.replaceFirst(TemplateReplaces.LOC_REF_CONTENT_REPLACE, this.environment.getLocRefContent());
@@ -450,7 +450,7 @@ public class DetachedBKUConnector implements Connector, LocalConnector
/**
* The configuration key of the sign request template.
*/
- protected static final String SIGN_REQUEST_TEMPLATE_KEY = "bku.sign.request.template"; //$NON-NLS-1$
+ protected static final String SIGN_REQUEST_TEMPLATE_KEY = "bku.sign.request.detached"; //$NON-NLS-1$
/**
* The configuration key of the sign URL.
@@ -460,12 +460,12 @@ public class DetachedBKUConnector implements Connector, LocalConnector
/**
* The configuration key of the verify request template.
*/
- protected static final String VERIFY_REQUEST_TEMPLATE_KEY = "bku.verify.request.template"; //$NON-NLS-1$
+ protected static final String VERIFY_REQUEST_TEMPLATE_KEY = "bku.verify.request.detached"; //$NON-NLS-1$
/**
* The configuration key of the verify template.
*/
- protected static final String VERIFY_TEMPLATE_KEY = "bku.verify.request.template.keys"; //$NON-NLS-1$
+ protected static final String VERIFY_TEMPLATE_KEY = "bku.verify.template.detached"; //$NON-NLS-1$
/**
* The configuration key of the verify URL.
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..dc5d35b 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
@@ -300,6 +300,10 @@ public class EnvelopedBase64BKUConnector implements Connector, LocalConnector
String xml_content = null;
if (SigKZIDHelper.isMOASigned(so))
{
+ //
+ if(so.id.equals("") || so.id == null)
+ so.id = "temp";
+ //
log.debug("The signature is MOA signed -> getting XML content from Base64MOA connector.");
EnvelopingBase64MOAConnector moa_conn = new EnvelopingBase64MOAConnector(this.environment.getProfile());
xml_content = moa_conn.prepareXMLContent(data, so);
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 eeb242f..98d381a 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
@@ -37,7 +37,7 @@ public class DetachedLocRefMOAConnector implements Connector
/**
* The SIG_ID prefix.
*/
- //public static final String SIG_ID_PREFIX = "etsi-bku-detached@"; //$NON-NLS-1$
+ public static final String SIG_ID_PREFIX = "etsi-bku-detached@"; //$NON-NLS-1$
/**
* The log.
@@ -316,7 +316,7 @@ public class DetachedLocRefMOAConnector implements Connector
/**
* The configuration key of the sign request template.
*/
- protected static final String SIGN_REQUEST_TEMPLATE_KEY = "moa.sign.request.template"; //$NON-NLS-1$
+ protected static final String SIGN_REQUEST_TEMPLATE_KEY = "moa.sign.request.detached"; //$NON-NLS-1$
/**
* The configuration key of the sign URL.
@@ -326,12 +326,12 @@ public class DetachedLocRefMOAConnector implements Connector
/**
* The configuration key of the verify request template.
*/
- protected static final String VERIFY_REQUEST_TEMPLATE_KEY = "moa.verify.request.template"; //$NON-NLS-1$
+ protected static final String VERIFY_REQUEST_TEMPLATE_KEY = "moa.verify.request.detached"; //$NON-NLS-1$
/**
* The configuration key of the verify template.
*/
- protected static final String VERIFY_TEMPLATE_KEY = "moa.verify.request.template.keys"; //$NON-NLS-1$
+ protected static final String VERIFY_TEMPLATE_KEY = "moa.verify.template.detached"; //$NON-NLS-1$
/**
* The configuration key of the verify URL.