Commit 300c473

mo <mo.khan@gmail.com>
2018-02-16 17:53:19
extract the signature transforms.
1 parent 1ef60db
Changed files (2)
lib
spec
lib/saml/kit/signature.rb
@@ -9,9 +9,9 @@ module Saml
 
       attr_reader :name
 
-      def initialize(item)
+      def initialize(node)
         @name = "Signature"
-        @node = item
+        @node = node
         @xml_hash = @node ? Hash.from_xml(to_xml)["Signature"] : {}
       end
 
@@ -48,6 +48,10 @@ module Saml
         at_xpath("./ds:SignedInfo/ds:CanonicalizationMethod/@Algorithm").try(:value)
       end
 
+      def transforms
+        node.search("./ds:SignedInfo/ds:Reference/ds:Transforms/ds:Transform/@Algorithm", Saml::Kit::Document::NAMESPACES).try(:map, &:value)
+      end
+
       # Returns the XML Hash.
       def to_h
         @xml_hash
spec/saml/signature_spec.rb
@@ -13,6 +13,7 @@ RSpec.describe Saml::Kit::Signature do
   specify { expect(subject.signature_value).to eql(xml_hash['Signature']['SignatureValue']) }
   specify { expect(subject.signature_method).to eql(xml_hash['Signature']['SignedInfo']['SignatureMethod']['Algorithm']) }
   specify { expect(subject.canonicalization_method).to eql(xml_hash['Signature']['SignedInfo']['CanonicalizationMethod']['Algorithm']) }
+  specify { expect(subject.transforms).to eql(xml_hash['Signature']['SignedInfo']['Reference']['Transforms']['Transform'].map { |x| x['Algorithm'] }) }
 
   describe "#valid?" do
     it 'returns true when the signature is valid' do