module Net::IMAP::Authenticators
Public Instance Methods
Adds an authenticator for Net::IMAP#authenticate
to use. mechanism
is the SASL mechanism implemented by authenticator
(for instance, "PLAIN"
).
The authenticator
must respond to #new
(or call), receiving the authenticator configuration and return a configured authentication session. The authenticator session must respond to #process
, receiving the server’s challenge and returning the client’s response.
See PlainAuthenticator
, XOauth2Authenticator
, and DigestMD5Authenticator
for examples.
# File net-imap-0.3.7/lib/net/imap/authenticators.rb, line 17 def add_authenticator(auth_type, authenticator) authenticators[auth_type] = authenticator end
Builds a new authentication session context for mechanism
.
- Note
-
This method is intended for internal use by connection protocol code only. Protocol client users should see refer to their client’s documentation, e.g.
Net::IMAP#authenticate
forNet::IMAP
.
The call signatures documented for this method are recommendations for authenticator implementors. All arguments (other than mechanism
) are forwarded to the registered authenticator’s #new
(or #call
) method, and each authenticator must document its own arguments.
The returned object represents a single authentication exchange and must not be reused for multiple authentication attempts.
# File net-imap-0.3.7/lib/net/imap/authenticators.rb, line 42 def authenticator(mechanism, *authargs, **properties, &callback) authenticator = authenticators.fetch(mechanism.upcase) do raise ArgumentError, 'unknown auth type - "%s"' % mechanism end if authenticator.respond_to?(:new) authenticator.new(*authargs, **properties, &callback) else authenticator.call(*authargs, **properties, &callback) end end
Private Instance Methods
# File net-imap-0.3.7/lib/net/imap/authenticators.rb, line 55 def authenticators @authenticators ||= {} end