Class: Epics::XMLSIG

Inherits:
Faraday::Middleware
  • Object
show all
Defined in:
lib/epics/middleware/xmlsig.rb

Instance Method Summary collapse

Constructor Details

#initialize(app, options = {}) ⇒ XMLSIG

Returns a new instance of XMLSIG.


3
4
5
6
# File 'lib/epics/middleware/xmlsig.rb', line 3

def initialize(app, options = {})
  super(app)
  @client = options[:client]
end

Instance Method Details

#call(env) ⇒ Object


8
9
10
11
12
13
14
15
16
# File 'lib/epics/middleware/xmlsig.rb', line 8

def call(env)
  @signer = Epics::Signer.new(@client, env["body"])
  @signer.digest!
  @signer.sign!

  env["body"] = @signer.doc.to_xml(save_with: Nokogiri::XML::Node::SaveOptions::AS_XML)

  @app.call(env)
end