ConnectionConfiguration config = new ConnectionConfiguration(XMPP_HOST, XMPP_PORT); config.setCompressionEnabled(false); config.setSASLAuthenticationEnabled(false); connection = new XMPPConnection(config);
/* this config I missed out */ ConnectionConfiguration config = new ConnectionConfiguration("talk.google.com", 5222, "gmail.com"); config.setCompressionEnabled(true); config.setSASLAuthenticationEnabled(false); connection = new XMPPConnection(config);
ConnectionConfiguration config; config = new ConnectionConfiguration(ip, port, "Smack"); config.setSASLAuthenticationEnabled(false); config.setReconnectionAllowed(true); config.setCompressionEnabled(false); config.setDebuggerEnabled(true); connection = new XMPPConnection(config); connection.connect(); if (connection.isConnected()) { connection.login(loginName, password); }
// Create the configuration for this new connection ConnectionConfiguration config = new ConnectionConfiguration("jabber.org", 5222); config.setCompressionEnabled(true); config.setSASLAuthenticationEnabled(true); Connection connection = new XMPPConnection(config); // Connect to the server connection.connect(); // Log into the server connection.login("danilodeveloper", "password", "SomeResource"); // getting the Openfire contacts that danilodeveloper has Roster roster = connection.getRoster(); // the contacts Collection<RosterEntry> entries = roster.getEntries();
ConnectionConfiguration config = new ConnectionConfiguration(HOST1, 5222); SmackConfiguration.DEBUG_ENABLED = true; SASLAuthentication.supportSASLMechanism("MD5", 0); System.setProperty("smack.debugEnabled", "true"); config.setCompressionEnabled(false); config.setSecurityMode(ConnectionConfiguration.SecurityMode.disabled); config.setReconnectionAllowed(true); config.setSendPresence(true); config.setRosterLoadedAtLogin(true);
try { ConnectionConfiguration config = new ConnectionConfiguration(OF_HOST, OF_PORT); config.setReconnectionAllowed(true); config.setSecurityMode(ConnectionConfiguration.SecurityMode.disabled); config.setSendPresence(true); config.setDebuggerEnabled(true); config.setCompressionEnabled(false); SASLAuthentication.supportSASLMechanism("PLAIN", 0); connection = new XMPPTCPConnection(config); Log.i("connection", connection.toString()); if (connection.isConnected()) { connection.disconnect(); } connection.connect(); return connection; } catch (Exception e) { e.printStackTrace(); }
/** * Creates a new XMPP connection in the same way {@link #XMPPConnection(String,CallbackHandler)} does, but * with no callback handler for password prompting of the keystore. This will work * in most cases, provided the client is not required to provide a certificate to * the server. * * @param serviceName the name of the XMPP server to connect to; e.g. <tt>example.com</tt>. */ public XMPPConnection(String serviceName) { // Create the configuration for this new connection super(new ConnectionConfiguration(serviceName)); config.setCompressionEnabled(false); config.setSASLAuthenticationEnabled(true); config.setDebuggerEnabled(DEBUG_ENABLED); }
/** * Creates a new XMPP connection in the same way {@link #XMPPConnection(String,CallbackHandler)} does, but * with no callback handler for password prompting of the keystore. This will work * in most cases, provided the client is not required to provide a certificate to * the server. * * @param serviceName the name of the XMPP server to connect to; e.g. <tt>example.com</tt>. */ public XMPPConnection(String serviceName) { // Create the configuration for this new connection super(new ConnectionConfiguration(serviceName)); config.setCompressionEnabled(false); config.setSASLAuthenticationEnabled(true); config.setDebuggerEnabled(DEBUG_ENABLED); }
/** * Creates a new XMPP connection in the same way {@link #XMPPConnection(String,CallbackHandler)} does, but * with no callback handler for password prompting of the keystore. This will work * in most cases, provided the client is not required to provide a certificate to * the server. * * @param serviceName the name of the XMPP server to connect to; e.g. <tt>example.com</tt>. */ public XMPPConnection(String serviceName) { // Create the configuration for this new connection super(new ConnectionConfiguration(serviceName)); config.setCompressionEnabled(false); config.setSASLAuthenticationEnabled(true); config.setDebuggerEnabled(DEBUG_ENABLED); }
ConnectionConfiguration config = new ConnectionConfiguration("your_server", port_no); config.setSASLAuthenticationEnabled(true); config.setCompressionEnabled(true); config.setSecurityMode(SecurityMode.enabled); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { config.setTruststoreType("AndroidCAStore"); config.setTruststorePassword(null); config.setTruststorePath(null); } else { config.setTruststoreType("BKS"); String path = System.getProperty("javax.net.ssl.trustStore"); if (path == null) path = System.getProperty("java.home") + File.separator + "etc" + File.separator + "security" + File.separator + "cacerts.bks"; config.setTruststorePath(path); }
ConnectionConfiguration config = new ConnectionConfiguration("your_server", port_no); config.setSASLAuthenticationEnabled(true); config.setCompressionEnabled(true); config.setSecurityMode(SecurityMode.enabled); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { config.setTruststoreType("AndroidCAStore"); config.setTruststorePassword(null); config.setTruststorePath(null); } else { config.setTruststoreType("BKS"); String path = System.getProperty("javax.net.ssl.trustStore"); if (path == null) path = System.getProperty("java.home") + File.separator + "etc" + File.separator + "security" + File.separator + "cacerts.bks"; config.setTruststorePath(path); }
XMPPConnection xmppCon; ConnectionConfiguration conf; SASLAuthentication.registerSASLMechanism("DIGEST-MD5", SASLDigestMD5Mechanism.class); SASLAuthentication.supportSASLMechanism("DIGEST-MD5", 0); conf = new ConnectionConfiguration(HOST, PORT);//, SERVICE); conf.setDebuggerEnabled(true); conf.setSASLAuthenticationEnabled(true); conf.setCompressionEnabled(true); conf.setSecurityMode(SecurityMode.enabled); if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH){ conf.setTruststoreType("AndroidCAStore"); conf.setTruststorePassword(null); conf.setTruststorePath(null); }else{ conf.setTruststoreType("BKS"); String path = System.getProperty("javax.net.ssl.trustStore"); if(path == null){ path = System.getProperty("java.home") + File.separator + "etc" + File.separator + "security" + File.separator + "cacerts.bks"; } conf.setTruststorePath(path); } xmppCon = new XMPPConnection(conf);
ConnectionConfiguration cc = new ConnectionConfiguration(domain, port, service); // SASLAuthentication.supportSASLMechanism("PLAIN", 0); cc.setSASLAuthenticationEnabled(false); cc.setRosterLoadedAtLogin(true); cc.setCompressionEnabled(false); cc.setReconnectionAllowed(true); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { cc.setTruststoreType("AndroidCAStore"); cc.setTruststorePassword(null); cc.setTruststorePath(null); } else { cc.setTruststoreType("BKS"); String path = System.getProperty("javax.net.ssl.trustStore"); if (path == null) { path = System.getProperty("java.home") + File.separator + "etc" + File.separator + "security" + File.separator + "cacerts.bks"; } cc.setTruststorePath(path); } XMPPConnection connection = new XMPPConnection(cc); connection.login(username, password);
/** * Creates a new connection to the specified XMPP server. A DNS SRV lookup will be * performed to determine the IP address and port corresponding to the * service name; if that lookup fails, it's assumed that server resides at * <tt>serviceName</tt> with the default port of 5222. Encrypted connections (TLS) * will be used if available, stream compression is disabled, and standard SASL * mechanisms will be used for authentication.<p> * <p/> * This is the simplest constructor for connecting to an XMPP server. Alternatively, * you can get fine-grained control over connection settings using the * {@link #XMPPConnection(ConnectionConfiguration)} constructor.<p> * <p/> * Note that XMPPConnection constructors do not establish a connection to the server * and you must call {@link #connect()}.<p> * <p/> * The CallbackHandler will only be used if the connection requires the client provide * an SSL certificate to the server. The CallbackHandler must handle the PasswordCallback * to prompt for a password to unlock the keystore containing the SSL certificate. * * @param serviceName the name of the XMPP server to connect to; e.g. <tt>example.com</tt>. * @param callbackHandler the CallbackHandler used to prompt for the password to the keystore. */ public XMPPConnection(String serviceName, CallbackHandler callbackHandler) { // Create the configuration for this new connection super(new ConnectionConfiguration(serviceName)); config.setCompressionEnabled(false); config.setSASLAuthenticationEnabled(true); config.setDebuggerEnabled(DEBUG_ENABLED); config.setCallbackHandler(callbackHandler); }
/** * Creates a new connection to the specified XMPP server. A DNS SRV lookup will be * performed to determine the IP address and port corresponding to the * service name; if that lookup fails, it's assumed that server resides at * <tt>serviceName</tt> with the default port of 5222. Encrypted connections (TLS) * will be used if available, stream compression is disabled, and standard SASL * mechanisms will be used for authentication.<p> * <p/> * This is the simplest constructor for connecting to an XMPP server. Alternatively, * you can get fine-grained control over connection settings using the * {@link #XMPPConnection(ConnectionConfiguration)} constructor.<p> * <p/> * Note that XMPPConnection constructors do not establish a connection to the server * and you must call {@link #connect()}.<p> * <p/> * The CallbackHandler will only be used if the connection requires the client provide * an SSL certificate to the server. The CallbackHandler must handle the PasswordCallback * to prompt for a password to unlock the keystore containing the SSL certificate. * * @param serviceName the name of the XMPP server to connect to; e.g. <tt>example.com</tt>. * @param callbackHandler the CallbackHandler used to prompt for the password to the keystore. */ public XMPPConnection(String serviceName, CallbackHandler callbackHandler) { // Create the configuration for this new connection super(new ConnectionConfiguration(serviceName)); config.setCompressionEnabled(false); config.setSASLAuthenticationEnabled(true); config.setDebuggerEnabled(DEBUG_ENABLED); config.setCallbackHandler(callbackHandler); }
/** * Creates a new connection to the specified XMPP server. A DNS SRV lookup will be * performed to determine the IP address and port corresponding to the * service name; if that lookup fails, it's assumed that server resides at * <tt>serviceName</tt> with the default port of 5222. Encrypted connections (TLS) * will be used if available, stream compression is disabled, and standard SASL * mechanisms will be used for authentication.<p> * <p/> * This is the simplest constructor for connecting to an XMPP server. Alternatively, * you can get fine-grained control over connection settings using the * {@link #XMPPConnection(ConnectionConfiguration)} constructor.<p> * <p/> * Note that XMPPConnection constructors do not establish a connection to the server * and you must call {@link #connect()}.<p> * <p/> * The CallbackHandler will only be used if the connection requires the client provide * an SSL certificate to the server. The CallbackHandler must handle the PasswordCallback * to prompt for a password to unlock the keystore containing the SSL certificate. * * @param serviceName the name of the XMPP server to connect to; e.g. <tt>example.com</tt>. * @param callbackHandler the CallbackHandler used to prompt for the password to the keystore. */ public XMPPConnection(String serviceName, CallbackHandler callbackHandler) { // Create the configuration for this new connection super(new ConnectionConfiguration(serviceName)); config.setCompressionEnabled(false); config.setSASLAuthenticationEnabled(true); config.setDebuggerEnabled(DEBUG_ENABLED); config.setCallbackHandler(callbackHandler); }
/** * Creates a new connection to the XMPP server at the specifiec host and port. * * @param host the name of the XMPP server to connect to; e.g. <tt>jivesoftware.com</tt>. * @param port the port on the server that should be used; e.g. <tt>5222</tt>. * @throws XMPPException if an error occurs while trying to establish the connection. * Two possible errors can occur which will be wrapped by an XMPPException -- * UnknownHostException (XMPP error code 504), and IOException (XMPP error code * 502). The error codes and wrapped exceptions can be used to present more * appropiate error messages to end-users. */ public XMPPConnection(String host, int port) throws XMPPException { // Create the configuration for this new connection ConnectionConfiguration config = new ConnectionConfiguration(host, port); config.setTLSEnabled(true); config.setCompressionEnabled(false); config.setSASLAuthenticationEnabled(true); config.setDebuggerEnabled(DEBUG_ENABLED); // Set the new connection configuration connectUsingConfiguration(config, null); }
/** * Creates a new connection to the specified XMPP server on the given host and port. * * @param host the host name, or null for the loopback address. * @param port the port on the server that should be used; e.g. <tt>5222</tt>. * @param serviceName the name of the XMPP server to connect to; e.g. <tt>jivesoftware.com</tt>. * @throws XMPPException if an error occurs while trying to establish the connection. * Two possible errors can occur which will be wrapped by an XMPPException -- * UnknownHostException (XMPP error code 504), and IOException (XMPP error code * 502). The error codes and wrapped exceptions can be used to present more * appropiate error messages to end-users. */ public XMPPConnection(String host, int port, String serviceName) throws XMPPException { // Create the configuration for this new connection ConnectionConfiguration config = new ConnectionConfiguration(host, port, serviceName); config.setTLSEnabled(true); config.setCompressionEnabled(false); config.setSASLAuthenticationEnabled(true); config.setDebuggerEnabled(DEBUG_ENABLED); // Set the new connection configuration connectUsingConfiguration(config, null); }
config.setCompressionEnabled(false); config.setSASLAuthenticationEnabled(true); config.setDebuggerEnabled(DEBUG_ENABLED);
/** * Creates a new connection to the specified XMPP server. A DNS SRV lookup will be * performed to try to determine the IP address and port corresponding to the * serviceName; if that lookup fails, it's assumed that server resides at serviceName * with the default port of 5222. This is the preferred constructor for connecting * to an XMPP server. * * @param serviceName the name of the XMPP server to connect to; e.g. <tt>jivesoftware.com</tt>. * @throws XMPPException if an error occurs while trying to establish the connection. * Two possible errors can occur which will be wrapped by an XMPPException -- * UnknownHostException (XMPP error code 504), and IOException (XMPP error code * 502). The error codes and wrapped exceptions can be used to present more * appropiate error messages to end-users. */ public XMPPConnection(String serviceName) throws XMPPException { // Perform DNS lookup to get host and port to use DNSUtil.HostAddress address = DNSUtil.resolveXMPPDomain(serviceName); // Create the configuration for this new connection ConnectionConfiguration config = new ConnectionConfiguration(address.getHost(), address.getPort(), serviceName); config.setTLSEnabled(true); config.setCompressionEnabled(false); config.setSASLAuthenticationEnabled(true); config.setDebuggerEnabled(DEBUG_ENABLED); // Set the new connection configuration connectUsingConfiguration(config, null); }