Class: Saml::Kit::Document
Constant Summary
collapse
- PROTOCOL_XSD =
File.expand_path("./xsd/saml-schema-protocol-2.0.xsd", File.dirname(__FILE__)).freeze
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from Trustable
#provider, #signature, #signature_verified!, #signed?, #trusted?
#error_message
#matches_xsd?
Constructor Details
#initialize(xml, name:, configuration: Saml::Kit.configuration) ⇒ Document
18
19
20
21
22
23
|
# File 'lib/saml/kit/document.rb', line 18
def initialize(xml, name:, configuration: Saml::Kit.configuration)
@configuration = configuration
@content = xml
@name = name
@xml_hash = Hash.from_xml(xml) || {}
end
|
Instance Attribute Details
#configuration ⇒ Object
Returns the value of attribute configuration.
16
17
18
|
# File 'lib/saml/kit/document.rb', line 16
def configuration
@configuration
end
|
#content ⇒ Object
Returns the value of attribute content.
16
17
18
|
# File 'lib/saml/kit/document.rb', line 16
def content
@content
end
|
#name ⇒ Object
Returns the value of attribute name.
16
17
18
|
# File 'lib/saml/kit/document.rb', line 16
def name
@name
end
|
Class Method Details
.to_saml_document(xml, configuration: Saml::Kit.configuration) ⇒ Object
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
|
# File 'lib/saml/kit/document.rb', line 67
def to_saml_document(xml, configuration: Saml::Kit.configuration)
hash = Hash.from_xml(xml)
if hash['Response'].present?
Response.new(xml, configuration: configuration)
elsif hash['LogoutResponse'].present?
LogoutResponse.new(xml, configuration: configuration)
elsif hash['AuthnRequest'].present?
AuthenticationRequest.new(xml, configuration: configuration)
elsif hash['LogoutRequest'].present?
LogoutRequest.new(xml, configuration: configuration)
end
rescue => error
Saml::Kit.logger.error(error)
InvalidDocument.new(xml)
end
|
Instance Method Details
#destination ⇒ Object
37
38
39
|
# File 'lib/saml/kit/document.rb', line 37
def destination
to_h.fetch(name, {}).fetch('Destination', nil)
end
|
#expected_type? ⇒ Boolean
45
46
47
48
|
# File 'lib/saml/kit/document.rb', line 45
def expected_type?
return false if to_xml.blank?
to_h[name].present?
end
|
#id ⇒ Object
25
26
27
|
# File 'lib/saml/kit/document.rb', line 25
def id
to_h.fetch(name, {}).fetch('ID', nil)
end
|
#issue_instant ⇒ Object
41
42
43
|
# File 'lib/saml/kit/document.rb', line 41
def issue_instant
to_h[name]['IssueInstant']
end
|
#issuer ⇒ Object
29
30
31
|
# File 'lib/saml/kit/document.rb', line 29
def issuer
to_h.fetch(name, {}).fetch('Issuer', nil)
end
|
#to_h ⇒ Object
50
51
52
|
# File 'lib/saml/kit/document.rb', line 50
def to_h
@xml_hash
end
|
#to_s ⇒ Object
62
63
64
|
# File 'lib/saml/kit/document.rb', line 62
def to_s
to_xml
end
|
#to_xhtml ⇒ Object
58
59
60
|
# File 'lib/saml/kit/document.rb', line 58
def to_xhtml
Nokogiri::XML(content, &:noblanks).to_xhtml
end
|
#to_xml(pretty: false) ⇒ Object
54
55
56
|
# File 'lib/saml/kit/document.rb', line 54
def to_xml(pretty: false)
pretty ? Nokogiri::XML(content).to_xml(indent: 2) : content
end
|
#version ⇒ Object
33
34
35
|
# File 'lib/saml/kit/document.rb', line 33
def version
to_h.fetch(name, {}).fetch('Version', {})
end
|