Sha256: cda009d12000dfa418af15395d1139f54b9ab110b59d38fe2856ca523dad8160

Contents?: true

Size: 1.38 KB

Versions: 126

Compression:

Stored size: 1.38 KB

Contents

module Bunny
  # Contains credentials encoding implementations for various
  # authentication strategies.
  module Authentication
    # Base credentials encoder. Subclasses implement credentials encoding for
    # a particular authentication mechanism (PLAIN, EXTERNAL, etc).
    #
    # @api plugin
    class CredentialsEncoder

      #
      # API
      #

      # Session that uses this encoder
      # @return [Bunny::Session]
      attr_reader :session

      # Instantiates a new encoder for the authentication mechanism
      # used by the provided session.
      #
      # @return [Bunny::CredentialsEncoder]
      def self.for_session(session)
        registry[session.mechanism].new(session)
      end

      # @private
      def self.registry
        @@registry ||= Hash.new { raise NotImplementedError }
      end

      # Registers an encoder for authentication mechanism
      # @api plugin
      def self.auth_mechanism(*mechanisms)
        mechanisms.each do |m|
          registry[m] = self
        end
      end

      # Encodes provided credentials according to the specific authentication
      # mechanism
      # @return [String] Encoded credentials
      def encode_credentials(username, challenge)
        raise NotImplementedError.new("Subclasses must override this method")
      end

      protected

      def initialize(session)
        @session = session
      end

    end
  end
end

Version data entries

126 entries across 126 versions & 2 rubygems

Version Path
bunny-2.23.0 lib/bunny/authentication/credentials_encoder.rb
bunny-2.22.0 lib/bunny/authentication/credentials_encoder.rb
bunny-2.21.0 lib/bunny/authentication/credentials_encoder.rb
bunny-2.20.3 lib/bunny/authentication/credentials_encoder.rb
bunny-2.20.2 lib/bunny/authentication/credentials_encoder.rb
bunny-2.20.1 lib/bunny/authentication/credentials_encoder.rb
bunny-2.20.0 lib/bunny/authentication/credentials_encoder.rb
garaio_bunny-2.19.2 lib/bunny/authentication/credentials_encoder.rb
garaio_bunny-2.19.1 lib/bunny/authentication/credentials_encoder.rb
bunny-2.19.0 lib/bunny/authentication/credentials_encoder.rb
bunny-2.18.0 lib/bunny/authentication/credentials_encoder.rb
bunny-2.17.0 lib/bunny/authentication/credentials_encoder.rb
bunny-2.16.1 lib/bunny/authentication/credentials_encoder.rb
bunny-2.15.0 lib/bunny/authentication/credentials_encoder.rb
bunny-2.14.4 lib/bunny/authentication/credentials_encoder.rb
bunny-2.14.3 lib/bunny/authentication/credentials_encoder.rb
bunny-2.14.2 lib/bunny/authentication/credentials_encoder.rb
bunny-2.14.1 lib/bunny/authentication/credentials_encoder.rb
bunny-2.13.0 lib/bunny/authentication/credentials_encoder.rb
bunny-2.12.1 lib/bunny/authentication/credentials_encoder.rb