From ddcff850831f1216f0e9210489dbe833e71a1990 Mon Sep 17 00:00:00 2001 From: Jonathan PHILIPPE Date: Thu, 26 Sep 2024 12:06:06 +0200 Subject: [PATCH] Improves root tag attributes --- lib/epics/client.rb | 9 +++++++++ lib/epics/generic_request.rb | 27 ++++++++++++++++++++++++--- lib/epics/hia.rb | 14 ++++++++++++-- lib/epics/ini.rb | 15 +++++++++++++-- 4 files changed, 58 insertions(+), 7 deletions(-) diff --git a/lib/epics/client.rb b/lib/epics/client.rb index 9ed115e..5b69a36 100644 --- a/lib/epics/client.rb +++ b/lib/epics/client.rb @@ -50,6 +50,15 @@ def urn_schema end end + def schema_location + case version + when VERSION_H3 + "#{urn_schema} http://www.ebics.org/#{version}/ebics_request.xsd" + when VERSION_H4, VERSION_H5 + "#{urn_schema} ebics_keymgmt_request_#{version}.xsd" + end + end + def inspect "#<#{self.class}:#{self.object_id} @keys=#{self.keys.keys}, diff --git a/lib/epics/generic_request.rb b/lib/epics/generic_request.rb index 6e84ed0..732acae 100644 --- a/lib/epics/generic_request.rb +++ b/lib/epics/generic_request.rb @@ -53,7 +53,14 @@ def auth_signature def to_transfer_xml Nokogiri::XML::Builder.new do |xml| - xml.send(root, 'xmlns:ds' => 'http://www.w3.org/2000/09/xmldsig#', 'xmlns' => client.urn_schema, 'Version' => client.version, 'Revision' => '1') { + xml.send(root, + 'xmlns' => client.urn_schema, + 'xmlns:ds' => 'http://www.w3.org/2000/09/xmldsig#', + 'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance', + 'xsi:schemaLocation' => client.schema_location, + 'Version' => client.version, + 'Revision' => '1' + ) { xml.header(authenticate: true) { xml.static { xml.HostID host_id @@ -76,7 +83,14 @@ def to_transfer_xml def to_receipt_xml Nokogiri::XML::Builder.new do |xml| - xml.send(root, 'xmlns:ds' => 'http://www.w3.org/2000/09/xmldsig#', 'xmlns' => client.urn_schema, 'Version' => client.version, 'Revision' => '1') { + xml.send(root, + 'xmlns' => client.urn_schema, + 'xmlns:ds' => 'http://www.w3.org/2000/09/xmldsig#', + 'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance', + 'xsi:schemaLocation' => client.schema_location, + 'Version' => client.version, + 'Revision' => '1' + ) { xml.header(authenticate: true) { xml.static { xml.HostID host_id @@ -98,7 +112,14 @@ def to_receipt_xml def to_xml Nokogiri::XML::Builder.new do |xml| - xml.send(root, 'xmlns:ds' => 'http://www.w3.org/2000/09/xmldsig#', 'xmlns' => client.urn_schema, 'Version' => client.version, 'Revision'=> '1') { + xml.send(root, + 'xmlns' => client.urn_schema, + 'xmlns:ds' => 'http://www.w3.org/2000/09/xmldsig#', + 'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance', + 'xsi:schemaLocation' => client.schema_location, + 'Version' => client.version, + 'Revision'=> '1' + ) { xml.parent.add_child(header) xml.parent.add_child(auth_signature) xml.parent.add_child(body) diff --git a/lib/epics/hia.rb b/lib/epics/hia.rb index 7505765..c9b9e50 100644 --- a/lib/epics/hia.rb +++ b/lib/epics/hia.rb @@ -24,7 +24,10 @@ def body def order_data Nokogiri::XML::Builder.new do |xml| - xml.HIARequestOrderData('xmlns:ds' => 'http://www.w3.org/2000/09/xmldsig#', 'xmlns' => client.urn_schema) { + xml.HIARequestOrderData( + 'xmlns:ds' => 'http://www.w3.org/2000/09/xmldsig#', + 'xmlns' => client.urn_schema + ) { xml.AuthenticationPubKeyInfo { xml.PubKeyValue { xml.send('ds:RSAKeyValue') { @@ -51,7 +54,14 @@ def order_data def to_xml Nokogiri::XML::Builder.new do |xml| - xml.send(root, 'xmlns:ds' => 'http://www.w3.org/2000/09/xmldsig#', 'xmlns' => client.urn_schema, 'Version' => client.version, 'Revision' => '1') { + xml.send(root, + 'xmlns' => client.urn_schema, + 'xmlns:ds' => 'http://www.w3.org/2000/09/xmldsig#', + 'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance', + 'xsi:schemaLocation' => client.schema_location, + 'Version' => client.version, + 'Revision' => '1' + ) { xml.parent.add_child(header) xml.parent.add_child(body) } diff --git a/lib/epics/ini.rb b/lib/epics/ini.rb index 44bc8fc..5f14f65 100644 --- a/lib/epics/ini.rb +++ b/lib/epics/ini.rb @@ -24,7 +24,11 @@ def body def key_signature Nokogiri::XML::Builder.new do |xml| - xml.SignaturePubKeyOrderData('xmlns:ds' => 'http://www.w3.org/2000/09/xmldsig#', 'xmlns' => 'http://www.ebics.org/S001') { + xml.SignaturePubKeyOrderData( + 'xmlns' => 'http://www.ebics.org/S001', + 'xmlns:ds' => 'http://www.w3.org/2000/09/xmldsig#', + 'xsi:schemaLocation' => 'http://www.ebics.org/S001 http://www.ebics.org/S001/ebics_signature.xsd' + ) { xml.SignaturePubKeyInfo { xml.PubKeyValue { xml.send('ds:RSAKeyValue') { @@ -43,7 +47,14 @@ def key_signature def to_xml Nokogiri::XML::Builder.new do |xml| - xml.send(root, 'xmlns:ds' => 'http://www.w3.org/2000/09/xmldsig#', 'xmlns' => client.urn_schema, 'Version' => client.version, 'Revision' => '1') { + xml.send(root, + 'xmlns' => client.urn_schema, + 'xmlns:ds' => 'http://www.w3.org/2000/09/xmldsig#', + 'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance', + 'xsi:schemaLocation' => client.schema_location, + 'Version' => client.version, + 'Revision' => '1' + ) { xml.parent.add_child(header) xml.parent.add_child(body) }