Class: SAML2::NameID::Policy

Inherits:
Base
  • Object
show all
Defined in:
lib/saml2/name_id.rb

Instance Attribute Summary collapse

Attributes inherited from Base

#xml

Instance Method Summary collapse

Methods inherited from Base

from_xml, #from_xml, load_object_array, load_string_array, lookup_qname, #to_s, #to_xml

Constructor Details

#initialize(allow_create = nil, format = nil, sp_name_qualifier = nil) ⇒ Policy

Returns a new instance of Policy.



19
20
21
22
23
# File 'lib/saml2/name_id.rb', line 19

def initialize(allow_create = nil, format = nil, sp_name_qualifier = nil)
  @allow_create = allow_create if allow_create
  @format = format if format
  @sp_name_qualifier = sp_name_qualifier if sp_name_qualifier
end

Instance Attribute Details

#allow_create=(value) ⇒ Object (writeonly)

Sets the attribute allow_create

Parameters:

  • value

    the value to set the attribute allow_create to.



17
18
19
# File 'lib/saml2/name_id.rb', line 17

def allow_create=(value)
  @allow_create = value
end

#formatObject



32
33
34
35
36
37
# File 'lib/saml2/name_id.rb', line 32

def format
  if xml && !instance_variable_defined?(:@format)
    @format = xml['Format']
  end
  @format
end

#sp_name_qualifierObject



39
40
41
42
43
44
# File 'lib/saml2/name_id.rb', line 39

def sp_name_qualifier
  if xml && !instance_variable_defined?(:@sp_name_qualifier)
    @sp_name_qualifier = xml['SPNameQualifier']
  end
  @sp_name_qualifier
end

Instance Method Details

#==(rhs) ⇒ Object



46
47
48
49
50
# File 'lib/saml2/name_id.rb', line 46

def ==(rhs)
  allow_create? == rhs.allow_create? &&
      format == rhs.format &&
      sp_name_qualifier == rhs.sp_name_qualifier
end

#allow_create?Boolean

Returns:

  • (Boolean)


25
26
27
28
29
30
# File 'lib/saml2/name_id.rb', line 25

def allow_create?
  if xml && !instance_variable_defined?(:@allow_create)
    @allow_create = xml['AllowCreate']&.== 'true'
  end
  @allow_create
end

#build(builder) ⇒ Object



52
53
54
55
56
57
58
# File 'lib/saml2/name_id.rb', line 52

def build(builder)
  builder['samlp'].NameIDPolicy do |name_id_policy|
    name_id_policy.parent['Format'] = format if format
    name_id_policy.parent['SPNameQualifier'] = sp_name_qualifier if sp_name_qualifier
    name_id_policy.parent['AllowCreate'] = allow_create? unless allow_create?.nil?
  end
end