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
17
18
# File 'lib/saml2/status.rb', line 14

def initialize(code = SUCCESS, message = nil)
  super()
  @code = code
  @message = 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.



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

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)


21
22
23
24
25
# File 'lib/saml2/status.rb', line 21

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)


27
28
29
# File 'lib/saml2/status.rb', line 27

def success?
  code == SUCCESS
end