Sha256: e82fb8222a6dde80ed56d9e5c7e2f80036ef58eb0037fcc0f71de4512cba84ad

Contents?: true

Size: 1.48 KB

Versions: 10

Compression:

Stored size: 1.48 KB

Contents

# frozen_string_literal: true

module Saml
  module Kit
    module Bindings
      # This class is a base class for SAML bindings.
      # {include:file:spec/saml/kit/bindings/binding_spec.rb}
      class Binding
        attr_reader :binding, :location

        def initialize(binding:, location:)
          @binding = binding
          @location = location
        end

        def binding?(other)
          binding == other
        end

        def serialize(*)
          []
        end

        def deserialize(_params)
          raise ArgumentError, 'Unsupported binding'
        end

        def to_h
          { binding: binding, location: location }
        end

        def ==(other)
          to_s == other.to_s
        end

        def eql?(other)
          self == other
        end

        def hash
          to_s.hash
        end

        def to_s
          "#{location}#{binding}"
        end

        def inspect
          to_h.inspect
        end

        protected

        def saml_param_from(params)
          parameters = {
            SAMLRequest: params[:SAMLRequest] || params['SAMLRequest'],
            SAMLResponse: params[:SAMLResponse] || params['SAMLResponse'],
          }
          return parameters[:SAMLRequest] if parameters[:SAMLRequest].present?
          return parameters[:SAMLResponse] if parameters[:SAMLResponse].present?

          message = 'SAMLRequest or SAMLResponse parameter is required.'
          raise ArgumentError, message
        end
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
saml-kit-1.3.0 lib/saml/kit/bindings/binding.rb
saml-kit-1.2.0 lib/saml/kit/bindings/binding.rb
saml-kit-1.1.0 lib/saml/kit/bindings/binding.rb
saml-kit-1.0.31 lib/saml/kit/bindings/binding.rb
saml-kit-1.0.30 lib/saml/kit/bindings/binding.rb
saml-kit-1.0.29 lib/saml/kit/bindings/binding.rb
saml-kit-1.0.28 lib/saml/kit/bindings/binding.rb
saml-kit-1.0.27 lib/saml/kit/bindings/binding.rb
saml-kit-1.0.26 lib/saml/kit/bindings/binding.rb
saml-kit-1.0.25 lib/saml/kit/bindings/binding.rb