Class: Spid::Saml2::LogoutResponseValidator

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

Overview

:nodoc:

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(response:, settings:, request_uuid:) ⇒ LogoutResponseValidator

Returns a new instance of LogoutResponseValidator.



11
12
13
14
15
16
# File 'lib/spid/saml2/logout_response_validator.rb', line 11

def initialize(response:, settings:, request_uuid:)
  @response = response
  @settings = settings
  @request_uuid = request_uuid
  @errors = {}
end

Instance Attribute Details

#errorsObject (readonly)

Returns the value of attribute errors.



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

def errors
  @errors
end

#request_uuidObject (readonly)

Returns the value of attribute request_uuid.



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

def request_uuid
  @request_uuid
end

#responseObject (readonly)

Returns the value of attribute response.



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

def response
  @response
end

#settingsObject (readonly)

Returns the value of attribute settings.



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

def settings
  @settings
end

Instance Method Details

#callObject



18
19
20
21
22
23
24
# File 'lib/spid/saml2/logout_response_validator.rb', line 18

def call
  [
    matches_request_uuid,
    destination,
    issuer
  ].all?
end

#destinationObject



34
35
36
37
38
39
40
41
42
43
# File 'lib/spid/saml2/logout_response_validator.rb', line 34

def destination
  return true if response.destination == settings.sp_slo_service_url

  @errors["destination"] =
    begin
      "Response Destination is '#{response.destination}'" \
      " but was expected '#{settings.sp_slo_service_url}'"
    end
  false
end

#issuerObject



45
46
47
48
49
50
51
52
53
54
# File 'lib/spid/saml2/logout_response_validator.rb', line 45

def issuer
  return true if response.issuer == settings.idp_entity_id

  @errors["issuer"] =
    begin
      "Response Issuer is '#{response.issuer}'" \
      " but was expected '#{settings.idp_entity_id}'"
    end
  false
end

#matches_request_uuidObject



26
27
28
29
30
31
32
# File 'lib/spid/saml2/logout_response_validator.rb', line 26

def matches_request_uuid
  return true if response.in_response_to == request_uuid

  @errors["request_uuid_mismatch"] =
    "Request uuid not belongs to current session"
  false
end