Skip to content

Instantly share code, notes, and snippets.

@milep
Created August 20, 2009 20:18
Show Gist options
  • Save milep/171329 to your computer and use it in GitHub Desktop.
Save milep/171329 to your computer and use it in GitHub Desktop.
package jabber;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.jivesoftware.smack.ConnectionConfiguration;
import org.jivesoftware.smack.SASLAuthentication;
import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.XMPPException;
public class Main {
public static void main(String[] args) {
ConnectionConfiguration config = new ConnectionConfiguration("jabber.org", 5222, "jabber.org");
config.setCompressionEnabled(true);
config.setSASLAuthenticationEnabled(true);
XMPPConnection connection = new XMPPConnection(config);
try {
// Connect to the server
connection.connect();
SASLAuthentication.supportSASLMechanism("PLAIN", 0);
connection.login("username", "password");
System.out.println("auth: " + connection.isAuthenticated());
} catch (XMPPException ex) {
Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
}
// Log into the server
// Disconnect from the server
connection.disconnect();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment