Class: RSAML::Protocol::StatusCode

Inherits:
Object
  • Object
show all
Defined in:
lib/rsaml/protocol/status_code.rb

Overview

A code or a set of nested codes representing the status of the corresponding request.

More information on available status codes may be found in Section 3.2.2.2 of the SAML 2.0 Core specification.

Constant Summary collapse

SUCCESS =

Constant respresenting the Success status

StatusCode.new('urn:oasis:names:tc:SAML:2.0:status:Success')
REQUESTOR =

Constant representing the Requestor status

StatusCode.new('urn:oasis:names:tc:SAML:2.0:status:Requestor')
RESPONDER =

Constant representing the Responder status

StatusCode.new('urn:oasis:names:tc:SAML:2.0:status:Responder')
VERSION_MISMATCH =

Constant representing the VersionMismatch status

StatusCode.new('urn:oasis:names:tc:SAML:2.0:status:VersionMismatch')

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(value) ⇒ StatusCode

Initialize the status code with the given value



9
10
11
# File 'lib/rsaml/protocol/status_code.rb', line 9

def initialize(value)
  @value = value
end

Instance Attribute Details

#status_codeObject

An optional child status code.



64
65
66
# File 'lib/rsaml/protocol/status_code.rb', line 64

def status_code
  @status_code
end

#valueObject

The status code value. Value is a URI reference.



61
62
63
# File 'lib/rsaml/protocol/status_code.rb', line 61

def value
  @value
end

Class Method Details

.second_level_status_codesObject

Hash of symbol/StatusCode pairs representing second-level status codes.



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/rsaml/protocol/status_code.rb', line 36

def self.second_level_status_codes
  @second_level_status_codes ||= {
    :authn_failed => StatusCode.new('urn:oasis:names:tc:SAML:2.0:status:AuthnFailed'),
    :invalid_attr_name_or_value => StatusCode.new('urn:oasis:names:tc:SAML:2.0:status:InvalidAttrNameOrValue'),
    :invalid_name_id_policy => StatusCode.new('urn:oasis:names:tc:SAML:2.0:status:InvalidNameIDPolicy'),
    :no_authn_context => StatusCode.new('urn:oasis:names:tc:SAML:2.0:status:NoAuthnContext'),
    :no_available_idp => StatusCode.new('urn:oasis:names:tc:SAML:2.0:status:NoAvailableIDP'),
    :no_passive => StatusCode.new('urn:oasis:names:tc:SAML:2.0:status:NoPassive'),
    :no_supported_idp => StatusCode.new('urn:oasis:names:tc:SAML:2.0:status:NoSupportedIDP'),
    :partial_logout => StatusCode.new('urn:oasis:names:tc:SAML:2.0:status:PartialLogout'),
    :proxy_count_exceeded => StatusCode.new('urn:oasis:names:tc:SAML:2.0:status:ProxyCountExceeded'),
    :request_denied => StatusCode.new('urn:oasis:names:tc:SAML:2.0:status:RequestDenied'),
    :request_unsupported => StatusCode.new('urn:oasis:names:tc:SAML:2.0:status:RequestUnsupported'),
    :request_version_deprecated => StatusCode.new('urn:oasis:names:tc:SAML:2.0:status:RequestVersionDeprecated'),
    :request_version_too_high => StatusCode.new('urn:oasis:names:tc:SAML:2.0:status:RequestVersionTooHigh'),
    :request_version_too_low => StatusCode.new('urn:oasis:names:tc:SAML:2.0:status:RequestVersionTooLow'),
    :resource_not_recognized => StatusCode.new('urn:oasis:names:tc:SAML:2.0:status:ResourceNotRecognized'),
    :too_many_responses => StatusCode.new('urn:oasis:names:tc:SAML:2.0:status:TooManyResponse'),
    :unknown_attr_profile => StatusCode.new('urn:oasis:names:tc:SAML:2.0:status:UnknownAttrProfile'),
    :unknown_principal => StatusCode.new('urn:oasis:names:tc:SAML:2.0:status:UnknownPrincipal'),
    :unsupported_binding => StatusCode.new('urn:oasis:names:tc:SAML:2.0:status:UnsupportedBinding'),
  }
end

.top_level_status_codesObject

Hash of symbol/StatusCode pairs representing top-level status codes.



26
27
28
29
30
31
32
33
# File 'lib/rsaml/protocol/status_code.rb', line 26

def self.top_level_status_codes
  @top_level_status_codes ||= {
    :success => SUCCESS,
    :requestor => REQUESTOR,
    :responder => RESPONDER,
    :version_mismatch => VERSION_MISMATCH
  }
end

Instance Method Details

#to_sObject

Return the value of the status code as a string.



79
80
81
# File 'lib/rsaml/protocol/status_code.rb', line 79

def to_s
  value
end

#to_xml(xml = Builder::XmlMarkup.new) ⇒ Object

Construct an XML fragment representing the request



71
72
73
74
75
76
# File 'lib/rsaml/protocol/status_code.rb', line 71

def to_xml(xml=Builder::XmlMarkup.new)
  attributes = {'Value' => value}
  xml.tag!('samlp:StatusCode', attributes) {
    xml << status_code.to_xml unless status_code.nil?
  }
end

#validateObject

Raises:



66
67
68
# File 'lib/rsaml/protocol/status_code.rb', line 66

def validate
  raise ValidationError, "Value is required" if value.nil?
end