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"
REQUESTER =
"urn:oasis:names:tc:SAML:2.0:status:Requester"
RESPONDER =
"urn:oasis:names:tc:SAML:2.0:status:Responder"
VERSION_MISMATCH =
"urn:oasis:names:tc:SAML:2.0:status:VersionMismatch"
AUTHN_FAILED =
"urn:oasis:names:tc:SAML:2.0:status:AuthnFailed"
INVALID_ATTR_NAME_OR_VALUE =
"urn:oasis:names:tc:SAML:2.0:status:InvalidAttrNameOrValue"
INVALID_NAME_ID_POLICY =
"urn:oasis:names:tc:SAML:2.0:status:InvalidNameIDPolicy"
NO_AUTHN_CONTEXT =
"urn:oasis:names:tc:SAML:2.0:status:NoAuthnContext"
NO_AVAILABLE_IDP =
"urn:oasis:names:tc:SAML:2.0:status:NoAvailableIDP"
NO_PASSIVE =
"urn:oasis:names:tc:SAML:2.0:status:NoPassive"
NO_SUPPORTED_IDP =
"urn:oasis:names:tc:SAML:2.0:status:NoSupportedIDP"
PARTIAL_LOGOUT =
"urn:oasis:names:tc:SAML:2.0:status:PartialLogout"
PROXY_COUNT_EXCEEDED =
"urn:oasis:names:tc:SAML:2.0:status:ProxyCountExceeded"
REQUEST_DENIED =
"urn:oasis:names:tc:SAML:2.0:status:RequestDenied"
REQUEST_UNSUPPORTED =
"urn:oasis:names:tc:SAML:2.0:status:RequestUnsupported"
REQUEST_VERSION_DEPRECATED =
"urn:oasis:names:tc:SAML:2.0:status:RequestVersionDeprecated"
REQUEST_VERSION_TOO_HIGH =
"urn:oasis:names:tc:SAML:2.0:status:RequestVersionTooHigh"
REQUEST_VERSION_TOO_LOW =
"urn:oasis:names:tc:SAML:2.0:status:RequestVersionTooLow"
RESOURCE_NOT_RECOGNIZED =
"urn:oasis:names:tc:SAML:2.0:status:ResourceNotRecognized"
TOO_MANY_RESPONSES =
"urn:oasis:names:tc:SAML::2.0:status:TooManyResponses"
UNKNOWN_ATTR_PROFILE =
"urn:oasis:names:tc:SAML:2.0:status:UnknownAttrProfile"
UNKNOWN_PRINCIPAL =
"urn:oasis:names:tc:SAML:2.0:status:UnknownPrincipal"
UNSUPPORTED_BINDING =
"urn:oasis:names:tc:SAML:2.0:status:UnsupportedBinding"
TOP_LEVEL_STATUS_CODES =
[SUCCESS, REQUESTER, RESPONDER, VERSION_MISMATCH].freeze

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, detail = nil) ⇒ Status

Returns a new instance of Status.

Parameters:

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


41
42
43
44
45
46
# File 'lib/saml2/status.rb', line 41

def initialize(code = SUCCESS, message = nil, detail = nil)
  super()
  self.codes = code
  @message = message
  @detail = detail
end

Instance Attribute Details

#codesArray<String>

Returns:

  • (Array<String>)


35
36
37
# File 'lib/saml2/status.rb', line 35

def codes
  @codes
end

#detailString

Returns:

  • (String)


37
38
39
# File 'lib/saml2/status.rb', line 37

def detail
  @detail
end

#messageString

Returns:

  • (String)


37
38
39
# File 'lib/saml2/status.rb', line 37

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.



84
85
86
87
88
89
90
91
# File 'lib/saml2/status.rb', line 84

def build(builder)
  builder["samlp"].Status do |status|
    build_code(status, codes, 0)

    status["samlp"].StatusMessage(message) if message
    status["samlp"].StatusDetail(detail) if detail
  end
end

#codeObject



65
66
67
# File 'lib/saml2/status.rb', line 65

def code
  codes.first
end

#from_xml(node) ⇒ void

This method returns an undefined value.

Parse an XML element into this object.

Parameters:

  • node (Nokogiri::XML::Element)


49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/saml2/status.rb', line 49

def from_xml(node)
  super

  @codes.clear
  code_node = node

  loop do
    code_node = code_node.at_xpath("samlp:StatusCode", Namespaces::ALL)
    break unless code_node

    codes << code_node["Value"]
  end
  self.message = xml.at_xpath("samlp:StatusMessage", Namespaces::ALL)&.content&.strip
  self.detail = xml.at_xpath("samlp:StatusDetail", Namespaces::ALL)&.content&.strip
end

#success?Boolean

Returns:

  • (Boolean)


79
80
81
# File 'lib/saml2/status.rb', line 79

def success?
  code == SUCCESS
end