aboutsummaryrefslogtreecommitdiff
path: root/pdf-as-lib/src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/moa/EnvelopingBase64MOAConnector.java
diff options
context:
space:
mode:
Diffstat (limited to 'pdf-as-lib/src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/moa/EnvelopingBase64MOAConnector.java')
-rw-r--r--pdf-as-lib/src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/moa/EnvelopingBase64MOAConnector.java72
1 files changed, 40 insertions, 32 deletions
diff --git a/pdf-as-lib/src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/moa/EnvelopingBase64MOAConnector.java b/pdf-as-lib/src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/moa/EnvelopingBase64MOAConnector.java
index 6f2d171..4a33fc8 100644
--- a/pdf-as-lib/src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/moa/EnvelopingBase64MOAConnector.java
+++ b/pdf-as-lib/src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/moa/EnvelopingBase64MOAConnector.java
@@ -54,7 +54,7 @@ import at.knowcenter.wag.egov.egiz.tools.FileHelper;
/**
* @author wprinz
- *
+ *
*/
public class EnvelopingBase64MOAConnector implements Connector
{
@@ -69,18 +69,18 @@ public class EnvelopingBase64MOAConnector implements Connector
* other configurable elements.
*/
protected Environment environment = null;
-
+
protected ConnectorParameters params = null;
/**
* Constructor that builds the configuration environment for this connector
* according to the given profile.
- *
+ *
* <p>
* If confuguration parameters are not defined on that profile, the default
* parameters defined in the configuration are used.
* </p>
- *
+ *
* @param profile
* The profile from which the Environment should be assembled.
* @throws ConnectorException
@@ -150,7 +150,7 @@ public class EnvelopingBase64MOAConnector implements Connector
/**
* Prepares the sign request xml to be sent using the sign request template.
- *
+ *
* @param data
* The SignatureData.
* @return Returns the sign request xml to be sent.
@@ -176,7 +176,7 @@ public class EnvelopingBase64MOAConnector implements Connector
/**
* Prepares the verify request xml to be sent using the verify request
* template.
- *
+ *
* @param data
* The SignatureData.
* @param so
@@ -199,7 +199,11 @@ public class EnvelopingBase64MOAConnector implements Connector
xml_content = chooseAndCreateXMLDsig(data, so);
}
- String verify_request_xml = verify_request_template.replaceFirst(TemplateReplaces.XML_CONTENT_REPLACE, xml_content);
+ // fixed by dti: Issuer names may contain escapted commas ("\,"). As far as replaceFirst (and replaceAll)
+ // methods are regarded, backslashes in the replacement string may cause the results to be different than
+ // if it were being treated as a literal replacement string.
+// String verify_request_xml = verify_request_template.replaceFirst(TemplateReplaces.XML_CONTENT_REPLACE, xml_content);
+ String verify_request_xml = verify_request_template.replace(TemplateReplaces.XML_CONTENT_REPLACE, xml_content);
verify_request_xml = verify_request_xml.replaceFirst(TemplateReplaces.TRUST_PROFILE_ID_REPLACE, this.environment.getVerifyTrustProfileId());
String returnHashInputDataElement = "";
@@ -208,10 +212,10 @@ public class EnvelopingBase64MOAConnector implements Connector
returnHashInputDataElement = MOASoapWithAttachmentConnector.RETURN_HASH_INPUT_DATA;
}
verify_request_xml = verify_request_xml.replaceFirst(TemplateReplaces.RETURN_HASH_INPUT_DATA_REPLACE, returnHashInputDataElement);
-
+
verify_request_xml = verify_request_xml.replaceFirst(TemplateReplaces.DATE_TIME_REPLACE, BKUHelper.formDateTimeElement(this.params.getVerificationTime()));
-
+
log.debug("\r\n\r\n" + verify_request_xml + "\r\n\r\n");
return verify_request_xml;
@@ -219,7 +223,7 @@ public class EnvelopingBase64MOAConnector implements Connector
/**
* Analyzes the sign response xml and extracts the signature data.
- *
+ *
* @param response_properties
* The response properties containing the response String and
* transport related information.
@@ -243,7 +247,7 @@ public class EnvelopingBase64MOAConnector implements Connector
/**
* Analyzes the verify response string.
- *
+ *
* @param response_properties
* The response properties containing the response XML.
* @return Returns the SignatureResponse containing the verification result.
@@ -266,11 +270,11 @@ public class EnvelopingBase64MOAConnector implements Connector
/**
* Prepares the XML content the holds the actual signature data.
- *
+ *
* <p>
* This strongly rebuilds the XML content as retuned from a sign request.
* </p>
- *
+ *
* @param data
* The data.
* @param so
@@ -285,7 +289,7 @@ public class EnvelopingBase64MOAConnector implements Connector
try
{
X509Certificate cert = so.getX509Certificate();
-
+
// dferbas
AlgorithmSuiteObject algSuite = new AlgorithmSuiteObject();
String verify_xml = AlgorithmSuiteUtil.evaluateReplaceAlgs(algSuite, this.environment, so);
@@ -311,7 +315,11 @@ public class EnvelopingBase64MOAConnector implements Connector
// Qualified Properties replaces
verify_xml = verify_xml.replaceFirst(TemplateReplaces.SIGNING_TIME_REPLACE, so.getDate());
verify_xml = verify_xml.replaceFirst(TemplateReplaces.DIGEST_VALUE_CERTIFICATE_REPLACE, certDigest);
- verify_xml = verify_xml.replaceFirst(TemplateReplaces.X509_ISSUER_NAME_REPLACE, so.getIssuer());
+ // fixed by dti: Issuer names may contain escapted commas ("\,"). As far as replaceFirst (and replaceAll)
+ // methods are regarded, backslashes in the replacement string may cause the results to be different than
+ // if it were being treated as a literal replacement string.
+// verify_xml = verify_xml.replaceFirst(TemplateReplaces.X509_ISSUER_NAME_REPLACE, so.getIssuer());
+ verify_xml = verify_xml.replace(TemplateReplaces.X509_ISSUER_NAME_REPLACE, so.getIssuer());
verify_xml = verify_xml.replaceFirst(TemplateReplaces.X509_SERIAL_NUMBER_REPLACE, so.getSerialNumber());
// SigDataRefReplace already done above
@@ -339,7 +347,7 @@ public class EnvelopingBase64MOAConnector implements Connector
// Base64 content replace -> do this at last for performance
String base64 = CodingHelper.encodeBase64(data_value);
verify_xml = verify_xml.replaceFirst(TemplateReplaces.BASE64_CONTENT_REPLACE, base64);
-
+
log.debug("prepareXMLContent finished."); //$NON-NLS-1$
return verify_xml;
}
@@ -352,7 +360,7 @@ public class EnvelopingBase64MOAConnector implements Connector
/**
* Holds environment configuration information like templates.
- *
+ *
* @author wprinz
*/
public static class Environment extends ConnectorEnvironment
@@ -401,7 +409,7 @@ public class EnvelopingBase64MOAConnector 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 sign_key_identifier = null;
@@ -424,7 +432,7 @@ public class EnvelopingBase64MOAConnector implements Connector
/**
* Initializes the environment with a given profile.
- *
+ *
* @param profile
* The configuration profile.
* @throws ConnectorException
@@ -433,7 +441,7 @@ public class EnvelopingBase64MOAConnector implements Connector
public Environment(String profile, String signKeyIdentifier) throws ConnectorException
{
this.profile = profile;
-
+
SettingsReader settings = null;
try
{
@@ -449,7 +457,7 @@ public class EnvelopingBase64MOAConnector implements Connector
this.sign_key_identifier = signKeyIdentifier;
}
else
- {
+ {
this.sign_key_identifier = getConnectorValueFromProfile(settings, profile, SIGN_KEY_IDENTIFIER_KEY);
}
@@ -488,7 +496,7 @@ public class EnvelopingBase64MOAConnector implements Connector
this.cert_alg_rsa = settings.getValueFromKey(RSA_CERT_ALG_KEY);
}
-
+
public String getProfile()
{
return this.profile;
@@ -496,7 +504,7 @@ public class EnvelopingBase64MOAConnector implements Connector
/**
* Returns the sign key identifier.
- *
+ *
* @return Returns the sign key identifier.
*/
public String getSignKeyIdentifier()
@@ -506,7 +514,7 @@ public class EnvelopingBase64MOAConnector implements Connector
/**
* Returns the sign request template.
- *
+ *
* @return Returns the sign request template.
*/
public String getSignRequestTemplate()
@@ -516,7 +524,7 @@ public class EnvelopingBase64MOAConnector implements Connector
/**
* Returns the sign URL.
- *
+ *
* @return Returns the sign URL.
*/
public String getSignURL()
@@ -526,7 +534,7 @@ public class EnvelopingBase64MOAConnector implements Connector
/**
* Returns the verify request template.
- *
+ *
* @return Returns the verify request template.
*/
public String getVerifyRequestTemplate()
@@ -536,7 +544,7 @@ public class EnvelopingBase64MOAConnector implements Connector
/**
* Returns the verify template.
- *
+ *
* @return Returns the verify template.
*/
public String getVerifyTemplate()
@@ -546,7 +554,7 @@ public class EnvelopingBase64MOAConnector implements Connector
/**
* Returns the verify URL.
- *
+ *
* @return Returns the verify URL.
*/
public String getVerifyURL()
@@ -556,7 +564,7 @@ public class EnvelopingBase64MOAConnector implements Connector
/**
* Returns the verify trust profile id.
- *
+ *
* @return Returns the verify trust profile id.
*/
public String getVerifyTrustProfileId()
@@ -566,7 +574,7 @@ public class EnvelopingBase64MOAConnector implements Connector
/**
* Returns the ecdsa cert alg property.
- *
+ *
* @return Returns the ecdsa cert alg property.
*/
public String getCertAlgEcdsa()
@@ -576,7 +584,7 @@ public class EnvelopingBase64MOAConnector implements Connector
/**
* Returns the rsa cert alg property.
- *
+ *
* @return Returns the rsa cert alg property.
*/
public String getCertAlgRsa()
@@ -587,7 +595,7 @@ public class EnvelopingBase64MOAConnector implements Connector
/**
* Reads the configuration entry given by the key, first from the given
* profile, if not found from the defaults.
- *
+ *
* @param settings
* The settings.
* @param profile