Class: Saml::Kit::Builders::Response

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

Overview

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from XmlTemplatable

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

Constructor Details

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

Returns a new instance of Response.



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

def initialize(user, request, configuration: Saml::Kit.configuration)
  @user = user
  @request = request
  @id = ::Xml::Kit::Id.generate
  @reference_id = ::Xml::Kit::Id.generate
  @now = Time.now.utc
  @version = '2.0'
  @status_code = Namespaces::SUCCESS
  @issuer = configuration.entity_id
  @encryption_certificate = request.try(:provider).try(:encryption_certificates).try(:last)
  @encrypt = encryption_certificate.present?
  @configuration = configuration
end

Instance Attribute Details

#configurationObject (readonly)

Returns the value of attribute configuration.



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

def configuration
  @configuration
end

#destinationObject

Returns the value of attribute destination.



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

def destination
  @destination
end

#idObject

Returns the value of attribute id.



9
10
11
# File 'lib/saml/kit/builders/response.rb', line 9

def id
  @id
end

#issuerObject

Returns the value of attribute issuer.



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

def issuer
  @issuer
end

#nowObject

Returns the value of attribute now.



9
10
11
# File 'lib/saml/kit/builders/response.rb', line 9

def now
  @now
end

#reference_idObject

Returns the value of attribute reference_id.



9
10
11
# File 'lib/saml/kit/builders/response.rb', line 9

def reference_id
  @reference_id
end

#requestObject (readonly)

Returns the value of attribute request.



8
9
10
# File 'lib/saml/kit/builders/response.rb', line 8

def request
  @request
end

#status_codeObject

Returns the value of attribute status_code.



10
11
12
# File 'lib/saml/kit/builders/response.rb', line 10

def status_code
  @status_code
end

#userObject (readonly)

Returns the value of attribute user.



8
9
10
# File 'lib/saml/kit/builders/response.rb', line 8

def user
  @user
end

#versionObject

Returns the value of attribute version.



10
11
12
# File 'lib/saml/kit/builders/response.rb', line 10

def version
  @version
end

Instance Method Details

#assertionObject



32
33
34
35
36
37
38
39
40
41
42
# File 'lib/saml/kit/builders/response.rb', line 32

def assertion
  @assertion ||=
    begin
      assertion = Saml::Kit::Builders::Assertion.new(self, embed_signature)
      if encrypt
        Saml::Kit::Builders::EncryptedAssertion.new(self, assertion)
      else
        assertion
      end
    end
end

#buildObject



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

def build
  Saml::Kit::Response.new(to_xml, request_id: request.id, configuration: configuration)
end