Created
August 20, 2009 20:18
-
-
Save milep/171329 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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