From db52e4d66d60184d53a27ba4d6772461daacc03d Mon Sep 17 00:00:00 2001 From: tknall Date: Fri, 22 Mar 2013 08:57:51 +0000 Subject: Maintenance update (bugfixes, new features, cleanup...) Refer to /dok/RELEASE_NOTES-3.3.txt for further information. git-svn-id: https://joinup.ec.europa.eu/svn/pdf-as/pdf-as/trunk@931 7b5415b0-85f9-ee4d-85bd-d5d0c3b42d1c --- .../bku/EnvelopedBase64BKUConnector.java | 68 ++++++++++++---------- 1 file changed, 38 insertions(+), 30 deletions(-) (limited to 'pdf-as-lib/src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/bku/EnvelopedBase64BKUConnector.java') diff --git a/pdf-as-lib/src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/bku/EnvelopedBase64BKUConnector.java b/pdf-as-lib/src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/bku/EnvelopedBase64BKUConnector.java index 170cc45..22318a2 100644 --- a/pdf-as-lib/src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/bku/EnvelopedBase64BKUConnector.java +++ b/pdf-as-lib/src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/bku/EnvelopedBase64BKUConnector.java @@ -52,7 +52,7 @@ import at.knowcenter.wag.egov.egiz.tools.CodingHelper; /** * @author wprinz - * + * */ public class EnvelopedBase64BKUConnector implements Connector, LocalConnector { @@ -72,16 +72,16 @@ public class EnvelopedBase64BKUConnector implements Connector, LocalConnector /** * Constructor that builds the configuration environment for this connector * according to the given profile. - * + * *

* If confuguration parameters are not defined on that profile, the default * parameters defined in the configuration are used. *

- * + * *

* This is the new "hotfix" base64 connector. *

- * + * * @param profile * The profile from which the Environment should be assembled. * @throws ConnectorException @@ -137,7 +137,7 @@ public class EnvelopedBase64BKUConnector implements Connector, LocalConnector // /** // * This emthod extracts id-values from a text. The id is given by the name. -// * +// * // * @param text // * the id-value that should extract from // * @param name @@ -166,11 +166,11 @@ public class EnvelopedBase64BKUConnector implements Connector, LocalConnector /** * Prepares the XML content the holds the actual signature data. - * + * *

* This strongly rebuilds the XML content as retuned from a sign request. *

