From bb6d5ce17a8807841e2190dc446fd5e6f63bcc5a Mon Sep 17 00:00:00 2001 From: shugo Date: Sat, 14 Oct 2000 14:54:51 +0000 Subject: *** empty log message *** git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@1004 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- lib/net/imap.rb | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'lib') diff --git a/lib/net/imap.rb b/lib/net/imap.rb index 3bc3750e12..4ced8bcf02 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 -- cgit v1.2.3