Class: Bunny::Authentication::CredentialsEncoder
- Inherits:
-
Object
- Object
- Bunny::Authentication::CredentialsEncoder
- Defined in:
- lib/bunny/authentication/credentials_encoder.rb
Overview
Base credentials encoder. Subclasses implement credentials encoding for a particular authentication mechanism (PLAIN, EXTERNAL, etc).
Direct Known Subclasses
Instance Attribute Summary collapse
-
#session ⇒ Bunny::Session
readonly
Session that uses this encoder.
Class Method Summary collapse
-
.auth_mechanism(*mechanisms) ⇒ Object
Registers an encoder for authentication mechanism.
-
.for_session(session) ⇒ Bunny::CredentialsEncoder
Instantiates a new encoder for the authentication mechanism used by the provided session.
- .registry ⇒ Object
Instance Method Summary collapse
-
#encode_credentials(username, challenge) ⇒ String
Encodes provided credentials according to the specific authentication mechanism.
Instance Attribute Details
#session ⇒ Bunny::Session (readonly)
Session that uses this encoder
17 18 19 |
# File 'lib/bunny/authentication/credentials_encoder.rb', line 17 def session @session end |
Class Method Details
.auth_mechanism(*mechanisms) ⇒ Object
Registers an encoder for authentication mechanism
34 35 36 37 38 |
# File 'lib/bunny/authentication/credentials_encoder.rb', line 34 def self.auth_mechanism(*mechanisms) mechanisms.each do |m| registry[m] = self end end |
.for_session(session) ⇒ Bunny::CredentialsEncoder
Instantiates a new encoder for the authentication mechanism used by the provided session.
23 24 25 |
# File 'lib/bunny/authentication/credentials_encoder.rb', line 23 def self.for_session(session) registry[session.mechanism].new(session) end |
.registry ⇒ Object
28 29 30 |
# File 'lib/bunny/authentication/credentials_encoder.rb', line 28 def self.registry @@registry ||= Hash.new { raise NotImplementedError } end |
Instance Method Details
#encode_credentials(username, challenge) ⇒ String
Encodes provided credentials according to the specific authentication mechanism
43 44 45 |
# File 'lib/bunny/authentication/credentials_encoder.rb', line 43 def encode_credentials(username, challenge) raise NotImplementedError.new("Subclasses must override this method") end |