Class: Net::IMAP
- Inherits:
-
Object
- Object
- Net::IMAP
- Defined in:
- lib/ruby-cyrus-sasl/imap.rb
Defined Under Namespace
Classes: SASLCallback
Instance Method Summary collapse
Instance Method Details
#authenticate_cyrus(user, password, authname) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/ruby-cyrus-sasl/imap.rb', line 29 def authenticate_cyrus user, password, authname callback = SASLCallback.new user, password, authname server_mechs = (@greeting.data.code.data.scan /AUTH=([^ ]+)/).join ", " cyrus_sasl = RubyCyrusSASL::ClientFactory.instance.create "imap", @host, callback start_result = cyrus_sasl.start server_mechs send_command("AUTHENTICATE", cyrus_sasl.mech) do |resp| if resp.instance_of?(ContinuationRequest) if start_result && start_result.length != 0 s = [start_result].pack("m").gsub(/\n/, "") send_string_data(s) put_string(CRLF) start_result = nil else data = cyrus_sasl.step(resp.data.text.unpack("m")[0]) data = "OK Success (privacy protection)" if cyrus_sasl.complete? and data == "" s = [data].pack("m").gsub(/\n/, "") send_string_data(s) put_string(CRLF) end end end end |