Class: SAML2::NameID

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

Defined Under Namespace

Modules: Format Classes: Policy

Instance Attribute Summary collapse

Attributes inherited from Base

#xml

Instance Method Summary collapse

Methods inherited from Base

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

Constructor Details

#initialize(id = nil, format = nil, name_qualifier: nil, sp_name_qualifier: nil) ⇒ NameID

Returns a new instance of NameID.

Parameters:

  • id (String) (defaults to: nil)
  • format (defaults to: nil)

    optional [String]

  • name_qualifier (defaults to: nil)

    optional [String]

  • sp_name_qualifier (defaults to: nil)

    optional [String]


93
94
95
96
# File 'lib/saml2/name_id.rb', line 93

def initialize(id = nil, format = nil, name_qualifier: nil, sp_name_qualifier: nil)
  @id, @format, @name_qualifier, @sp_name_qualifier =
      id, format, name_qualifier, sp_name_qualifier
end

Instance Attribute Details

#formatString?

Returns:

  • (String, nil)

79
80
81
# File 'lib/saml2/name_id.rb', line 79

def format
  @format
end

#idString

Returns:

  • (String)

77
78
79
# File 'lib/saml2/name_id.rb', line 77

def id
  @id
end

#name_qualifierString?

Returns:

  • (String, nil)

79
80
81
# File 'lib/saml2/name_id.rb', line 79

def name_qualifier
  @name_qualifier
end

#sp_name_qualifierString?

Returns:

  • (String, nil)

79
80
81
# File 'lib/saml2/name_id.rb', line 79

def sp_name_qualifier
  @sp_name_qualifier
end

Instance Method Details

#==(rhs) ⇒ Boolean

Parameters:

Returns:

  • (Boolean)

100
101
102
103
104
105
# File 'lib/saml2/name_id.rb', line 100

def ==(rhs)
  id == rhs.id &&
      format == rhs.format &&
      name_qualifier == rhs.name_qualifier &&
      sp_name_qualifier == rhs.sp_name_qualifier
end

#build(builder, element: nil) ⇒ 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.


108
109
110
111
112
113
114
# File 'lib/saml2/name_id.rb', line 108

def build(builder, element: nil)
  args = {}
  args['Format'] = format if format
  args['NameQualifier'] = name_qualifier if name_qualifier
  args['SPNameQualifier'] = sp_name_qualifier if sp_name_qualifier
  builder['saml'].__send__(element || 'NameID', id, args)
end

#from_xml(node) ⇒ void

This method returns an undefined value.

Parse an XML element into this object.

Parameters:

  • node (Nokogiri::XML::Element)

82
83
84
85
86
87
# File 'lib/saml2/name_id.rb', line 82

def from_xml(node)
  self.id = node.content.strip
  self.format = node['Format']
  self.name_qualifier = node['NameQualifier']
  self.sp_name_qualifier = node['SPNameQualifier']
end