From 3d982813b34f6f230baf4a467cdc37ec92a77595 Mon Sep 17 00:00:00 2001 From: netconomy Date: Fri, 17 Aug 2007 06:10:56 +0000 Subject: Performance git-svn-id: https://joinup.ec.europa.eu/svn/pdf-as/trunk@167 7b5415b0-85f9-ee4d-85bd-d5d0c3b42d1c --- .../connectors/moa/DetachedLocRefMOAConnector.java | 69 ++++++++++------------ 1 file changed, 31 insertions(+), 38 deletions(-) (limited to 'src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/moa/DetachedLocRefMOAConnector.java') 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) -- cgit v1.2.3