我们有两个服务器一个服务器通过restful API完成身份验证,另一个是从mongoosim的本地数据库进行身份验证。我的身份验证在通过mongooseim db进行身份验证的服务器上失败。
这些是会话
的捕获数据包D/SMACK: SENT (0): <stream:stream xmlns='jabber:client' to='ip' xmlns:stream='http://etherx.jabber.org/streams' version='1.0' from='test@ip' xml:lang='en'>
D/SMACK: RECV (0): <?xml version='1.0'?><stream:stream xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' id='BB3E907D81DDDB71' from='ip' version='1.0' xml:lang='en'><stream:features><starttls xmlns='urn:ietf:params:xml:ns:xmpp-tls'/><mechanisms xmlns='urn:ietf:params:xml:ns:xmpp-sasl'><mechanism>PLAIN</mechanism><mechanism>DIGEST-MD5</mechanism><mechanism>SCRAM-SHA-1</mechanism></mechanisms><register xmlns='http://jabber.org/features/iq-register'/><sm xmlns='urn:xmpp:sm:3'/></stream:featur
这是我在进行身份验证时获得的例外情况。
01-29 15:58:21.673 4793-5035/com.safarifone.waafi.debug W/System.err: org.jivesoftware.smack.sasl.SASLErrorException: SASLError using PLAIN: not-authorized
01-29 15:58:21.684 4793-5035/com.safarifone.waafi.debug W/System.err: at org.jivesoftware.smack.SASLAuthentication.authenticationFailed(SASLAuthentication.java:291)
01-29 15:58:21.687 4793-5035/com.safarifone.waafi.debug W/System.err: at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader.parsePackets(XMPPTCPConnection.java:1096)
01-29 15:58:21.688 4793-5035/com.safarifone.waafi.debug W/System.err: at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader.access$300(XMPPTCPConnection.java:994)
01-29 15:58:21.690 4793-5035/com.safarifone.waafi.debug W/System.err: at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader$1.run(XMPPTCPConnection.java:1010)
捕获数据包
D/SMACK: SENT (0): <auth xmlns='urn:ietf:params:xml:ns:xmpp-sasl' mechanism='PLAIN'>ADkyMzE1NTEwNDI5MgA=</auth>
D/SMACK: RECV (0): <failure xmlns='urn:ietf:params:xml:ns:xmpp-sasl'><not-authorized/></failure>
这就是我配置客户端的方式
XMPPTCPConnectionConfiguration.Builder builder = XMPPTCPConnectionConfiguration.builder()
.setUsernameAndPassword(mAccount.getUserName(), mAccount.getPassword())
.setXmppDomain(com.safarifone.settings.Settings.IM_SERVER)
.setHost(mAccount.getHost())
.setPort(mAccount.getPort())
.setKeystoreType(null)
.setSendPresence(true)
.setResource(IMConstant.XMPP_RESOURCE)
.setDebuggerEnabled(true)
.setSecurityMode(ConnectionConfiguration.SecurityMode.disabled)
.setConnectTimeout(IMService.CONNECT_TIMEOUT);
Log.d(TAG, "Setting TLS Certificates Settings for XMPPTCPConnectionConfiguration Object ");
// TLSUtils.acceptAllCertificates(builder);
Log.d(TAG, "Setting XMPPTCPConnection Static StreamManagement Default Properties to true ");
XMPPTCPConnection.setUseStreamManagementDefault(true);
XMPPTCPConnection.setUseStreamManagementResumptionDefault(true);
Log.d(TAG, "Setting SASLAuthentication Blacklist");
SASLAuthentication.unBlacklistSASLMechanism("PLAIN");
SASLAuthentication.blacklistSASLMechanism("DIGEST-MD5");
SASLAuthentication.blacklistSASLMechanism("SCRAM-SHA-1");
SASLAuthentication.registerSASLMechanism(new SASLPlainMechanism());
注意: 如果我使用其他客户端,例如jitsi,我可以进行身份验证。