Class: Spid::Saml2::IdpLogoutResponse

Inherits:
Object
  • Object
show all
Defined in:
lib/spid/saml2/idp_logout_response.rb

Overview

:nodoc:

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(settings:, request_uuid:, uuid: nil) ⇒ IdpLogoutResponse

Returns a new instance of IdpLogoutResponse.



12
13
14
15
16
17
18
# File 'lib/spid/saml2/idp_logout_response.rb', line 12

def initialize(settings:, request_uuid:, uuid: nil)
  @document = REXML::Document.new
  @settings = settings
  @uuid = uuid || SecureRandom.uuid
  @issue_instant = Time.now.utc.iso8601
  @request_uuid = request_uuid
end

Instance Attribute Details

#documentObject (readonly)

Returns the value of attribute document.



6
7
8
# File 'lib/spid/saml2/idp_logout_response.rb', line 6

def document
  @document
end

#issue_instantObject (readonly)

Returns the value of attribute issue_instant.



9
10
11
# File 'lib/spid/saml2/idp_logout_response.rb', line 9

def issue_instant
  @issue_instant
end

#request_uuidObject (readonly)

Returns the value of attribute request_uuid.



10
11
12
# File 'lib/spid/saml2/idp_logout_response.rb', line 10

def request_uuid
  @request_uuid
end

#settingsObject (readonly)

Returns the value of attribute settings.



7
8
9
# File 'lib/spid/saml2/idp_logout_response.rb', line 7

def settings
  @settings
end

#uuidObject (readonly)

Returns the value of attribute uuid.



8
9
10
# File 'lib/spid/saml2/idp_logout_response.rb', line 8

def uuid
  @uuid
end

Instance Method Details

#issuerObject



47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/spid/saml2/idp_logout_response.rb', line 47

def issuer
  @issuer ||=
    begin
      element = REXML::Element.new("saml:Issuer")
      element.add_attributes(
        "Format" => "urn:oasis:names:tc:SAML:2.0:nameid-format:entity",
        "NameQualifier" => settings.sp_entity_id
      )
      element.text = settings.sp_entity_id
      element
    end
end

#logout_responseObject



25
26
27
28
29
30
31
32
33
34
# File 'lib/spid/saml2/idp_logout_response.rb', line 25

def logout_response
  @logout_response ||=
    begin
      element = REXML::Element.new("samlp:LogoutResponse")
      element.add_attributes(logout_response_attributes)
      element.add_element(issuer)
      element.add_element(status)
      element
    end
end

#logout_response_attributesObject



36
37
38
39
40
41
42
43
44
45
# File 'lib/spid/saml2/idp_logout_response.rb', line 36

def logout_response_attributes
  @logout_response_attributes ||= {
    "xmlns:samlp" => "urn:oasis:names:tc:SAML:2.0:protocol",
    "xmlns:saml" => "urn:oasis:names:tc:SAML:2.0:assertion",
    "IssueInstant" => issue_instant,
    "InResponseTo" => request_uuid,
    "Destination" => settings.idp_slo_target_url,
    "ID" => "_#{uuid}"
  }
end

#statusObject



60
61
62
63
64
65
66
67
# File 'lib/spid/saml2/idp_logout_response.rb', line 60

def status
  @status ||=
    begin
      element = REXML::Element.new("saml:Status")
      element.add_element(status_code)
      element
    end
end

#status_codeObject



69
70
71
72
73
74
75
76
# File 'lib/spid/saml2/idp_logout_response.rb', line 69

def status_code
  @status_code ||=
    begin
      element = REXML::Element.new("saml:StatusCode")
      element.text = "urn:oasis:names:tc:SAML:2.0:status:Success"
      element
    end
end

#to_samlObject



20
21
22
23
# File 'lib/spid/saml2/idp_logout_response.rb', line 20

def to_saml
  document.add_element(logout_response)
  document.to_s
end