Class: Jabber::Client

Inherits:
Object show all
Defined in:
lib/kinokero/sasl_xoauth2.rb

Overview

****************************************************************************

Instance Method Summary collapse

Instance Method Details

#auth(password) ⇒ Object


Authenticate with the server

Throws ClientAuthenticationFailure

Authentication mechanisms are used in the following preference:

  • SASL X-OAUTH2

  • SASL DIGEST-MD5

  • SASL PLAIN

  • Non-SASL digest

password
String

THIS OVERRIDES XMPP4R method of the same




34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/kinokero/sasl_xoauth2.rb', line 34

def auth(password)

  begin
    if @stream_mechanisms.include? MECHANISM_XOAUTH2
      auth_sasl SASL.new(self, MECHANISM_XOAUTH2), password
    elsif @stream_mechanisms.include? 'DIGEST-MD5'
      auth_sasl SASL.new(self, 'DIGEST-MD5'), password
    elsif @stream_mechanisms.include? 'PLAIN'
      auth_sasl SASL.new(self, 'PLAIN'), password
    else
      auth_nonsasl(password)
    end

  rescue
    Jabber::debuglog("#{$!.class}: #{$!}\n#{$!.backtrace.join("\n")}")
    raise ClientAuthenticationFailure.new, $!.to_s
  end

end