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

#decrypt, from_xml, #from_xml, #inspect, 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.

Parameters:

  • allow_create (defaults to: nil)

    optional [Boolean]

  • format (defaults to: nil)

    optional [String]

  • sp_name_qualifier (defaults to: nil)

    optional [String]



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

def initialize(allow_create = nil, format = nil, sp_name_qualifier = nil)
  super()
  @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) ⇒ Boolean? (writeonly)

Returns:

  • (Boolean, nil)


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

def allow_create=(value)
  @allow_create = value
end

#formatString?

Returns:

  • (String, nil)

See Also:



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

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

#sp_name_qualifierString?

Returns:

  • (String, nil)


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

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

Instance Method Details

#==(other) ⇒ Boolean

Parameters:

Returns:

  • (Boolean)


61
62
63
64
65
# File 'lib/saml2/name_id.rb', line 61

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

#allow_create?Boolean?

Returns:

  • (Boolean, nil)


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

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

#build(builder) ⇒ void

This method returns an undefined value.

Serialize this object to XML, as part of a larger document

Parameters:

  • builder (Nokogiri::XML::Builder)

    The builder helper object to serialize to.



68
69
70
71
72
73
74
# File 'lib/saml2/name_id.rb', line 68

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