gpt4 book ai didi

xmpp - "bad_auth is not a constant in org.jivesoftware.smack.sasl.SASLError"使用 Smack 4.1 的异常

转载 作者:行者123 更新时间:2023-12-01 05:04:37 25 4
gpt4 key购买 nike

相关问题: Initialization exception "NoClassDefFoundError: javax.naming.directory.InitialDirContext" when using Smack 4.1 on Android

我在我的 Android 应用程序中使用 Smack 4.1.1,但出现以下异常 -

05-19 21:38:31.141    8330-8803/test W/SASLError﹕ Could not transform string 'bad_auth' to SASLError
java.lang.IllegalArgumentException: bad_auth is not a constant in org.jivesoftware.smack.sasl.SASLError
at java.lang.Enum.valueOf(Enum.java:192)
at org.jivesoftware.smack.sasl.SASLError.valueOf(SASLError.java:22)
at org.jivesoftware.smack.sasl.SASLError.fromString(SASLError.java:46)
at org.jivesoftware.smack.sasl.packet.SaslStreamElements$SASLFailure.<init>(SaslStreamElements.java:169)
at org.jivesoftware.smack.util.PacketParserUtils.parseSASLFailure(PacketParserUtils.java:789)
at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader.parsePackets(XMPPTCPConnection.java:1032)
at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader.access$200(XMPPTCPConnection.java:937)
at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader$1.run(XMPPTCPConnection.java:952)
at java.lang.Thread.run(Thread.java:856)
05-19 21:38:31.221 8330-8766/test W/System.err﹕ org.jivesoftware.smack.sasl.SASLErrorException: SASLError using SCRAM-SHA-1: bad-auth
05-19 21:38:31.231 8330-8766/test W/System.err﹕ at org.jivesoftware.smack.SASLAuthentication.authenticationFailed(SASLAuthentication.java:365)
05-19 21:38:31.231 8330-8766/test W/System.err﹕ at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader.parsePackets(XMPPTCPConnection.java:1033)
05-19 21:38:31.231 8330-8766/test W/System.err﹕ at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader.access$200(XMPPTCPConnection.java:937)
05-19 21:38:31.231 8330-8766/test W/System.err﹕ at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader$1.run(XMPPTCPConnection.java:952)
05-19 21:38:31.231 8330-8766/test W/System.err﹕ at java.lang.Thread.run(Thread.java:856)

这是我当前的登录代码 -
public void login(String username, String password) throws IOException, XMPPException, SmackException {

XMPPTCPConnectionConfiguration config = XMPPTCPConnectionConfiguration.builder()
.setUsernameAndPassword(username, password)
.setHost(SERVICE_NAME)
.setPort(5222)
.setServiceName(SERVICE_NAME)
.setSecurityMode(ConnectionConfiguration.SecurityMode.disabled)
.build();


mConnection = new XMPPTCPConnection(config);

mConnection.connect();
mConnection.login();

mChatManager = ChatManager.getInstanceFor(mConnection);
mChatManager.addChatListener(this);
}

我曾尝试使用普通 SASL 机制 -

SASLAuthentication.registerSASLMechanism(new SASLPlainMechanism());

并且也尝试了以下代码
    SASLMechanism mechanism = new SASLDigestMD5Mechanism();
SASLAuthentication.registerSASLMechanism(mechanism);
SASLAuthentication.blacklistSASLMechanism("SCRAM-SHA-1");
SASLAuthentication.unBlacklistSASLMechanism("DIGEST-MD5");

所有这些都不起作用。

我能够成功地将相同的服务器用于 iOS(使用 XMPPFramework)和 WPF(使用 S22)。我也在 pidgin 中使用它进行测试。它在任何地方都可以正常工作,所以我确信我错过了在 smack 中进行身份验证的一些重要步骤。我怎么知道登录到指定服务器的正确方法是什么?

最佳答案

05-19 21:38:31.141    8330-8803/test W/SASLError﹕ Could not transform string 'bad_auth' to SASLError
java.lang.IllegalArgumentException: bad_auth is not a constant in org.jivesoftware.smack.sasl.SASLError
at java.lang.Enum.valueOf(Enum.java:192)

“bad_auth”不是按照 RFC 6120 § 6.5. SASL Errors 定义的 SASL 错误.告诉所用 XMPP 服务器的供应商修复该问题。

关于xmpp - "bad_auth is not a constant in org.jivesoftware.smack.sasl.SASLError"使用 Smack 4.1 的异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30331117/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com