Sha256: 4b1a2952fefeafc8b6b795aff53f709af571c3bf3478dee08d996b5ee83742cb

Contents?: true

Size: 1.4 KB

Versions: 28

Compression:

Stored size: 1.4 KB

Contents

module GorgonBunny
  # 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 [GorgonBunny::Session]
      attr_reader :session

      # Instantiates a new encoder for the authentication mechanism
      # used by the provided session.
      #
      # @return [GorgonBunny::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

28 entries across 28 versions & 1 rubygems

Version Path
gorgon-0.11.1 lib/gorgon_bunny/lib/gorgon_bunny/authentication/credentials_encoder.rb
gorgon-0.11.0 lib/gorgon_bunny/lib/gorgon_bunny/authentication/credentials_encoder.rb
gorgon-0.10.5 lib/gorgon_bunny/lib/gorgon_bunny/authentication/credentials_encoder.rb
gorgon-0.10.4 lib/gorgon_bunny/lib/gorgon_bunny/authentication/credentials_encoder.rb
gorgon-0.10.3 lib/gorgon_bunny/lib/gorgon_bunny/authentication/credentials_encoder.rb
gorgon-0.10.2 lib/gorgon_bunny/lib/gorgon_bunny/authentication/credentials_encoder.rb
gorgon-0.10.1 lib/gorgon_bunny/lib/gorgon_bunny/authentication/credentials_encoder.rb
gorgon-0.10.0 lib/gorgon_bunny/lib/gorgon_bunny/authentication/credentials_encoder.rb
gorgon-0.9.0 lib/gorgon_bunny/lib/gorgon_bunny/authentication/credentials_encoder.rb
gorgon-0.8.4 lib/gorgon_bunny/lib/gorgon_bunny/authentication/credentials_encoder.rb
gorgon-0.8.3 lib/gorgon_bunny/lib/gorgon_bunny/authentication/credentials_encoder.rb
gorgon-0.8.2 lib/gorgon_bunny/lib/gorgon_bunny/authentication/credentials_encoder.rb
gorgon-0.8.1 lib/gorgon_bunny/lib/gorgon_bunny/authentication/credentials_encoder.rb
gorgon-0.8.0 lib/gorgon_bunny/lib/gorgon_bunny/authentication/credentials_encoder.rb
gorgon-0.7.1 lib/gorgon_bunny/lib/gorgon_bunny/authentication/credentials_encoder.rb
gorgon-0.7.0 lib/gorgon_bunny/lib/gorgon_bunny/authentication/credentials_encoder.rb
gorgon-0.7.0.rc4 lib/gorgon_bunny/lib/gorgon_bunny/authentication/credentials_encoder.rb
gorgon-0.7.0.rc3 lib/gorgon_bunny/lib/gorgon_bunny/authentication/credentials_encoder.rb
gorgon-0.7.0.rc2 lib/gorgon_bunny/lib/gorgon_bunny/authentication/credentials_encoder.rb
gorgon-0.7.0.rc1 lib/gorgon_bunny/lib/gorgon_bunny/authentication/credentials_encoder.rb