summaryrefslogtreecommitdiff
path: root/lib/net/imap.rb
diff options
context:
space:
mode:
authorshugo <shugo@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2000-10-14 14:54:51 +0000
committershugo <shugo@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2000-10-14 14:54:51 +0000
commitbb6d5ce17a8807841e2190dc446fd5e6f63bcc5a (patch)
tree0b954ed3ccfd26e3cc44e1737d81015ce92d836a /lib/net/imap.rb
parentcef64ee0ba659231bec5d7599a4bfacca53352f3 (diff)
*** empty log message ***
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@1004 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/net/imap.rb')
-rw-r--r--lib/net/imap.rb19
1 files changed, 12 insertions, 7 deletions
diff --git a/lib/net/imap.rb b/lib/net/imap.rb
index 3bc3750..4ced8bc 100644
--- a/lib/net/imap.rb
+++ b/lib/net/imap.rb
@@ -27,6 +27,9 @@ Object
: debug = val
Sets the debug mode
+: add_authenticator(auth_type, authenticator)
+ Adds an authenticator for Net::IMAP#authenticate.
+
=== Methods
: greeting
@@ -211,6 +214,10 @@ module Net
return @@debug = val
end
+ def self.add_authenticator(auth_type, authenticator)
+ @@authenticators[auth_type] = authenticator
+ end
+
def disconnect
@sock.close
end
@@ -230,11 +237,11 @@ module Net
def authenticate(auth_type, *args)
auth_type = auth_type.upcase
- unless AUTHENTICATORS.has_key?(auth_type)
+ unless @@authenticators.has_key?(auth_type)
raise ArgumentError,
format('unknown auth type - "%s"', auth_type)
end
- authenticator = AUTHENTICATORS[auth_type].new(*args)
+ authenticator = @@authenticators[auth_type].new(*args)
send_command("AUTHENTICATE", auth_type) do |resp|
if resp.prefix == "+"
data = authenticator.process(resp[0].unpack("m")[0])
@@ -363,6 +370,7 @@ module Net
PORT = 143
@@debug = false
+ @@authenticators = {}
def initialize(host, port = PORT)
@host = host
@@ -1019,6 +1027,7 @@ module Net
@state = STATE_USER
end
end
+ add_authenticator "LOGIN", LoginAuthenticator
class CramMD5Authenticator
def process(challenge)
@@ -1057,11 +1066,7 @@ module Net
return md5.hexdigest
end
end
-
- AUTHENTICATORS = {
- "LOGIN" => LoginAuthenticator,
- "CRAM-MD5" => CramMD5Authenticator
- }
+ add_authenticator "CRAM-MD5", CramMD5Authenticator
class Error < StandardError
end