class Bunny::Authentication::CredentialsEncoder
Base credentials encoder. Subclasses implement credentials encoding for a particular authentication mechanism (PLAIN, EXTERNAL, etc).
@api plugin
Attributes
Session
that uses this encoder @return [Bunny::Session]
Public Class Methods
Source
# File lib/bunny/authentication/credentials_encoder.rb, line 36 def self.auth_mechanism(*mechanisms) mechanisms.each do |m| registry[m] = self end end
Registers an encoder for authentication mechanism @api plugin
Source
# File lib/bunny/authentication/credentials_encoder.rb, line 25 def self.for_session(session) registry[session.mechanism].new(session) end
Instantiates a new encoder for the authentication mechanism used by the provided session.
@return [Bunny::CredentialsEncoder]
Source
# File lib/bunny/authentication/credentials_encoder.rb, line 51 def initialize(session) @session = session end
Source
# File lib/bunny/authentication/credentials_encoder.rb, line 30 def self.registry @@registry ||= Hash.new { raise NotImplementedError } end
@private
Public Instance Methods
Source
# File lib/bunny/authentication/credentials_encoder.rb, line 45 def encode_credentials(username, challenge) raise NotImplementedError.new("Subclasses must override this method") end
Encodes provided credentials according to the specific authentication mechanism @return [String] Encoded credentials