Class: Samlr::Signature
Overview
A SAML specific implementation en.wikipedia.org/wiki/XML_Signature
Instance Attribute Summary collapse
-
#document ⇒ Object
readonly
Returns the value of attribute document.
-
#fingerprint ⇒ Object
readonly
Returns the value of attribute fingerprint.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#original ⇒ Object
readonly
Returns the value of attribute original.
-
#prefix ⇒ Object
readonly
Returns the value of attribute prefix.
-
#signature ⇒ Object
readonly
Returns the value of attribute signature.
Instance Method Summary collapse
-
#initialize(original, prefix, options) ⇒ Signature
constructor
Is initialized with the source document and a path to the element embedding the signature.
- #missing? ⇒ Boolean
- #present? ⇒ Boolean
- #references ⇒ Object
- #verify! ⇒ Object
Constructor Details
#initialize(original, prefix, options) ⇒ Signature
Is initialized with the source document and a path to the element embedding the signature
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/samlr/signature.rb', line 12 def initialize(original, prefix, ) # Signature validations require document alterations @original = original @document = original.dup @prefix = prefix @options = if @signature = document.at("#{prefix}/ds:Signature", NS_MAP) @signature.remove # enveloped signatures only end @fingerprint = if [:fingerprint] Fingerprint.from_string([:fingerprint]) elsif [:certificate] Certificate.new([:certificate]).fingerprint end end |
Instance Attribute Details
#document ⇒ Object (readonly)
Returns the value of attribute document.
9 10 11 |
# File 'lib/samlr/signature.rb', line 9 def document @document end |
#fingerprint ⇒ Object (readonly)
Returns the value of attribute fingerprint.
9 10 11 |
# File 'lib/samlr/signature.rb', line 9 def fingerprint @fingerprint end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
9 10 11 |
# File 'lib/samlr/signature.rb', line 9 def @options end |
#original ⇒ Object (readonly)
Returns the value of attribute original.
9 10 11 |
# File 'lib/samlr/signature.rb', line 9 def original @original end |
#prefix ⇒ Object (readonly)
Returns the value of attribute prefix.
9 10 11 |
# File 'lib/samlr/signature.rb', line 9 def prefix @prefix end |
#signature ⇒ Object (readonly)
Returns the value of attribute signature.
9 10 11 |
# File 'lib/samlr/signature.rb', line 9 def signature @signature end |
Instance Method Details
#missing? ⇒ Boolean
34 35 36 |
# File 'lib/samlr/signature.rb', line 34 def missing? signature.nil? || certificate.nil? end |
#present? ⇒ Boolean
30 31 32 |
# File 'lib/samlr/signature.rb', line 30 def present? !missing? end |
#references ⇒ Object
48 49 50 51 52 53 54 |
# File 'lib/samlr/signature.rb', line 48 def references @references ||= [].tap do |refs| original.xpath("#{prefix}/ds:Signature/ds:SignedInfo/ds:Reference[@URI]", NS_MAP).each do |ref| refs << Samlr::Reference.new(ref) end end end |
#verify! ⇒ Object
38 39 40 41 42 43 44 45 46 |
# File 'lib/samlr/signature.rb', line 38 def verify! raise SignatureError.new("No signature at #{prefix}/ds:Signature") unless present? verify_fingerprint! unless [:skip_fingerprint] verify_digests! verify_signature! true end |