- * + * * @param data * The data. * @param so @@ -186,13 +186,13 @@ public class EnvelopedBase64BKUConnector implements Connector, LocalConnector { String ids_string = so.getSigID(); String[] ids = SignatureObject.parseSigIds(ids_string); - + X509Certificate cert = so.getX509Certificate(); - + // dferbas AlgorithmSuiteObject algSuite = new AlgorithmSuiteObject(); String verify_xml = AlgorithmSuiteUtil.evaluateReplaceAlgs(algSuite, this.environment, so); - + // data digest replace byte[] data_value = BKUHelper.prepareEnvelopingData(data); { @@ -225,7 +225,11 @@ public class EnvelopedBase64BKUConnector implements Connector, LocalConnector verify_xml = verify_xml.replaceAll(TemplateReplaces.SIG_ID_REPLACE, ids[0]); 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 @@ -276,7 +280,7 @@ public class EnvelopedBase64BKUConnector implements Connector, LocalConnector /** * 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. @@ -302,7 +306,7 @@ public class EnvelopedBase64BKUConnector implements Connector, LocalConnector /** * Prepares the verify request xml to be sent using the verify request * template. - * + * * @param data * The SignatureData. * @param so @@ -325,7 +329,11 @@ public class EnvelopedBase64BKUConnector implements Connector, LocalConnector 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); // log.debug("\r\n\r\n" + verify_request_xml + "\r\n\r\n"); @@ -349,7 +357,7 @@ public class EnvelopedBase64BKUConnector implements Connector, LocalConnector /** * Sends the request to the given URL. - * + * * @param url * The URL. * @param request_string @@ -373,7 +381,7 @@ public class EnvelopedBase64BKUConnector implements Connector, LocalConnector /** * Analyzes the sign response xml and extracts the signature data. - * + * * @param response_properties * The response properties containing the response String and * transport related information. @@ -391,7 +399,7 @@ public class EnvelopedBase64BKUConnector implements Connector, LocalConnector String bkuIdentifier = BKUHelper.getBKUIdentifier(response_properties); log.debug("BKU identifier: \"" + bkuIdentifier + "\""); - + SignSignatureObject so = BKUHelper.parseCreateXMLResponse(response_string, new HotfixIdFormatter(), this.environment); log.debug("analyzeSignResponse finished."); //$NON-NLS-1$ @@ -400,7 +408,7 @@ public class EnvelopedBase64BKUConnector implements Connector, LocalConnector /** * Analyzes the verify response string. - * + * * @param response_properties * The response properties containing the response XML. * @return Returns the SignatureResponse containing the verification result. @@ -423,7 +431,7 @@ public class EnvelopedBase64BKUConnector implements Connector, LocalConnector /** * Holds environment configuration information like templates. - * + * * @author wprinz */ public static class Environment extends ConnectorEnvironment @@ -488,7 +496,7 @@ public class EnvelopedBase64BKUConnector implements Connector, LocalConnector /** * Initializes the environment with a given profile. - * + * * @param profile * The configuration profile. * @throws ConnectorException @@ -524,7 +532,7 @@ public class EnvelopedBase64BKUConnector implements Connector, LocalConnector //this.verify_request_template = FileHelper.readFromFile(SettingsReader.relocateFile(verify_request_filename)); this.verify_request_template = settings.readInternalResourceAsString(verify_request_filename); log.debug("Verify request template filename = " + verify_request_filename); - + if (this.verify_request_template == null) { throw new ConnectorException(ErrorCode.SETTING_NOT_FOUND, "Can not read the verify xml request template"); //$NON-NLS-1$ @@ -555,7 +563,7 @@ public class EnvelopedBase64BKUConnector implements Connector, LocalConnector /** * Returns the sign keybox identifier. - * + * * @return Returns the sign keybox identifier. */ public String getSignKeyboxIdentifier() @@ -565,7 +573,7 @@ public class EnvelopedBase64BKUConnector implements Connector, LocalConnector /** * Returns the sign request template. - * + * * @return Returns the sign request template. */ public String getSignRequestTemplate() @@ -575,7 +583,7 @@ public class EnvelopedBase64BKUConnector implements Connector, LocalConnector /** * Returns the sign URL. - * + * * @return Returns the sign URL. */ public String getSignURL() @@ -585,7 +593,7 @@ public class EnvelopedBase64BKUConnector implements Connector, LocalConnector /** * Returns the verify request template. - * + * * @return Returns the verify request template. */ public String getVerifyRequestTemplate() @@ -595,7 +603,7 @@ public class EnvelopedBase64BKUConnector implements Connector, LocalConnector /** * Returns the verify template. - * + * * @return Returns the verify template. */ public String getVerifyTemplate() @@ -605,7 +613,7 @@ public class EnvelopedBase64BKUConnector implements Connector, LocalConnector /** * Returns the verify URL. - * + * * @return Returns the verify URL. */ public String getVerifyURL() @@ -615,7 +623,7 @@ public class EnvelopedBase64BKUConnector implements Connector, LocalConnector /** * Returns the ecdsa cert alg property. - * + * * @return Returns the ecdsa cert alg property. */ public String getCertAlgEcdsa() @@ -625,7 +633,7 @@ public class EnvelopedBase64BKUConnector implements Connector, LocalConnector /** * Returns the rsa cert alg property. - * + * * @return Returns the rsa cert alg property. */ public String getCertAlgRsa() @@ -636,7 +644,7 @@ public class EnvelopedBase64BKUConnector implements Connector, LocalConnector /** * 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 -- cgit v1.2.3