Class: SAML2::Status

Inherits:
Base
  • Object
show all
Defined in:
lib/saml2/status.rb

Constant Summary collapse

SUCCESS =
"urn:oasis:names:tc:SAML:2.0:status:Success"

Instance Attribute Summary collapse

Attributes inherited from Base

#xml

Instance Method Summary collapse

Methods inherited from Base

#decrypt, from_xml, #inspect, load_object_array, load_string_array, lookup_qname, #to_s, #to_xml

Constructor Details

#initialize(code = SUCCESS, message = nil) ⇒ Status

Returns a new instance of Status.

Parameters:

  • code (String) (defaults to: SUCCESS)
  • message (String, nil) (defaults to: nil)

14
15
16
# File 'lib/saml2/status.rb', line 14

def initialize(code = SUCCESS, message = nil)
  @code, @message = code, message
end

Instance Attribute Details

#codeString

Returns:

  • (String)

10
11
12
# File 'lib/saml2/status.rb', line 10

def code
  @code
end

#messageString

Returns:

  • (String)

10
11
12
# File 'lib/saml2/status.rb', line 10

def message
  @message
end

Instance Method Details

#build(builder) ⇒ void

This method returns an undefined value.

Serialize this object to XML, as part of a larger document

Parameters:

  • builder (Nokogiri::XML::Builder)

    The builder helper object to serialize to.


30
31
32
33
34
35
36
37
# File 'lib/saml2/status.rb', line 30

def build(builder)
  builder['samlp'].Status do |status|
    status['samlp'].StatusCode(Value: code)
    Array(message).each do |m|
      status['samlp'].StatusMessage(m)
    end
  end
end

#from_xml(node) ⇒ void

This method returns an undefined value.

Parse an XML element into this object.

Parameters:

  • node (Nokogiri::XML::Element)

19
20
21
22
23
# File 'lib/saml2/status.rb', line 19

def from_xml(node)
  super
  self.code = node.at_xpath('samlp:StatusCode', Namespaces::ALL)['Value']
  self.message = load_string_array(xml, 'samlp:StatusMessage')
end

#success?Boolean

Returns:

  • (Boolean)

25
26
27
# File 'lib/saml2/status.rb', line 25

def success?
  code == SUCCESS
end