Class: AMQP::AuthMechanismAdapter

Inherits:
Object
  • Object
show all
Defined in:
lib/amqp/auth_mechanism_adapter.rb

Overview

Provides a flexible method for encoding AMQP credentials. PLAIN and EXTERNAL are provided by this gem. In order to implement a new authentication mechanism, create a subclass like so:

class MyAuthMechanism < AMQP::Async::AuthMechanismAdapter auth_mechanism “X-MYAUTH” def encode_credentials(username, password)
  1. … end end

Direct Known Subclasses

External, Plain

Defined Under Namespace

Classes: External, Plain

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#adapterObject (readonly)

The Adapter that this AuthMechanismAdapter operates on behalf of.


52
53
54
# File 'lib/amqp/auth_mechanism_adapter.rb', line 52

def adapter
  @adapter
end

Class Method Details

.auth_mechanism(*mechanisms) ⇒ Object (protected)

Used by subclasses to declare the mechanisms that an AuthMechanismAdapter understands.

Parameters:

  • mechanisms (Array<String>)

    One or more mechanisms that can be handled by the subclass.


35
36
37
# File 'lib/amqp/auth_mechanism_adapter.rb', line 35

def self.auth_mechanism(*mechanisms)
  mechanisms.each {|mechanism| registry[mechanism] = self}
end

.for_adapter(adapter) ⇒ AuthMechanismAdapter

Find and instantiate an AuthMechanismAdapter.

Parameters:

  • adapter (Adapter)

    The Adapter for which to encode credentials.

Returns:

Raises:

  • (NotImplementedError)

    The Adapter’s mechanism does not correspond to any known AuthMechanismAdapter.


24
25
26
# File 'lib/amqp/auth_mechanism_adapter.rb', line 24

def self.for_adapter(adapter)
  registry[adapter.mechanism].new adapter
end