Module: AgentXmpp::Xmpp::SASL

Defined in:
lib/agent_xmpp/xmpp/sasl.rb

Overview


Defined Under Namespace

Classes: Anonymous, Base, DigestMD5, Plain

Constant Summary collapse

NS_SASL =

.….….….….….….….….….….….….….….….….….….….….….….….….….

'urn:ietf:params:xml:ns:xmpp-sasl'

Class Method Summary collapse

Class Method Details

.authenticate(stream_mechanisms) ⇒ Object

.….….….….….….….….….….….….….….….….….….….….….….….….….….



32
33
34
35
36
37
38
# File 'lib/agent_xmpp/xmpp/sasl.rb', line 32

def authenticate(stream_mechanisms)
  if stream_mechanisms.include?('PLAIN')
    Send(new('PLAIN').auth(AgentXmpp.jid, AgentXmpp.password))
  else
    raise AgentXmppError, "PLAIN authentication required"
  end
end

.new(mechanism) ⇒ Object

.….….….….….….….….….….….….….….….….….….….….….….….….….



18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/agent_xmpp/xmpp/sasl.rb', line 18

def new(mechanism)
  case mechanism
    when 'DIGEST-MD5'
      DigestMD5.new
    when 'PLAIN'
      Plain.new
    when 'ANONYMOUS'
      Anonymous.new
    else
      raise AgentXmppError "Unknown SASL mechanism: #{mechanism}"
  end
end