class Net::IMAP::SASL::ClientAdapter

This API is experimental, and may change.

TODO: use with more clients, to verify the API can accommodate them.

An abstract base class for implementing a SASL authentication exchange. Different clients will each have their own adapter subclass, overridden to match their needs.

Although the default implementations may be sufficient, subclasses will probably need to override some methods. Additionally, subclasses may need to include a protocol adapter mixin, if the default ProtocolAdapters::Generic isn’t sufficient.

Attributes

client[R]
command_proc[R]

Public Class Methods

new(client, &command_proc) click to toggle source

command_proc can used to avoid exposing private methods on client. It should run a command with the arguments sent to it, yield each continuation payload, respond to the server with the result of each yield, and return the result. Non-successful results MUST raise an exception. Exceptions in the block MUST cause the command to fail.

Subclasses that override run_command may use command_proc for other purposes.

# File net-imap-0.4.4/lib/net/imap/sasl/client_adapter.rb, line 32
def initialize(client, &command_proc)
  @client, @command_proc = client, command_proc
end

Public Instance Methods

auth_capable?(mechanism) click to toggle source

Does the server advertise support for the mechanism?

# File net-imap-0.4.4/lib/net/imap/sasl/client_adapter.rb, line 43
def auth_capable?(mechanism); client.auth_capable?(mechanism) end
authenticate(...) click to toggle source

Delegates to AuthenticationExchange.authenticate.

# File net-imap-0.4.4/lib/net/imap/sasl/client_adapter.rb, line 37
def authenticate(...) AuthenticationExchange.authenticate(self, ...) end
drop_connection() click to toggle source

Drop the connection gracefully.

# File net-imap-0.4.4/lib/net/imap/sasl/client_adapter.rb, line 65
def drop_connection;  client.drop_connection end
drop_connection!() click to toggle source

Drop the connection abruptly.

# File net-imap-0.4.4/lib/net/imap/sasl/client_adapter.rb, line 68
def drop_connection!; client.drop_connection! end
response_errors() click to toggle source

Returns an array of server responses errors raised by run_command. Exceptions in this array won’t drop the connection.

# File net-imap-0.4.4/lib/net/imap/sasl/client_adapter.rb, line 62
def response_errors; [] end
run_command(mechanism, initial_response = nil, &block) click to toggle source

Runs the authenticate command with mechanism and initial_response. When initial_response is nil, an initial response must NOT be sent.

Yields each continuation payload, responds to the server with the result of each yield, and returns the result. Non-successful results MUST raise an exception. Exceptions in the block MUST cause the command to fail.

Subclasses that override this may use command_proc differently.

# File net-imap-0.4.4/lib/net/imap/sasl/client_adapter.rb, line 54
def run_command(mechanism, initial_response = nil, &block)
  command_proc or raise Error, "initialize with block or override"
  args = [command_name, mechanism, initial_response].compact
  command_proc.call(*args, &block)
end
sasl_ir_capable?() click to toggle source

Do the protocol and server both support an initial response?

# File net-imap-0.4.4/lib/net/imap/sasl/client_adapter.rb, line 40
def sasl_ir_capable?; client.sasl_ir_capable? end