I am developing XMPP client for chat.facebook.com on Android. I use X-FACEBOOK-PLATFORM mechanism. According to the server response, I am successfull with authentication. But my JID is strange it is: -0@chat.facebook.com@chat.facebook.com:5222/Application_a573c90d_4E4AD1661EFE6. And my status is always "offline". And rooster is always empty. My LogCat is here:
08-24 14:13:19.920: I/System.out(12326): PRE-CONNECTED
08-24 14:13:19.950: D/dalvikvm(12326): GC_CONCURRENT freed 372K, 5% free 9556K/10055K, paused 2ms+13ms
08-24 14:13:22.540: D/SMACK(12326): 02:13:22 PM SENT (736870032): <stream:stream to="chat.facebook.com" xmlns="jabber:client" xmlns:stream="http://etherx.jabber.org/streams" version="1.0">
08-24 14:13:22.950: D/SMACK(12326): 02:13:22 PM RCV (736870032): <?xml version="1.0"?><stream:stream id="67C3CE90" from="chat.facebook.com" version="1.0" xmlns="jabber:client" xmlns:stream="http://etherx.jabber.org/streams" xml:lang="en"><stream:features><starttls xmlns="urn:ietf:params:xml:ns:xmpp-tls"/><mechanisms xmlns="urn:ietf:params:xml:ns:xmpp-sasl"><mechanism>X-FACEBOOK-PLATFORM</mechanism><mechanism>DIGEST-MD5</mechanism></mechanisms></stream:features>
08-24 14:13:22.950: D/SMACK(12326): 02:13:22 PM SENT (736870032): <starttls xmlns="urn:ietf:params:xml:ns:xmpp-tls"/>
08-24 14:13:23.260: D/SMACK(12326): 02:13:23 PM RCV (736870032): <proceed xmlns="urn:ietf:params:xml:ns:xmpp-tls"/>
08-24 14:13:23.280: W/System.err(12326): java.security.KeyStoreException: java.security.NoSuchAlgorithmException: KeyStore jks implementation not found
08-24 14:13:23.280: W/System.err(12326): at java.security.KeyStore.getInstance(KeyStore.java:119)
08-24 14:13:23.280: W/System.err(12326): at org.jivesoftware.smack.ServerTrustManager.<init>(ServerTrustManager.java:70)
08-24 14:13:23.280: W/System.err(12326): at org.jivesoftware.smack.XMPPConnection.proceedTLSReceived(XMPPConnection.java:871)
08-24 14:13:23.280: W/System.err(12326): at org.jivesoftware.smack.PacketReader.parsePackets(PacketReader.java:221)
08-24 14:13:23.280: W/System.err(12326): at org.jivesoftware.smack.PacketReader.access$000(PacketReader.java:44)
08-24 14:13:23.280: W/System.err(12326): at org.jivesoftware.smack.PacketReader$1.run(PacketReader.java:70)
08-24 14:13:23.280: W/System.err(12326): Caused by: java.security.NoSuchAlgorithmException: KeyStore jks implementation not found
08-24 14:13:23.300: W/System.err(12326): at org.apache.harmony.security.fortress.Engine.notFound(Engine.java:177)
08-24 14:13:23.300: W/System.err(12326): at org.apache.harmony.security.fortress.Engine.getInstance(Engine.java:151)
08-24 14:13:23.300: W/System.err(12326): at java.security.KeyStore.getInstance(KeyStore.java:116)
08-24 14:13:23.300: W/System.err(12326): ... 5 more
08-24 14:13:23.720: D/SMACK(12326): 02:13:23 PM SENT (736870032): <stream:stream to="chat.facebook.com" xmlns="jabber:client" xmlns:stream="http://etherx.jabber.org/streams" version="1.0">
08-24 14:13:23.760: D/dalvikvm(12326): GC_FOR_ALLOC freed 197K, 5% free 9677K/10183K, paused 19ms
08-24 14:13:24.383: D/SMACK(12326): 02:13:24 PM RCV (736870032): <?xml version="1.0"?><stream:stream id="D534089B" from="chat.facebook.com" version="1.0" xmlns="jabber:client" xmlns:stream="http://etherx.jabber.org/streams" xml:lang="en">
08-24 14:13:24.390: D/SMACK(12326): 02:13:24 PM RCV (736870032): <stream:features><mechanisms xmlns="urn:ietf:params:xml:ns:xmpp-sasl"><mechanism>X-FACEBOOK-PLATFORM</mechanism><mechanism>DIGEST-MD5</mechanism></mechanisms></stream:features>
08-24 14:13:24.390: I/System.out(12326): CONNECTED:true
08-24 14:13:24.430: D/SMACK(12326): 02:13:24 PM SENT (736870032): <auth mechanism="X-FACEBOOK-PLATFORM" xmlns="urn:ietf:params:xml:ns:xmpp-sasl"></auth>
08-24 14:13:24.798: D/SMACK(12326): 02:13:24 PM RCV (736870032): <challenge xmlns="urn:ietf:params:xml:ns:xmpp-sasl">dmVyc2lvbj0xJm1ldGhvZD1hdXRoLnhtcHBfbG9naW4mbm9uY2U9QjdFOTc2M0Q0Nzc2QTlDMTFBMjE0QTRCOTdFQzVEQjU=</challenge>
08-24 14:13:24.800: D/SMACK(12326): 02:13:24 PM SENT (736870032): <response xmlns="urn:ietf:params:xml:ns:xmpp-sasl">bWV0aG9kPWF1dGgueG1wcF9sb2dpbiZub25jZT1CN0U5NzYzRDQ3NzZBOUMxMUEyMTRBNEI5N0VD
08-24 14:13:24.800: D/SMACK(12326): NURCNSZhY2Nlc3NfdG9rZW49Q0FBSkdJQlU5eDg4QkFHcXpRbnBNMXZFSW54YU11aWg2WkNLd0FX
08-24 14:13:24.800: D/SMACK(12326): NXpDVUs2U0lGSGZ5VDdMbFM2RGlYZThwdmVQTEhIZlpCdWpKNkJhdHRNT2pMZnQ3SG5zRktPOTRD
08-24 14:13:24.800: D/SMACK(12326): WVZEV3BGUHR5R1dSaXZJdkk0WkJJeEp5MXVUNHMxeXJvS0NTQXloTHlYblpDZjloZzhPc1FUNVRE
08-24 14:13:24.800: D/SMACK(12326): MFJjSzNJU1dEYW15SkJFRUptcWo5bzdZdXNtaEFaQ3BLNVpDWEhUaGRKSE56WFpCZlVBbmRkM3RI
08-24 14:13:24.800: D/SMACK(12326): ZmQzMkVXJmFwaV9rZXk9NjQwMDUzNTYyNjg5NDg3JmNhbGxfaWQ9MCZ2PTEuMA==</response>
08-24 14:13:25.208: D/SMACK(12326): 02:13:25 PM RCV (736870032): <success xmlns="urn:ietf:params:xml:ns:xmpp-sasl"/>
08-24 14:13:25.210: D/SMACK(12326): 02:13:25 PM SENT (736870032): <stream:stream to="chat.facebook.com" xmlns="jabber:client" xmlns:stream="http://etherx.jabber.org/streams" version="1.0">
08-24 14:13:25.510: D/SMACK(12326): 02:13:25 PM RCV (736870032): <?xml version="1.0"?><stream:stream id="90530E3B" from="chat.facebook.com" version="1.0" xmlns="jabber:client" xmlns:stream="http://etherx.jabber.org/streams" xml:lang="en">
08-24 14:13:25.510: D/SMACK(12326): 02:13:25 PM RCV (736870032): <stream:features><bind xmlns="urn:ietf:params:xml:ns:xmpp-bind"/><session xmlns="urn:ietf:params:xml:ns:xmpp-session"/></stream:features>
08-24 14:13:25.530: D/SMACK(12326): 02:13:25 PM SENT (736870032): <iq id="0imwt-0" type="set"><bind xmlns="urn:ietf:params:xml:ns:xmpp-bind"><resource>Application</resource></bind></iq>
08-24 14:13:25.925: D/SMACK(12326): 02:13:25 PM RCV (736870032): <iq id="0imwt-0" type="result"><bind xmlns="urn:ietf:params:xml:ns:xmpp-bind"><jid>-0@chat.facebook.com/Application_a573c90d_4E4AD1661EFE6</jid></bind></iq>
08-24 14:13:25.925: D/SMACK(12326): 02:13:25 PM SENT (736870032): <iq id="0imwt-1" type="set"><session xmlns="urn:ietf:params:xml:ns:xmpp-session"/></iq>
08-24 14:13:26.330: D/SMACK(12326): 02:13:26 PM RCV (736870032): <iq type="result" id="0imwt-1"><session xmlns="urn:ietf:params:xml:ns:xmpp-session"/></iq>
08-24 14:13:26.340: D/SMACK(12326): 02:13:26 PM SENT (736870032): <iq id="0imwt-2" type="get"><query xmlns="jabber:iq:roster" ></query></iq>
08-24 14:13:26.340: D/SMACK(12326): 02:13:26 PM SENT (736870032): <presence id="0imwt-3"></presence>
08-24 14:13:26.340: D/SMACK(12326): User logged (736870032): -0@chat.facebook.com@chat.facebook.com:5222/Application_a573c90d_4E4AD1661EFE6
08-24 14:13:26.340: I/System.out(12326): TLS:true
08-24 14:13:26.340: I/System.out(12326): Logged in:true
Here is my code for connection and authentication:
ConnectionConfiguration config = new ConnectionConfiguration("chat.facebook.com", 5222);
config.setDebuggerEnabled(true);
config.setSASLAuthenticationEnabled(true);
config.setSecurityMode(ConnectionConfiguration.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);
}
xmpp = new XMPPConnection(config);
SASLAuthentication.registerSASLMechanism("X-FACEBOOK-PLATFORM",SASLXFacebookPlatformMechanism.class);
SASLAuthentication.supportSASLMechanism("X-FACEBOOK-PLATFORM", 0);
System.out.println("PRE-CONNECTED");
xmpp.connect();
System.out.println("CONNECTED:"+xmpp.isConnected());
Log.i("TOKEN", Session.getActiveSession().getAccessToken());
xmpp.login("640053562689487", Session.getActiveSession().getAccessToken(),"Application");