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.



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

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



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

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

#fetch_attribute(key) ⇒ Object



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

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

#fetch_attributes(key) ⇒ Object



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

def fetch_attributes(key)
  return unless self.attribute_statement
  return unless self.attribute_statement.attribute
  attribute_statement.fetch_attributes(key)
end

#providerSaml::Provider

Returns:



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

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