Class: SAML2::Message
Overview
In the SAML Schema, Request and Response don’t technically share a common ancestor, but they have several things in common so it’s useful to represent that here
Direct Known Subclasses
Instance Attribute Summary collapse
-
#destination ⇒ Object
Returns the value of attribute destination.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#issue_instant ⇒ Object
readonly
Returns the value of attribute issue_instant.
-
#issuer ⇒ Object
Returns the value of attribute issuer.
Attributes inherited from Base
Class Method Summary collapse
Instance Method Summary collapse
- #from_xml(node) ⇒ Object
-
#initialize ⇒ Message
constructor
A new instance of Message.
- #valid_schema? ⇒ Boolean
Methods inherited from Base
load_object_array, load_string_array, lookup_qname, #to_s, #to_xml
Constructor Details
#initialize ⇒ Message
Returns a new instance of Message.
72 73 74 75 |
# File 'lib/saml2/message.rb', line 72 def initialize @id = "_#{SecureRandom.uuid}" @issue_instant = Time.now.utc end |
Instance Attribute Details
#destination ⇒ Object
Returns the value of attribute destination.
42 43 44 |
# File 'lib/saml2/message.rb', line 42 def destination @destination end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
41 42 43 |
# File 'lib/saml2/message.rb', line 41 def id @id end |
#issue_instant ⇒ Object (readonly)
Returns the value of attribute issue_instant.
41 42 43 |
# File 'lib/saml2/message.rb', line 41 def issue_instant @issue_instant end |
#issuer ⇒ Object
Returns the value of attribute issuer.
42 43 44 |
# File 'lib/saml2/message.rb', line 42 def issuer @issuer end |
Class Method Details
.from_xml(node) ⇒ Object
50 51 52 53 54 55 |
# File 'lib/saml2/message.rb', line 50 def from_xml(node) return super unless self == Message klass = Message.[node.name] raise UnknownMessage.new("Unknown message #{node.name}") unless klass klass.from_xml(node) end |
.inherited(klass) ⇒ Object
45 46 47 48 |
# File 'lib/saml2/message.rb', line 45 def inherited(klass) # explicitly keep track of all messages in this base class Message.[klass.name.sub(/^SAML2::/, '')] = klass end |
.parse(xml) ⇒ Object
57 58 59 60 61 62 63 |
# File 'lib/saml2/message.rb', line 57 def parse(xml) result = Message.from_xml(Nokogiri::XML(xml) { |config| config.strict }.root) raise UnexpectedMessage.new("Expected a #{self.name}, but got a #{result.class.name}") unless self == Message || result.class == self result rescue Nokogiri::XML::SyntaxError raise CorruptMessage end |
Instance Method Details
#from_xml(node) ⇒ Object
77 78 79 80 81 |
# File 'lib/saml2/message.rb', line 77 def from_xml(node) super @id = nil @issue_instant = nil end |