Sha256: fbe4bd1c4fd391c8cc40c6446f2d7d9234036d1326917ceb4a7b82419237b155

Contents?: true

Size: 1.72 KB

Versions: 8

Compression:

Stored size: 1.72 KB

Contents

module Saml
  module Kit
    module Builders
      class Response
        include Templatable
        attr_reader :user, :request
        attr_accessor :id, :reference_id, :now
        attr_accessor :version, :status_code
        attr_accessor :issuer, :destination, :encrypt
        attr_reader :configuration

        def initialize(user, request, configuration: Saml::Kit.configuration)
          @user = user
          @request = request
          @id = Id.generate
          @reference_id = Id.generate
          @now = Time.now.utc
          @version = "2.0"
          @status_code = Namespaces::SUCCESS
          @issuer = configuration.issuer
          @embed_signature = want_assertions_signed
          @encrypt = encryption_certificate.present?
          @configuration = configuration
        end

        def want_assertions_signed
          request.provider.want_assertions_signed
        rescue => error
          Saml::Kit.logger.error(error)
          nil
        end

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

        def encryption_certificate
          request.provider.encryption_certificates.first
        rescue => error
          Saml::Kit.logger.error(error)
          nil
        end

        private

        def assertion
          @assertion ||= Saml::Kit::Builders::Assertion.new(self)
        end

        def response_options
          {
            ID: id,
            Version: version,
            IssueInstant: now.iso8601,
            Destination: destination,
            Consent: Namespaces::UNSPECIFIED,
            InResponseTo: request.id,
            xmlns: Namespaces::PROTOCOL,
          }
        end
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
saml-kit-0.2.14 lib/saml/kit/builders/response.rb
saml-kit-0.2.13 lib/saml/kit/builders/response.rb
saml-kit-0.2.12 lib/saml/kit/builders/response.rb
saml-kit-0.2.11 lib/saml/kit/builders/response.rb
saml-kit-0.2.10 lib/saml/kit/builders/response.rb
saml-kit-0.2.9 lib/saml/kit/builders/response.rb
saml-kit-0.2.8 lib/saml/kit/builders/response.rb
saml-kit-0.2.7 lib/saml/kit/builders/response.rb