Class: Saml::Kit::LogoutRequest

Inherits:
Document
  • Object
show all
Includes:
Requestable
Defined in:
lib/saml/kit/logout_request.rb

Overview

This class can be used to parse a LogoutRequest SAML document.

document = Saml::Kit::LogoutRequest.new(raw_xml)

It can also be used to generate a new LogoutRequest.

document = Saml::Kit::LogoutRequest.build do |builder|
  builder.issuer = "issuer"
end

puts document.to_xml(pretty: true)

See Builders::LogoutRequest for a list of available settings.

This class can also be used to generate the correspondong LogoutResponse for a LogoutRequest.

document = Saml::Kit::LogoutRequest.new(raw_xml)
url, saml_params = document.response_for(binding: :http_post)

See #response_for for more information.

Constant Summary

Constants inherited from Document

Document::CONSTRUCTORS, Document::XPATH

Constants included from XsdValidatable

XsdValidatable::METADATA_XSD, XsdValidatable::PROTOCOL_XSD

Constants included from XmlParseable

XmlParseable::NAMESPACES

Instance Attribute Summary

Attributes inherited from Document

#name, #registry

Instance Method Summary collapse

Methods inherited from Document

#destination, #id, #issue_instant, #issuer, to_saml_document, #version

Methods included from XmlParseable

#present?, #to_h, #to_s, #to_xhtml, #to_xml

Methods included from Trustable

#signed?, #trusted?

Methods included from Validatable

#each_error

Constructor Details

#initialize(xml, configuration: Saml::Kit.configuration) ⇒ LogoutRequest

A new instance of LogoutRequest

Parameters:

  • xml (String)

    The raw xml string.

  • configuration (Saml::Kit::Configuration) (defaults to: Saml::Kit.configuration)

    configuration to use.



36
37
38
# File 'lib/saml/kit/logout_request.rb', line 36

def initialize(xml, configuration: Saml::Kit.configuration)
  super(xml, name: 'LogoutRequest', configuration: configuration)
end

Instance Method Details

#name_idObject

Returns the NameID value.



41
42
43
# File 'lib/saml/kit/logout_request.rb', line 41

def name_id
  at_xpath('./*/saml:NameID').try(:text)
end

#name_id_formatObject



45
46
47
# File 'lib/saml/kit/logout_request.rb', line 45

def name_id_format
  at_xpath('./*/saml:NameID/@Format').try(:value)
end

#response_for(binding:, relay_state: nil) ⇒ Array

Generates a Serialized LogoutResponse using the encoding rules for the specified binding.

‘:http_post`. RelayState param. return to the requestor.

Parameters:

  • binding (Symbol)

    The binding to use ‘:http_redirect` or

  • relay_state (Object) (defaults to: nil)

    The RelayState to include in the

Returns:

  • (Array)

    Returns an array with a url and Hash of parameters to



58
59
60
61
62
63
64
# File 'lib/saml/kit/logout_request.rb', line 58

def response_for(binding:, relay_state: nil)
  builder = Saml::Kit::LogoutResponse.builder(self) do |xxx|
    yield xxx if block_given?
  end
  response_binding = provider.single_logout_service_for(binding: binding)
  response_binding.serialize(builder, relay_state: relay_state)
end