ConnectionConfiguration ConnectionConfiguration = new ConnectionConfiguration(HOST, PORT); ConnectionConfiguration.setDebuggerEnabled(true); ConnectionConfiguration.setSecurityMode(SecurityMode.disabled);
ConnectionConfiguration config = new ConnectionConfiguration(server, port); //... any other stuff you need //very basic security stuff just to get you going... config.setSecurityMode(ConnectionConfiguration.SecurityMode.disabled); XMPPTCPConnection connection = new XMPPTCPConnection(config); SASLAuthentication.supportSASLMechanism("DIGEST-MD5", 0); connection.connect(); //... any other stuff you want connection.login(user, passw);
private static ConnectionConfiguration buildConnectionConfiguration(Shard shard) { ConnectionConfiguration connConf = new ConnectionConfiguration(shard.chatUrl, Shard.JABBER_PORT, "pvp.net"); connConf.setSecurityMode(ConnectionConfiguration.SecurityMode.disabled); connConf.setSocketFactory(SSLSocketFactory.getDefault()); return connConf; }
conConfig.setSecurityMode(SecurityMode.disabled); connection = new XMPPTCPConnection(conConfig); try {
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(); }
ConnectionConfiguration config = new ConnectionConfiguration("chat.facebook.com", 5222); config.setSASLAuthenticationEnabled(true); config.setSecurityMode(ConnectionConfiguration.SecurityMode.enabled); XMPPConnection xmpp = new XMPPConnection(config); SASLAuthentication.registerSASLMechanism("X-FACEBOOK-PLATFORM",SASLXFacebookPlatformMechanism.class); SASLAuthentication.supportSASLMechanism("X-FACEBOOK-PLATFORM", 0); xmpp.connect(); xmpp.login(appSecret, accessToken, "Application");
public XMPPConnection login() throws XMPPException { ConnectionConfiguration config = new ConnectionConfiguration("talk.google.com",5222,"gmail.com"); config.setSecurityMode(SecurityMode.required); config.setTruststoreType("BKS"); config.setTruststorePath("/system/etc/security/cacerts.bks"); XMPPConnection connection = new XMPPConnection(config); connection.connect(); connection.login(username, password); Presence presence = new Presence(Presence.Type.available); presence.setMode(Presence.Mode.available); connection.sendPacket(presence); try { Thread.sleep(3000); } catch (Exception ex) { ex.printStackTrace(); } return connection; }
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);
private void testLogin(){ ConnectionConfiguration config = new ConnectionConfiguration("chat.facebook.com", 5222); config.setSASLAuthenticationEnabled(true); config.setSecurityMode(ConnectionConfiguration.SecurityMode.enabled); xmpp = new XMPPConnection(config); SASLAuthentication.registerSASLMechanism("X-FACEBOOK-PLATFORM",SASLXFacebookPlatformMechanism.class); SASLAuthentication.supportSASLMechanism("X-FACEBOOK-PLATFORM", 0); Log.i("XMPPClient", "Access token to " + mFacebook.getAccessToken()); Log.i("XMPPClient", "Access token to " + mFacebook.getAppId()); Log.i("XMPPClient", "Access token to " + mFacebook.getAccessToken()); try { xmpp.connect(); Log.i("XMPPClient", "Connected to " + xmpp.getHost()); } catch (XMPPException e1) { Log.i("XMPPClient", "Unable to " + xmpp.getHost()); e1.printStackTrace(); } try { xmpp.login(PreferenceConnector.APP_ID, mFacebook.getAccessToken()); getRoster(xmpp); } catch (XMPPException e) { e.printStackTrace(); } }
configuration.setSecurityMode(SecurityMode.enabled); configuration.setReconnectionAllowed(true); configuration.setRosterLoadedAtLogin(false);
ConnectionConfiguration connectionConfiguration = new ConnectionConfiguration("localhost", 5222); connectionConfiguration.setSecurityMode(ConnectionConfiguration.SecurityMode.required); connectionConfiguration.setSASLAuthenticationEnabled(true); connectionConfiguration.setKeystorePath("src/main/resources/bogus_mina_tls.cert"); connectionConfiguration.setTruststorePath("src/main/resources/bogus_mina_tls.cert"); connectionConfiguration.setTruststorePassword("boguspw");
private void testLogin(){ ConnectionConfiguration config = new ConnectionConfiguration("chat.facebook.com", 5222); config.setSASLAuthenticationEnabled(true); config.setSecurityMode(ConnectionConfiguration.SecurityMode.enabled); xmpp = new XMPPConnection(config); SASLAuthentication.registerSASLMechanism("X-FACEBOOK-PLATFORM",SASLXFacebookPlatformMechanism.class); SASLAuthentication.supportSASLMechanism("X-FACEBOOK-PLATFORM", 0); Log.i("XMPPClient", "Access token to " + mFacebook.getAccessToken()); Log.i("XMPPClient", "Access token to " + mFacebook.getAppId()); Log.i("XMPPClient", "Access token to " + mFacebook.getAccessToken()); try { xmpp.connect(); Log.i("XMPPClient", "Connected to " + xmpp.getHost()); } catch (XMPPException e1) { Log.i("XMPPClient", "Unable to " + xmpp.getHost()); e1.printStackTrace(); } try { xmpp.login(PreferenceConnector.APP_ID, mFacebook.getAccessToken()); } catch (XMPPException e) { e.printStackTrace(); } }
private void LoginToFaceBook(){ ConnectionConfiguration config = new ConnectionConfiguration("chat.facebook.com", 5222); config.setSASLAuthenticationEnabled(true); config.setSecurityMode(ConnectionConfiguration.SecurityMode.enabled); xmpp = new XMPPConnection(config); SASLAuthentication.registerSASLMechanism("X-FACEBOOK-PLATFORM",SASLXFacebookPlatformMechanism.class); SASLAuthentication.supportSASLMechanism("X-FACEBOOK-PLATFORM", 0); Log.i("XMPPClient", "Access token to " + mFacebook.getAccessToken()); Log.i("XMPPClient", "Access token to " + mFacebook.getAppId()); Log.i("XMPPClient", "Access token to " + mFacebook.getAccessToken()); try { xmpp.connect(); Log.i("XMPPClient", "Connected to " + xmpp.getHost()); } catch (XMPPException e1) { Log.i("XMPPClient", "Unable to " + xmpp.getHost()); e1.printStackTrace(); } try { xmpp.login(PreferenceConnector.APP_ID, mFacebook.getAccessToken()); } catch (XMPPException e) { e.printStackTrace(); } }
new ConnectionConfiguration (getHost(), getPort(), getService()); connectionConfig.setSASLAuthenticationEnabled(true); connectionConfig.setSecurityMode(true); connectionConfig.setRosterLoadedAtLogin(true); connectionConfig.setReconnectionAllowed(true);
ConnectionConfiguration config = new ConnectionConfiguration("IM_DOMAIN", 5222); config.setDebuggerEnabled(false); config.setSecurityMode(SecurityMode.disabled); XMPPTCPConnection con = new XMPPTCPConnection(config); try { con.connect(); con.login("USERNAME", "PASSWORD"); Message msg = new Message("RECIPIENT_JID"); msg.setBody("message"); msg.setType(Type.chat); con.sendPacket(msg); } catch (SmackException | XMPPException | IOException | InterruptedException e) { throw e; } finally { if (null != con) { try { con.disconnect(); } catch (NotConnectedException e) { } } }
config.setSecurityMode(SecurityMode.required); config.setRosterLoadedAtLogin(true); config.setTruststorePath("/system/etc/security/cacerts.bks");
private XMPPTCPConnection connect(long senderId, String apiKey) throws XMPPException, IOException, SmackException { ConnectionConfiguration config = new ConnectionConfiguration(GCM_SERVER, GCM_PORT); config.setSecurityMode(ConnectionConfiguration.SecurityMode.enabled); config.setReconnectionAllowed(true); config.setRosterLoadedAtLogin(false); config.setSendPresence(false); config.setSocketFactory(SSLSocketFactory.getDefault()); XMPPTCPConnection connection = new XMPPTCPConnection(config); connection.connect(); connection.addConnectionListener(new LoggingConnectionListener()); connection.addPacketListener(this, new PacketTypeFilter(Message.class)); connection.login(senderId + "@gcm.googleapis.com", apiKey); return connection; }