Class: Spid::Saml2::Response

Inherits:
SamlParser show all
Defined in:
lib/spid/saml2/response.rb

Overview

:nodoc:

Instance Attribute Summary

Attributes inherited from SamlParser

#document, #saml_message

Instance Method Summary collapse

Methods inherited from SamlParser

#element_from_xpath, #initialize

Methods included from Utils

#certificate_from_encoded_der, #decode, #decode_and_inflate, #deflate, #deflate_and_encode, #encode, #escaped_params, #escaped_query_string, #inflate, #query_param, #query_params, #query_string

Constructor Details

This class inherits a constructor from Spid::Saml2::SamlParser

Instance Method Details

#assertion_issuerObject



31
32
33
# File 'lib/spid/saml2/response.rb', line 31

def assertion_issuer
  element_from_xpath("/samlp:Response/saml:Assertion/saml:Issuer/text()")
end

#attributesObject



105
106
107
108
109
110
111
112
113
114
115
116
117
118
# File 'lib/spid/saml2/response.rb', line 105

def attributes
  main_xpath = "/samlp:Response/saml:Assertion/saml:AttributeStatement"
  main_xpath = "#{main_xpath}/saml:Attribute"

  attributes = REXML::XPath.match(document, main_xpath)
  attributes.each_with_object({}) do |attribute, acc|
    xpath = attribute.xpath

    name = document.elements["#{xpath}/@Name"].value
    value = document.elements["#{xpath}/saml:AttributeValue/text()"].value

    acc[name] = value
  end
end

#audienceObject



57
58
59
60
61
62
# File 'lib/spid/saml2/response.rb', line 57

def audience
  element_from_xpath(
    "/samlp:Response/saml:Assertion/saml:Conditions" \
    "/saml:AudienceRestriction/saml:Audience/text()"
  )
end

#certificateObject



27
28
29
# File 'lib/spid/saml2/response.rb', line 27

def certificate
  certificate_from_encoded_der(raw_certificate)
end

#conditions_not_beforeObject



45
46
47
48
49
# File 'lib/spid/saml2/response.rb', line 45

def conditions_not_before
  element_from_xpath(
    "/samlp:Response/saml:Assertion/saml:Conditions/@NotBefore"
  )
end

#conditions_not_on_or_afterObject



51
52
53
54
55
# File 'lib/spid/saml2/response.rb', line 51

def conditions_not_on_or_after
  element_from_xpath(
    "/samlp:Response/saml:Assertion/saml:Conditions/@NotOnOrAfter"
  )
end

#destinationObject



41
42
43
# File 'lib/spid/saml2/response.rb', line 41

def destination
  element_from_xpath("/samlp:Response/@Destination")
end

#in_response_toObject



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

def in_response_to
  document.elements["/samlp:Response/@InResponseTo"]&.value
end

#issuerObject



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

def issuer
  document.elements["/samlp:Response/saml:Issuer/text()"]&.value
end

#name_idObject



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

def name_id
  element_from_xpath(
    "/samlp:Response/saml:Assertion/saml:Subject/saml:NameID/text()"
  )
end

#raw_certificateObject



20
21
22
23
24
25
# File 'lib/spid/saml2/response.rb', line 20

def raw_certificate
  element_from_xpath(
    "/samlp:Response/saml:Assertion/ds:Signature/ds:KeyInfo" \
    "/ds:X509Data/ds:X509Certificate/text()"
  )
end

#session_indexObject



35
36
37
38
39
# File 'lib/spid/saml2/response.rb', line 35

def session_index
  element_from_xpath(
    "/samlp:Response/saml:Assertion/saml:AuthnStatement/@SessionIndex"
  )
end

#status_codeObject



85
86
87
88
89
# File 'lib/spid/saml2/response.rb', line 85

def status_code
  element_from_xpath(
    "/samlp:Response/samlp:Status/samlp:StatusCode/@Value"
  )
end

#status_detailObject



98
99
100
101
102
103
# File 'lib/spid/saml2/response.rb', line 98

def status_detail
  element_from_xpath(
    "/samlp:Response/samlp:Status/samlp:StatusCode/" \
    "samlp:StatusDetail/@Value"
  )
end

#status_messageObject



91
92
93
94
95
96
# File 'lib/spid/saml2/response.rb', line 91

def status_message
  element_from_xpath(
    "samlp:StatusMessage/@Value" \
    "/samlp:Response/samlp:Status/samlp:StatusCode/"
  )
end

#subject_confirmation_data_node_xpathObject



64
65
66
67
# File 'lib/spid/saml2/response.rb', line 64

def subject_confirmation_data_node_xpath
  xpath = "/samlp:Response/saml:Assertion/saml:Subject/"
  "#{xpath}/saml:SubjectConfirmation/saml:SubjectConfirmationData"
end

#subject_in_response_toObject



73
74
75
76
77
# File 'lib/spid/saml2/response.rb', line 73

def subject_in_response_to
  element_from_xpath(
    "#{subject_confirmation_data_node_xpath}/@InResponseTo"
  )
end

#subject_not_on_or_afterObject



79
80
81
82
83
# File 'lib/spid/saml2/response.rb', line 79

def subject_not_on_or_after
  element_from_xpath(
    "#{subject_confirmation_data_node_xpath}/@NotOnOrAfter"
  )
end

#subject_recipientObject



69
70
71
# File 'lib/spid/saml2/response.rb', line 69

def subject_recipient
  element_from_xpath("#{subject_confirmation_data_node_xpath}/@Recipient")
end