Class: SAML2::Entity
Defined Under Namespace
Classes: Group
Instance Attribute Summary collapse
#contacts, #organization
Attributes inherited from Base
#xml
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from Signable
#sign, #signature, #signed?, #signing_key, #valid_signature?, #validate_signature
Methods inherited from Base
from_xml, #inspect, load_object_array, load_string_array, lookup_qname, #to_s, #to_xml
Constructor Details
#initialize ⇒ Entity
Returns a new instance of Entity.
74
75
76
77
78
79
80
|
# File 'lib/saml2/entity.rb', line 74
def initialize
super
@valid_until = nil
@entity_id = nil
@roles = []
@id = "_#{SecureRandom.uuid}"
end
|
Instance Attribute Details
#entity_id ⇒ Object
93
94
95
|
# File 'lib/saml2/entity.rb', line 93
def entity_id
@entity_id || xml && xml['entityID']
end
|
Class Method Details
.parse(xml) ⇒ Object
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
# File 'lib/saml2/entity.rb', line 16
def self.parse(xml)
document = Nokogiri::XML(xml)
entities = document.at_xpath("/md:EntitiesDescriptor", Namespaces::ALL)
entity = document.at_xpath("/md:EntityDescriptor", Namespaces::ALL)
if entities
Group.from_xml(entities)
elsif entity
from_xml(entity)
else
nil
end
end
|
Instance Method Details
#build(builder) ⇒ Object
121
122
123
124
125
126
127
128
129
130
131
132
133
134
|
# File 'lib/saml2/entity.rb', line 121
def build(builder)
builder['md'].EntityDescriptor('entityID' => entity_id,
'xmlns:md' => Namespaces::METADATA,
'xmlns:dsig' => Namespaces::DSIG,
'xmlns:xenc' => Namespaces::XENC) do |entity_descriptor|
entity_descriptor.parent['ID'] = id if id
roles.each do |role|
role.build(entity_descriptor)
end
super
end
end
|
#from_xml(node) ⇒ Object
82
83
84
85
86
87
|
# File 'lib/saml2/entity.rb', line 82
def from_xml(node)
super
@id = nil
remove_instance_variable(:@valid_until)
@roles = nil
end
|
#id ⇒ Object
97
98
99
|
# File 'lib/saml2/entity.rb', line 97
def id
@id ||= xml['ID']
end
|
#identity_providers ⇒ Object
108
109
110
|
# File 'lib/saml2/entity.rb', line 108
def identity_providers
roles.select { |r| r.is_a?(IdentityProvider) }
end
|
#roles ⇒ Object
116
117
118
119
|
# File 'lib/saml2/entity.rb', line 116
def roles
@roles ||= load_object_array(xml, 'md:IDPSSODescriptor', IdentityProvider) +
load_object_array(xml, 'md:SPSSODescriptor', ServiceProvider)
end
|
#service_providers ⇒ Object
112
113
114
|
# File 'lib/saml2/entity.rb', line 112
def service_providers
roles.select { |r| r.is_a?(ServiceProvider) }
end
|
#valid_schema? ⇒ Boolean
89
90
91
|
# File 'lib/saml2/entity.rb', line 89
def valid_schema?
Schemas.federation.valid?(xml.document)
end
|
#valid_until ⇒ Object
101
102
103
104
105
106
|
# File 'lib/saml2/entity.rb', line 101
def valid_until
unless instance_variable_defined?(:@valid_until)
@valid_until = xml['validUntil'] && Time.parse(xml['validUntil'])
end
@valid_until
end
|