Class: OMF::GENI::AM::Signature
- Inherits:
-
Object
- Object
- OMF::GENI::AM::Signature
- Defined in:
- lib/omf-sfa/am/signature.rb
Class Method Summary collapse
-
.verify_xml_string(content) ⇒ Object
The xml content (provided as string) should contain a Signature tag.
Instance Method Summary collapse
-
#initialize(sig_doc) ⇒ Signature
constructor
A new instance of Signature.
Constructor Details
#initialize(sig_doc) ⇒ Signature
Returns a new instance of Signature.
32 33 34 |
# File 'lib/omf-sfa/am/signature.rb', line 32 def initialize(sig_doc) @sig_doc = sig_doc end |
Class Method Details
.verify_xml_string(content) ⇒ Object
The xml content (provided as string) should contain a Signature tag.
Returns a Signature object if valid. Raises exception if not valid
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/omf-sfa/am/signature.rb', line 11 def self.verify_xml_string(content) tf = sig = nil begin tf = Tempfile.open('omf-am-rpc') tf << content tf.close cmd = "#{@@xmlsec} verify --trusted-pem #{@@root_certs} --print-xml-debug #{tf.path} 2> /dev/null" out = [] #IO.popen("#{cmd} 2>&1") do |so| IO.popen(cmd) do |so| sig = Nokogiri::XML.parse(so) end unless (sig.xpath('/VerificationContext')[0]['status'] == 'succeeded') raise "Error: Signature doesn't verify\n#{sig.to_xml}" end ensure tf.close! if tf end return Signature.new(sig) end |