Class: SAML2::Attribute
- Inherits:
-
Base
- Object
- Base
- SAML2::Attribute
show all
- Defined in:
- lib/saml2/attribute.rb,
lib/saml2/attribute/x500.rb
Defined Under Namespace
Modules: NameFormats
Classes: X500
Instance Attribute Summary collapse
Attributes inherited from Base
#xml
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Base
#inspect, load_object_array, load_string_array, lookup_qname, #to_s, #to_xml
Constructor Details
#initialize(name = nil, value = nil, friendly_name = nil, name_format = nil) ⇒ Attribute
Returns a new instance of Attribute.
57
58
59
|
# File 'lib/saml2/attribute.rb', line 57
def initialize(name = nil, value = nil, friendly_name = nil, name_format = nil)
@name, @value, @friendly_name, @name_format = name, value, friendly_name, name_format
end
|
Instance Attribute Details
#friendly_name ⇒ Object
Returns the value of attribute friendly_name.
55
56
57
|
# File 'lib/saml2/attribute.rb', line 55
def friendly_name
@friendly_name
end
|
#name ⇒ Object
Returns the value of attribute name.
55
56
57
|
# File 'lib/saml2/attribute.rb', line 55
def name
@name
end
|
Returns the value of attribute name_format.
55
56
57
|
# File 'lib/saml2/attribute.rb', line 55
def name_format
@name_format
end
|
#value ⇒ Object
Returns the value of attribute value.
55
56
57
|
# File 'lib/saml2/attribute.rb', line 55
def value
@value
end
|
Class Method Details
.create(name, value = nil) ⇒ Object
34
35
36
|
# File 'lib/saml2/attribute.rb', line 34
def create(name, value = nil)
(class_for(name) || self).new(name, value)
end
|
.element ⇒ Object
42
43
44
|
# File 'lib/saml2/attribute.rb', line 42
def element
'Attribute'
end
|
.from_xml(node) ⇒ Object
25
26
27
28
29
30
31
32
|
# File 'lib/saml2/attribute.rb', line 25
def from_xml(node)
return super unless self == Attribute
klass = class_for(node)
klass ? klass.from_xml(node) : super
end
|
.inherited(klass) ⇒ Object
21
22
23
|
# File 'lib/saml2/attribute.rb', line 21
def inherited(klass)
subclasses << klass
end
|
.namespace ⇒ Object
38
39
40
|
# File 'lib/saml2/attribute.rb', line 38
def namespace
'saml'
end
|
.subclasses ⇒ Object
17
18
19
|
# File 'lib/saml2/attribute.rb', line 17
def subclasses
@subclasses ||= []
end
|
Instance Method Details
#build(builder) ⇒ Object
61
62
63
64
65
66
67
68
69
70
71
72
|
# File 'lib/saml2/attribute.rb', line 61
def build(builder)
builder[self.class.namespace].__send__(self.class.element, 'Name' => name) do |attribute|
attribute.parent['FriendlyName'] = friendly_name if friendly_name
attribute.parent['NameFormat'] = name_format if name_format
Array.wrap(value).each do |value|
xsi_type, val = convert_to_xsi(value)
attribute['saml'].AttributeValue(val) do |attribute_value|
attribute_value.parent['xsi:type'] = xsi_type if xsi_type
end
end
end
end
|
#from_xml(node) ⇒ Object
74
75
76
77
78
79
80
81
82
83
84
85
86
87
|
# File 'lib/saml2/attribute.rb', line 74
def from_xml(node)
super
@name = node['Name']
@friendly_name = node['FriendlyName']
@name_format = node['NameFormat']
values = node.xpath('saml:AttributeValue', Namespaces::ALL).map do |value|
convert_from_xsi(value.attribute_with_ns('type', Namespaces::XSI), value.content && value.content.strip)
end
@value = case values.length
when 0; nil
when 1; values.first
else; values
end
end
|