lib/xmpp2s/connection.rb
# Try to authenticate user
#
# === Attributes
#
# * +password+ - User password
# * +mechanism+ - Authentication mechanism
#
# ==== Exception
#
# Can raise AuthenticationError if invalid login is provided.
Try to authenticate user
Attributes

+password+ - User password
+mechanism+ - Authentication mechanism

Exception

Can raise AuthenticationError if invalid login is provided.
Try to authenticate user Attributes + password + - User password + mechanism + - Authentication mechanism Exception Can raise AuthenticationError if invalid login is provided .
def authenticate(password, mechanism)
      if (mechanism == Xmpp2s::Auth::SASL)
        unless @features.include?('xmpp-sasl') && @features.include?('PLAIN')
          fail AuthenticationError, 'Unsupported Authentication'
        end
      else
      end
      send_data(Xmpp2s::Protocol::Auth.new(@jid.jid, password, mechanism))
      response = read_data
      if response.root.name != 'success'
        close
        fail AuthenticationError, "Invalid login (#{response.root.child.name})"
      end
      start_stream
      bind_resource
      register_session
      @authorized = true
    end
def authenticate ( password , mechanism ) if ( mechanism == Xmpp2s :: Auth :: SASL ) unless @features . include? ( 'xmpp-sasl' ) && @features . include? ( 'PLAIN' ) fail AuthenticationError , 'Unsupported Authentication' end else end send_data ( Xmpp2s :: Protocol :: Auth . new ( @jid . jid , password , mechanism ) ) response = read_data if response . root . name != 'success' close fail AuthenticationError , "Invalid login (#{response.root.child.name})" end start_stream bind_resource register_session @authorized = true end
Try to authenticate user
 Attributes
Try to authenticate user Attributes
# Check mechanism # Check SASL authentication in features # Check non-sasl method # Send authentitation XML # Read authentication response from server # Check # Close connection # Raise an unauthorized exception # Start stream again # Bind resources # Register session # Return (success login)
password
mechanism