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.
51 52 53 |
# File 'lib/bunny/authentication/credentials_encoder.rb', line 51 def initialize(session) @session = session end |
Instance Attribute Details
#session ⇒ Bunny::Session (readonly)
Session that uses this encoder
19 20 21 |
# File 'lib/bunny/authentication/credentials_encoder.rb', line 19 def session @session end |
Class Method Details
.auth_mechanism(*mechanisms) ⇒ Object
Registers an encoder for authentication mechanism
36 37 38 39 40 |
# File 'lib/bunny/authentication/credentials_encoder.rb', line 36 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.
25 26 27 |
# File 'lib/bunny/authentication/credentials_encoder.rb', line 25 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
45 46 47 |
# File 'lib/bunny/authentication/credentials_encoder.rb', line 45 def encode_credentials(username, challenge) raise NotImplementedError.new("Subclasses must override this method") end |