Class: Saml::Kit::Builders::Assertion

Inherits:
Object
  • Object
show all
Includes:
XmlTemplatable
Defined in:
lib/saml/kit/builders/assertion.rb

Overview

This class is responsible for building a SAML Assertion

Constant Summary

Constants included from XmlTemplatable

XmlTemplatable::TEMPLATES_DIR

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from XmlTemplatable

#digest_method, #sign?, #signature_method, #signing_key_pair, #template_name, #template_path

Constructor Details

#initialize(user, request, configuration: Saml::Kit.configuration) ⇒ Assertion

Returns a new instance of Assertion


17
18
19
20
21
22
23
24
25
26
# File 'lib/saml/kit/builders/assertion.rb', line 17

def initialize(user, request, configuration: Saml::Kit.configuration)
  @user = user
  @request = request
  @configuration = configuration
  @issuer = configuration.entity_id
  @reference_id = ::Xml::Kit::Id.generate
  @version = '2.0'
  @now = Time.now.utc
  self.default_name_id_format = Saml::Kit::Namespaces::UNSPECIFIED_NAMEID
end

Instance Attribute Details

#configurationObject (readonly)

Returns the value of attribute configuration


11
12
13
# File 'lib/saml/kit/builders/assertion.rb', line 11

def configuration
  @configuration
end

#default_name_id_formatObject

Returns the value of attribute default_name_id_format


15
16
17
# File 'lib/saml/kit/builders/assertion.rb', line 15

def default_name_id_format
  @default_name_id_format
end

#destinationObject

Returns the value of attribute destination


13
14
15
# File 'lib/saml/kit/builders/assertion.rb', line 13

def destination
  @destination
end

#issuerObject

Returns the value of attribute issuer


14
15
16
# File 'lib/saml/kit/builders/assertion.rb', line 14

def issuer
  @issuer
end

#nowObject

Returns the value of attribute now


13
14
15
# File 'lib/saml/kit/builders/assertion.rb', line 13

def now
  @now
end

#reference_idObject

Returns the value of attribute reference_id


12
13
14
# File 'lib/saml/kit/builders/assertion.rb', line 12

def reference_id
  @reference_id
end

#requestObject (readonly)

Returns the value of attribute request


11
12
13
# File 'lib/saml/kit/builders/assertion.rb', line 11

def request
  @request
end

#userObject (readonly)

Returns the value of attribute user


11
12
13
# File 'lib/saml/kit/builders/assertion.rb', line 11

def user
  @user
end

#versionObject

Returns the value of attribute version


14
15
16
# File 'lib/saml/kit/builders/assertion.rb', line 14

def version
  @version
end

Instance Method Details

#assertion_attributesObject


36
37
38
39
40
# File 'lib/saml/kit/builders/assertion.rb', line 36

def assertion_attributes
  return {} unless user.respond_to?(:assertion_attributes_for)

  user.assertion_attributes_for(request)
end

#buildObject


42
43
44
# File 'lib/saml/kit/builders/assertion.rb', line 42

def build
  Saml::Kit::Assertion.new(to_xml, configuration: configuration)
end

#name_idObject


32
33
34
# File 'lib/saml/kit/builders/assertion.rb', line 32

def name_id
  user.name_id_for(name_id_format)
end

#name_id_formatObject


28
29
30
# File 'lib/saml/kit/builders/assertion.rb', line 28

def name_id_format
  request.try(:name_id_format)
end