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.
Instance Method Summary collapse
-
#encode_credentials(username, challenge) ⇒ String
Encodes provided credentials according to the specific authentication mechanism.
-
#initialize(session) ⇒ CredentialsEncoder
constructor
protected
A new instance of CredentialsEncoder.
Constructor Details
#initialize(session) ⇒ CredentialsEncoder (protected)
Returns a new instance of CredentialsEncoder.
49 50 51 |
# File 'lib/bunny/authentication/credentials_encoder.rb', line 49 def initialize(session) @session = session end |
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 |
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 |