Class: SAML2::Entity
Defined Under Namespace
Classes: Group
Instance Attribute Summary collapse
#contacts, #organization
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Base
#from_xml, load_object_array, load_string_array, #to_s, #to_xml
Constructor Details
#initialize(root = nil) ⇒ Entity
Returns a new instance of Entity.
50
51
52
53
54
55
56
|
# File 'lib/saml2/entity.rb', line 50
def initialize(root = nil)
super
@root = root
unless @root
@roles = []
end
end
|
Instance Attribute Details
#entity_id ⇒ Object
62
63
64
|
# File 'lib/saml2/entity.rb', line 62
def entity_id
@entity_id || @root && @root['entityID']
end
|
Class Method Details
.from_xml(node) ⇒ Object
46
47
48
|
# File 'lib/saml2/entity.rb', line 46
def self.from_xml(node)
node && new(node)
end
|
.parse(xml) ⇒ Object
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
# File 'lib/saml2/entity.rb', line 14
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
71
72
73
74
75
76
77
78
79
80
81
82
|
# File 'lib/saml2/entity.rb', line 71
def build(builder)
builder['md'].EntityDescriptor('entityID' => entity_id,
'xmlns:md' => Namespaces::METADATA,
'xmlns:dsig' => Namespaces::DSIG,
'xmlns:xenc' => Namespaces::XENC) do |builder|
roles.each do |role|
role.build(builder)
end
super
end
end
|
#roles ⇒ Object
66
67
68
69
|
# File 'lib/saml2/entity.rb', line 66
def roles
@roles ||= load_object_array(@root, 'md:SPSSODescriptor', ServiceProvider)
end
|
#valid_schema? ⇒ Boolean
58
59
60
|
# File 'lib/saml2/entity.rb', line 58
def valid_schema?
Schemas.metadata.valid?(@root.document)
end
|