Class: OneLogin::RubySaml::SloLogoutrequest

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

Overview

SAML2 Logout Request (SLO IdP initiated, Parser)

Constant Summary

Constants inherited from SamlMessage

OneLogin::RubySaml::SamlMessage::ASSERTION, OneLogin::RubySaml::SamlMessage::BASE64_FORMAT, OneLogin::RubySaml::SamlMessage::PROTOCOL

Instance Attribute Summary collapse

Attributes included from ErrorHandling

#errors

Instance Method Summary collapse

Methods included from ErrorHandling

#append_error, #reset_errors!

Methods inherited from SamlMessage

schema, #valid_saml?, #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::RubySaml::Settings object Or :allowed_clock_drift for the logout request validation process to allow a clock drift when checking dates with Or :relax_signature_validation to accept signatures if no idp certificate registered on settings

Raises:

  • (ArgumentError)

    If Request is nil



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

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

  @errors = []
  @options = options
  @soft = true
  unless options[:settings].nil?
    @settings = options[:settings]
    unless @settings.soft.nil?
      @soft = @settings.soft
    end
  end

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

Instance Attribute Details

#documentObject (readonly)

Returns the value of attribute document.



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

def document
  @document
end

#optionsObject (readonly)

Returns the value of attribute options.



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

def options
  @options
end

#requestObject (readonly)

Returns the value of attribute request.



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

def request
  @request
end

#settingsObject

OneLogin::RubySaml::Settings Toolkit settings



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

def settings
  @settings
end

#softObject

Returns the value of attribute soft.



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

def soft
  @soft
end

Instance Method Details

#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.



87
88
89
# File 'lib/onelogin/ruby-saml/slo_logoutrequest.rb', line 87

def id
  super(document)
end

#is_valid?(collect_errors = false) ⇒ Boolean

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

Parameters:

  • collect_errors (Boolean) (defaults to: false)

    Stop validation when first error appears or keep validating.

Returns:

  • (Boolean)

    TRUE if the Logout Request is valid



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

def is_valid?(collect_errors = false)
  validate(collect_errors)
end

#issuerString

Returns Gets the Issuer from the Logout Request.

Returns:

  • (String)

    Gets the Issuer from the Logout Request.



93
94
95
96
97
98
99
100
101
102
# File 'lib/onelogin/ruby-saml/slo_logoutrequest.rb', line 93

def issuer
  @issuer ||= begin
    node = REXML::XPath.first(
      document,
      "/p:LogoutRequest/a:Issuer",
      { "p" => PROTOCOL, "a" => ASSERTION }
    )
    Utils.element_text(node)
  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.



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

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

#name_id_formatString Also known as: nameid_format

Returns Gets the NameID Format of the Logout Request.

Returns:

  • (String)

    Gets the NameID Format of the Logout Request.



75
76
77
78
79
80
81
# File 'lib/onelogin/ruby-saml/slo_logoutrequest.rb', line 75

def name_id_format
  @name_id_node ||= REXML::XPath.first(document, "/p:LogoutRequest/a:NameID", { "p" => PROTOCOL, "a" => ASSERTION })
  @name_id_format ||=
    if @name_id_node && @name_id_node.attribute("Format")
      @name_id_node.attribute("Format").value
    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.



106
107
108
109
110
111
112
113
114
115
116
117
# File 'lib/onelogin/ruby-saml/slo_logoutrequest.rb', line 106

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

#request_idObject



50
51
52
# File 'lib/onelogin/ruby-saml/slo_logoutrequest.rb', line 50

def request_id
  id(document)
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



121
122
123
124
125
126
127
128
129
# File 'lib/onelogin/ruby-saml/slo_logoutrequest.rb', line 121

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

  nodes.map { |node| Utils.element_text(node) }
end