Class: Onelogin::Saml::Logoutrequest

Inherits:
Object
  • Object
show all
Includes:
Codeing
Defined in:
lib/onelogin/saml/logoutrequest.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Codeing

#decode, #deflate, #encode, #escape, #inflate, #unescape

Constructor Details

#initializeLogoutrequest

Returns a new instance of Logoutrequest.



8
9
10
# File 'lib/onelogin/saml/logoutrequest.rb', line 8

def initialize
  @transaction_id = UUID.new.generate
end

Instance Attribute Details

#transaction_idObject (readonly)

Returns the value of attribute transaction_id.



6
7
8
# File 'lib/onelogin/saml/logoutrequest.rb', line 6

def transaction_id
  @transaction_id
end

Instance Method Details

#create(settings, params = {}) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/onelogin/saml/logoutrequest.rb', line 12

def create(settings, params={})
 issue_instant = Onelogin::Saml::Logoutrequest.timestamp

 request = xml(settings, issue_instant)
 
 deflated_request  = deflate(request)
 base64_request    = encode(deflated_request)
 params["SAMLRequest"] = base64_request
 query_string = params.map {|key, value| "#{key}=#{escape(value)}"}.join("&")

 settings.idp_slo_target_url + "?#{query_string}"
end

#xml(settings, issue_instant) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/onelogin/saml/logoutrequest.rb', line 25

def xml(settings, issue_instant)
  request = <<-EOF
    <samlp:LogoutRequest xmlns:samlp="urn:oasis:names:tc:SAML:2.0:protocol"
        ID="#{transaction_id}" Version="2.0" IssueInstant="#{issue_instant}">
            <saml:Issuer xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion">#{settings.issuer}</saml:Issuer>
            <saml:NameID xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion"
                NameQualifier="#{settings.sp_name_qualifier}"
                Format="#{settings.name_identifier_format}">#{settings.name_id}</saml:NameID>
        <samlp:SessionIndex xmlns:samlp="urn:oasis:names:tc:SAML:2.0:protocol">#{settings.sessionindex}</samlp:SessionIndex>
    </samlp:LogoutRequest>
  EOF

  request
end