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]



94
95
96
97
98
99
100
# File 'lib/saml2/name_id.rb', line 94

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

Instance Attribute Details

#formatString?

Returns:

  • (String, nil)


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

def format
  @format
end

#idString

Returns:

  • (String)


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

def id
  @id
end

#name_qualifierString?

Returns:

  • (String, nil)


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

def name_qualifier
  @name_qualifier
end

#sp_name_qualifierString?

Returns:

  • (String, nil)


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

def sp_name_qualifier
  @sp_name_qualifier
end

Instance Method Details

#==(other) ⇒ Boolean

Parameters:

Returns:

  • (Boolean)


104
105
106
107
108
109
# File 'lib/saml2/name_id.rb', line 104

def ==(other)
  id == other.id &&
    format == other.format &&
    name_qualifier == other.name_qualifier &&
    sp_name_qualifier == other.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.



112
113
114
115
116
117
118
# File 'lib/saml2/name_id.rb', line 112

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)


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

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