module Net::IMAP::Authenticators

Registry for SASL authenticators used by Net::IMAP.

Public Instance Methods

add_authenticator(auth_type, authenticator) click to toggle source

Adds an authenticator for use with Net::IMAP#authenticate. auth_type is the SASL mechanism supported by authenticator (for instance, “PLAIN”). The authenticator is an object which defines a #process method to handle authentication with the server. See Net::IMAP::PlainAuthenticator, Net::IMAP::LoginAuthenticator, Net::IMAP::CramMD5Authenticator, and Net::IMAP::DigestMD5Authenticator for examples.

If auth_type refers to an existing authenticator, it will be replaced by the new one.

# File net-imap-0.3.1/lib/net/imap/authenticators.rb, line 16
def add_authenticator(auth_type, authenticator)
  authenticators[auth_type] = authenticator
authenticator(mechanism, *authargs, **properties, &callback) click to toggle source

Builds an authenticator for Net::IMAP#authenticate. args will be passed directly to the chosen authenticator’s #initialize.

# File net-imap-0.3.1/lib/net/imap/authenticators.rb, line 22
def authenticator(mechanism, *authargs, **properties, &callback)
  authenticator = authenticators.fetch(mechanism.upcase) do
    raise ArgumentError, 'unknown auth type - "%s"' % mechanism
  if authenticator.respond_to?(:new)*authargs, **properties, &callback)
  else*authargs, **properties, &callback)