123456789_123456789_123456789_123456789_123456789_

Module: Net::IMAP::Authenticators

Relationships & Source Files
Extension / Inclusion / Inheritance Descendants
Extended In:
Defined in: lib/net/imap/authenticators.rb

Overview

Registry for SASL authenticators used by ::Net::IMAP.

Instance Method Summary

Instance Method Details

#add_authenticator(auth_type, authenticator)

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 PlainAuthenticator, LoginAuthenticator, CramMD5Authenticator, and DigestMD5Authenticator for examples.

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

[ GitHub ]

  
# File 'lib/net/imap/authenticators.rb', line 16

def add_authenticator(auth_type, authenticator)
  authenticators[auth_type] = authenticator
end

#authenticator(auth_type, *args)

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

[ GitHub ]

  
# File 'lib/net/imap/authenticators.rb', line 22

def authenticator(auth_type, *args)
  auth_type = auth_type.upcase
  unless authenticators.has_key?(auth_type)
    raise ArgumentError,
      format('unknown auth type - "%s"', auth_type)
  end
  authenticators[auth_type].new(*args)
end

#authenticators (private)

[ GitHub ]

  
# File 'lib/net/imap/authenticators.rb', line 33

def authenticators
  @authenticators ||= {}
end