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

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

Overview

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 = nil, configuration: Saml::Kit.configuration) ⇒ Response

Returns a new instance of Response.



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/saml/kit/builders/response.rb', line 16

def initialize(
  user, request = nil, configuration: Saml::Kit.configuration
)
  @user = user
  @request = request
  @id = ::Xml::Kit::Id.generate
  @now = Time.now.utc
  @version = '2.0'
  @status_code = Namespaces::SUCCESS
  @status_message = nil
  @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.



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

def configuration
  @configuration
end

#destinationObject

Returns the value of attribute destination.



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

def destination
  @destination
end

#idObject

Returns the value of attribute id.



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

def id
  @id
end

#issuerObject

Returns the value of attribute issuer.



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

def issuer
  @issuer
end

#nowObject

Returns the value of attribute now.



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

def now
  @now
end

#requestObject (readonly)

Returns the value of attribute request.



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

def request
  @request
end

#status_codeObject

Returns the value of attribute status_code.



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

def status_code
  @status_code
end

#status_messageObject

Returns the value of attribute status_message.



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

def status_message
  @status_message
end

#userObject (readonly)

Returns the value of attribute user.



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

def user
  @user
end

#versionObject

Returns the value of attribute version.



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

def version
  @version
end

Instance Method Details

#assertionObject



45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/saml/kit/builders/response.rb', line 45

def assertion
  @assertion ||=
    begin
      assertion = Assertion.new(user, request, configuration: configuration)
      assertion.sign_with(@signing_key_pair) if @signing_key_pair
      assertion.embed_signature = embed_signature unless embed_signature.nil?
      assertion.now = now
      assertion.destination = destination
      assertion.issuer = issuer
      encrypt ? EncryptedAssertion.new(self, assertion) : assertion
    end
end

#assertion=(value) ⇒ Object



41
42
43
# File 'lib/saml/kit/builders/response.rb', line 41

def assertion=(value)
  @assertion = value || Null.new
end

#buildObject



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

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