Class: Eet::Message
- Inherits:
-
Object
- Object
- Eet::Message
- Defined in:
- lib/eet/message.rb
Constant Summary collapse
- SOAP_ENV_SCHEMA =
"http://schemas.xmlsoap.org/soap/envelope/"- WSSE_SCHEMA =
"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"- WSU_SCHEMA =
"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"- WSU_ID =
'artificial_id'
Instance Attribute Summary collapse
-
#data ⇒ Object
Returns the value of attribute data.
-
#options ⇒ Object
Returns the value of attribute options.
Instance Method Summary collapse
- #body ⇒ Object
- #envelope ⇒ Object
-
#initialize(data, options = { already_issued: false, first_send: true }) ⇒ Message
constructor
A new instance of Message.
- #to_xml ⇒ Object
Constructor Details
#initialize(data, options = { already_issued: false, first_send: true }) ⇒ Message
Returns a new instance of Message.
15 16 17 18 |
# File 'lib/eet/message.rb', line 15 def initialize(data, = { already_issued: false, first_send: true }) @data = data = end |
Instance Attribute Details
#data ⇒ Object
Returns the value of attribute data.
13 14 15 |
# File 'lib/eet/message.rb', line 13 def data @data end |
#options ⇒ Object
Returns the value of attribute options.
13 14 15 |
# File 'lib/eet/message.rb', line 13 def end |
Instance Method Details
#body ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/eet/message.rb', line 20 def body Nokogiri::XML::Builder.new('encoding' => 'UTF-8') do |xml| xml.Trzba(xmlns: 'http://fs.mfcr.cz/eet/schema/v3') do xml.Hlavicka(dat_odesl: data[:timestamp], prvni_zaslani: [:first_send], uuid_zpravy: SecureRandom.uuid) xml.Data(data[:data]) xml.KontrolniKody do xml.pkp(cipher: 'RSA2048', digest: 'SHA256', encoding: 'base64') do xml.text(data[:pkp]) end xml.bkp(digest: 'SHA1', encoding: 'base16') do xml.text(data[:bkp]) end end end end.doc end |
#envelope ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/eet/message.rb', line 40 def envelope Nokogiri::XML::Builder.new('encoding' => 'UTF-8') do |xml| xml['soap'].Envelope('xmlns:soap' => "http://schemas.xmlsoap.org/soap/envelope/") do xml['SOAP-ENV'].Header('xmlns:SOAP-ENV' => SOAP_ENV_SCHEMA) do xml['wsse'].Security('xmlns:wsse' => WSSE_SCHEMA, 'xmlns:wsu' => WSU_SCHEMA, 'soap:mustUnderstand' => '1') end xml['soap'].Body('xmlns:wsu' => WSU_SCHEMA, 'wsu:Id' => WSU_ID) do end end end.doc end |
#to_xml ⇒ Object
53 54 55 56 57 58 59 |
# File 'lib/eet/message.rb', line 53 def to_xml msg = envelope.dup body = msg.at_xpath('//soap:Body') body.add_child(self.body.root) msg end |