Class: OneLogin::KlRubySaml::SloLogoutrequest

Inherits:
SamlMessage
  • Object
show all
Defined in:
lib/onelogin/kl-ruby-saml/slo_logoutrequest.rb

Overview

SAML2 Logout Request (SLO IdP initiated, Parser)

Constant Summary

Constants inherited from SamlMessage

OneLogin::KlRubySaml::SamlMessage::ASSERTION, OneLogin::KlRubySaml::SamlMessage::BASE64_FORMAT, OneLogin::KlRubySaml::SamlMessage::PROTOCOL

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from SamlMessage

schema, #valid_saml?, #validation_error, #version

Constructor Details

#initialize(request, options = {}) ⇒ SloLogoutrequest

Constructs the Logout Request. A Logout Request Object that is an extension of the SamlMessage class.

Parameters:

  • request (String)

    A UUEncoded Logout Request from the IdP.

  • options (Hash) (defaults to: {})

    :settings to provide the OneLogin::KlRubySaml::Settings object Or :allowed_clock_drift for the logout request validation process to allow a clock drift when checking dates with

Raises:

  • (ArgumentError)

    If Request is nil



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/onelogin/kl-ruby-saml/slo_logoutrequest.rb', line 34

def initialize(request, options = {})
  @errors = []
  raise ArgumentError.new("Request cannot be nil") if request.nil?
  @options  = options

  @soft = true
  if !options.empty? && !options[:settings].nil?
    @settings = options[:settings]
    if !options[:settings].soft.nil? 
      @soft = options[:settings].soft
    end
  end

  @request = decode_raw_saml(request)
  @document = REXML::Document.new(@request)
end

Instance Attribute Details

#documentObject (readonly)

Returns the value of attribute document.



21
22
23
# File 'lib/onelogin/kl-ruby-saml/slo_logoutrequest.rb', line 21

def document
  @document
end

#errorsObject

Array with the causes [Array of strings]



19
20
21
# File 'lib/onelogin/kl-ruby-saml/slo_logoutrequest.rb', line 19

def errors
  @errors
end

#optionsObject (readonly)

Returns the value of attribute options.



23
24
25
# File 'lib/onelogin/kl-ruby-saml/slo_logoutrequest.rb', line 23

def options
  @options
end

#requestObject (readonly)

Returns the value of attribute request.



22
23
24
# File 'lib/onelogin/kl-ruby-saml/slo_logoutrequest.rb', line 22

def request
  @request
end

#settingsObject

OneLogin::KlRubySaml::Settings Toolkit settings



16
17
18
# File 'lib/onelogin/kl-ruby-saml/slo_logoutrequest.rb', line 16

def settings
  @settings
end

#softObject

Returns the value of attribute soft.



25
26
27
# File 'lib/onelogin/kl-ruby-saml/slo_logoutrequest.rb', line 25

def soft
  @soft
end

Instance Method Details

#append_error(error_msg) ⇒ Object

Append the cause to the errors array, and based on the value of soft, return false or raise an exception



53
54
55
56
# File 'lib/onelogin/kl-ruby-saml/slo_logoutrequest.rb', line 53

def append_error(error_msg)
  @errors << error_msg
  return soft ? false : validation_error(error_msg)
end

#idString|nil

Returns Gets the ID attribute from the Logout Request. if exists.

Returns:

  • (String|nil)

    Gets the ID attribute from the Logout Request. if exists.



83
84
85
# File 'lib/onelogin/kl-ruby-saml/slo_logoutrequest.rb', line 83

def id
  super(document)
end

#is_valid?Boolean

Validates the Logout Request with the default values (soft = true)

Returns:

  • (Boolean)

    TRUE if the Logout Request is valid



66
67
68
# File 'lib/onelogin/kl-ruby-saml/slo_logoutrequest.rb', line 66

def is_valid?
  validate
end

#issuerString

Returns Gets the Issuer from the Logout Request.

Returns:

  • (String)

    Gets the Issuer from the Logout Request.



89
90
91
92
93
94
95
96
97
98
# File 'lib/onelogin/kl-ruby-saml/slo_logoutrequest.rb', line 89

def issuer
  @issuer ||= begin
    node = REXML::XPath.first(
      document,
      "/p:LogoutRequest/a:Issuer",
      { "p" => PROTOCOL, "a" => ASSERTION }
    )
    node.nil? ? nil : node.text
  end
end

#name_idString Also known as: nameid

Returns Gets the NameID of the Logout Request.

Returns:

  • (String)

    Gets the NameID of the Logout Request.



72
73
74
75
76
77
# File 'lib/onelogin/kl-ruby-saml/slo_logoutrequest.rb', line 72

def name_id
  @name_id ||= begin
    node = REXML::XPath.first(document, "/p:LogoutRequest/a:NameID", { "p" => PROTOCOL, "a" => ASSERTION })
    node.nil? ? nil : node.text
  end
end

#not_on_or_afterTime|nil

Returns Gets the NotOnOrAfter Attribute value if exists.

Returns:

  • (Time|nil)

    Gets the NotOnOrAfter Attribute value if exists.



102
103
104
105
106
107
108
109
110
111
112
113
# File 'lib/onelogin/kl-ruby-saml/slo_logoutrequest.rb', line 102

def not_on_or_after
  @not_on_or_after ||= begin
    node = REXML::XPath.first(
      document,
      "/p:LogoutRequest",
      { "p" => PROTOCOL }
    )
    if node && node.attributes["NotOnOrAfter"]
      Time.parse(node.attributes["NotOnOrAfter"])
    end
  end
end

#reset_errors!Object

Reset the errors array



59
60
61
# File 'lib/onelogin/kl-ruby-saml/slo_logoutrequest.rb', line 59

def reset_errors!
  @errors = []
end

#session_indexesArray

Returns Gets the SessionIndex if exists (Supported multiple values). Empty Array if none found.

Returns:

  • (Array)

    Gets the SessionIndex if exists (Supported multiple values). Empty Array if none found



117
118
119
120
121
122
123
124
125
126
127
128
129
130
# File 'lib/onelogin/kl-ruby-saml/slo_logoutrequest.rb', line 117

def session_indexes
  s_indexes = []
  nodes = REXML::XPath.match(
    document,
    "/p:LogoutRequest/p:SessionIndex",
    { "p" => PROTOCOL }
  )

  nodes.each do |node|
    s_indexes << node.text
  end

  s_indexes
end