Class: Saml::Assertion

Inherits:
Object
  • Object
show all
Includes:
Base, XMLHelpers
Defined in:
lib/saml/assertion.rb

Instance Method Summary collapse

Methods included from XMLHelpers

#add_signature, #to_soap, #to_xml

Constructor Details

#initialize(*args) ⇒ Assertion

Returns a new instance of Assertion.



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/saml/assertion.rb', line 31

def initialize(*args)
  options          = args.extract_options!
  @subject         = Saml::Elements::Subject.new(:name_id        => options.delete(:name_id),
                                                 :name_id_format => options.delete(:name_id_format),
                                                 :recipient      => options.delete(:recipient),
                                                 :in_response_to => options.delete(:in_response_to))
  @conditions      = Saml::Elements::Conditions.new(:audience => options.delete(:audience))
  @authn_statement = Saml::Elements::AuthnStatement.new(:authn_instant           => Time.now,
                                                        :address                 => options.delete(:address),
                                                        :authn_context_class_ref => options.delete(:authn_context_class_ref),
                                                        :session_index           => options.delete(:session_index))
  super(*(args << options))
  @_id           ||= Saml.generate_id
  @issue_instant ||= Time.now
  @issuer        ||= Saml.current_provider.entity_id
  @version       ||= Saml::SAML_VERSION
end

Instance Method Details

#add_attribute(key, value) ⇒ Object



54
55
56
57
58
# File 'lib/saml/assertion.rb', line 54

def add_attribute(key, value)
  self.attribute_statement ||= Saml::Elements::AttributeStatement.new
  self.attribute_statement.attribute ||= []
  self.attribute_statement.attribute << Saml::Elements::Attribute.new(name: key, attribute_value: value)
end

#attribute_statementObject



70
71
72
# File 'lib/saml/assertion.rb', line 70

def attribute_statement
  attribute_statements.try(:first)
end

#attribute_statement=(attribute_statement) ⇒ Object



74
75
76
# File 'lib/saml/assertion.rb', line 74

def attribute_statement=(attribute_statement)
  self.attribute_statements = [attribute_statement]
end

#fetch_attribute(key) ⇒ Object



60
61
62
# File 'lib/saml/assertion.rb', line 60

def fetch_attribute(key)
  fetch_attributes(key).first if fetch_attributes(key)
end

#fetch_attributes(key) ⇒ Object



64
65
66
67
68
# File 'lib/saml/assertion.rb', line 64

def fetch_attributes(key)
  return unless self.attribute_statements
  return unless self.attribute_statements.flat_map(&:attribute)
  attribute_statements.flat_map { |attribute_statement| attribute_statement.fetch_attributes(key) }
end

#providerSaml::Provider

Returns:



50
51
52
# File 'lib/saml/assertion.rb', line 50

def provider
  @provider ||= Saml.provider(issuer)
end