Class: Jabber::SASL::Plain

Inherits:
Base
  • Object
show all
Defined in:
lib/xmpp4r/sasl.rb

Overview

SASL PLAIN authentication helper (RFC2595)

Instance Method Summary (collapse)

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from Jabber::SASL::Base

Instance Method Details

- (Object) auth(password)

Authenticate via sending password in clear-text



59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/xmpp4r/sasl.rb', line 59

def auth(password)
  auth_text = "#{@stream.jid.strip}\x00#{@stream.jid.node}\x00#{password}"
  error = nil
  @stream.send(generate_auth('PLAIN', Base64::encode64(auth_text).gsub(/\s/, ''))) { |reply|
    if reply.name != 'success'
      error = reply.first_element(nil).name
    end
    true
  }

  raise error if error
end