Class: Saml2::Assertion

Inherits:
Object
  • Object
show all
Extended by:
Parsing
Defined in:
lib/saml2/assertion.rb

Defined Under Namespace

Modules: Parsing

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Parsing

each_attribute_node_from, item

Constructor Details

#initialize(issuer, subject_name_id, attributes) ⇒ Assertion

Returns a new instance of Assertion.



79
80
81
82
83
# File 'lib/saml2/assertion.rb', line 79

def initialize(issuer, subject_name_id, attributes)
  @issuer = issuer
  @subject_name_id = subject_name_id
  @attributes = attributes
end

Instance Attribute Details

#issuerObject (readonly)

Returns the value of attribute issuer.



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

def issuer
  @issuer
end

#subject_name_idObject (readonly)

Returns the value of attribute subject_name_id.



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

def subject_name_id
  @subject_name_id
end

Class Method Details

.loggerObject



52
53
54
# File 'lib/saml2/assertion.rb', line 52

def self.logger
  SamlSp.logger
end

.new_from_artifact(artifact) ⇒ Saml2::Assertion

Resolves an artifact into the Assertion it represents

Parameters:

Returns:



41
42
43
44
45
46
47
48
49
50
# File 'lib/saml2/assertion.rb', line 41

def self.new_from_artifact(artifact)
  artifact = if artifact.respond_to? :resolve
               artifact
             else
               Type4Artifact.new_from_string(artifact)
             end
  

  artifact.resolve
end

.new_from_xml(xml_assertion) ⇒ Object



56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/saml2/assertion.rb', line 56

def self.new_from_xml(xml_assertion)
  doc = case xml_assertion
        when Nokogiri::XML::Node
          xml_assertion
        else
          Nokogiri::XML.parse(xml_assertion)
        end
  logger.debug {"Parsing assertion: \n" + doc.to_xml(:indent => 2).gsub(/^/, "\t")}


  doc.root.add_namespace_definition('asrt', 'urn:oasis:names:tc:SAML:2.0:assertion')

  attrs = Hash.new
  each_attribute_node_from(doc) do |node|
    attrs[attribute_name_from(node)] = attribute_value_from(node)
  end

  new(issuer_from(doc), subject_name_id_from(doc), attrs)
      
end

Instance Method Details

#[](attr_name) ⇒ Object



85
86
87
# File 'lib/saml2/assertion.rb', line 85

def [](attr_name)
  attributes[attr_name.to_s]
end