def initialize(obj, opts = {:tls => false})
@obj = obj
@opts = opts
@allow_shell_cmds = opts[:allow_shell_cmds]
@log = opts[:logger] || ::Logger.new(STDERR)
@auth_attempt_cbs = []
@auth_attempts = []
@auth_fail_cbs = []
@auth_fails = []
@auth_ok_cbs = []
@auth_oks = []
@auth_tries = 5
@after_auth = []
return unless (a = opts[:auth])
if a.is_a?(Proc)
return fail("auth handler Procs must take two arguments not (#{a.arity})") unless a.arity == 2
@auth = a
elsif a.respond_to?(:call)
return fail("auth handler must take two arguments not (#{a.method(:call).arity})") unless a.method(:call).arity == 2
@auth = a
else
return error("auth handler objects must respond to :call, or :[]") unless a.respond_to?(:[])
@auth = lambda {|u,p| a[u] && a[u] == p }
end
end