*** empty log message ***
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@1004 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
cef64ee0ba
commit
bb6d5ce17a
@ -27,6 +27,9 @@ Object
|
|||||||
: debug = val
|
: debug = val
|
||||||
Sets the debug mode
|
Sets the debug mode
|
||||||
|
|
||||||
|
: add_authenticator(auth_type, authenticator)
|
||||||
|
Adds an authenticator for Net::IMAP#authenticate.
|
||||||
|
|
||||||
=== Methods
|
=== Methods
|
||||||
|
|
||||||
: greeting
|
: greeting
|
||||||
@ -211,6 +214,10 @@ module Net
|
|||||||
return @@debug = val
|
return @@debug = val
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.add_authenticator(auth_type, authenticator)
|
||||||
|
@@authenticators[auth_type] = authenticator
|
||||||
|
end
|
||||||
|
|
||||||
def disconnect
|
def disconnect
|
||||||
@sock.close
|
@sock.close
|
||||||
end
|
end
|
||||||
@ -230,11 +237,11 @@ module Net
|
|||||||
|
|
||||||
def authenticate(auth_type, *args)
|
def authenticate(auth_type, *args)
|
||||||
auth_type = auth_type.upcase
|
auth_type = auth_type.upcase
|
||||||
unless AUTHENTICATORS.has_key?(auth_type)
|
unless @@authenticators.has_key?(auth_type)
|
||||||
raise ArgumentError,
|
raise ArgumentError,
|
||||||
format('unknown auth type - "%s"', auth_type)
|
format('unknown auth type - "%s"', auth_type)
|
||||||
end
|
end
|
||||||
authenticator = AUTHENTICATORS[auth_type].new(*args)
|
authenticator = @@authenticators[auth_type].new(*args)
|
||||||
send_command("AUTHENTICATE", auth_type) do |resp|
|
send_command("AUTHENTICATE", auth_type) do |resp|
|
||||||
if resp.prefix == "+"
|
if resp.prefix == "+"
|
||||||
data = authenticator.process(resp[0].unpack("m")[0])
|
data = authenticator.process(resp[0].unpack("m")[0])
|
||||||
@ -363,6 +370,7 @@ module Net
|
|||||||
PORT = 143
|
PORT = 143
|
||||||
|
|
||||||
@@debug = false
|
@@debug = false
|
||||||
|
@@authenticators = {}
|
||||||
|
|
||||||
def initialize(host, port = PORT)
|
def initialize(host, port = PORT)
|
||||||
@host = host
|
@host = host
|
||||||
@ -1019,6 +1027,7 @@ module Net
|
|||||||
@state = STATE_USER
|
@state = STATE_USER
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
add_authenticator "LOGIN", LoginAuthenticator
|
||||||
|
|
||||||
class CramMD5Authenticator
|
class CramMD5Authenticator
|
||||||
def process(challenge)
|
def process(challenge)
|
||||||
@ -1057,11 +1066,7 @@ module Net
|
|||||||
return md5.hexdigest
|
return md5.hexdigest
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
add_authenticator "CRAM-MD5", CramMD5Authenticator
|
||||||
AUTHENTICATORS = {
|
|
||||||
"LOGIN" => LoginAuthenticator,
|
|
||||||
"CRAM-MD5" => CramMD5Authenticator
|
|
||||||
}
|
|
||||||
|
|
||||||
class Error < StandardError
|
class Error < StandardError
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user