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

#auth(password) ⇒ Object

Authenticate via sending password in clear-text



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

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).strip)) { |reply|
    if reply.name != 'success'
      error = reply.first_element(nil).name
    end
    true
  }
  
  raise error if error
end