org.jivesoftware.smack.sasl.SASLErrorException: SASLError using PLAIN: not-authorized
Hi.. Am new to Chat Application.. For server am using openfire 3.10.2, i got the error like this
W/System.err: org.jivesoftware.smack.sasl.SASLErrorException: SASLError using PLAIN: not-authorized 03-31 10:52:36.492 27403-10572/com.dating W/System.err: at org.jivesoftware.smack.SASLAuthentication.authenticationFailed(SASLAuthentication.java:365) 03-31 10:52:36.492 27403-10572/com.dating W/System.err: at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader.parsePackets(XMPPTCPConnection.java:1044) 03-31 10:52:36.502 27403-10572/com.dating W/System.err: at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader.access$300(XMPPTCPConnection.java:948) 03-31 10:52:36.502 27403-10572/com.dating W/System.err: at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader$1.run(XMPPTCPConnection.java:963) 03-31 10:52:36.502 27403-10573/com.dating W/System.err: at org.jivesoftware.smack.sasl.SASLErrorException: SASLError using PLAIN: not-authorized 03-31 10:52:36.502 27403-10572/com.dating W/System.err: java.lang.Thread.run(Thread.java:841) 03-31 10:52:36.502 27403-10573/com.dating W/System.err: at org.jivesoftware.smack.SASLAuthentication.authenticationFailed(SASLAuthentication.java:365) 03-31 10:52:36.502 27403-10573/com.dating W/System.err: at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader.parsePackets(XMPPTCPConnection.java:1044) 03-31 10:52:36.502 27403-10573/com.dating W/System.err: at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader.access$300(XMPPTCPConnection.java:948) 03-31 10:52:36.502 27403-10573/com.dating W/System.err: at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader$1.run(XMPPTCPConnection.java:963)
private void createConnection(String fqdn, int port, boolean useSRVLookup) { XMPPTCPConnectionConfiguration.Builder builder = XMPPTCPConnectionConfiguration.builder(); if (useSRVLookup) { builder.setServiceName(serverName); } else { builder.setHost(fqdn); builder.setPort(port); builder.setServiceName(serverName); }
onReady(builder);
}
private void onReady(XMPPTCPConnectionConfiguration.Builder builder) {
builder.setSecurityMode(ConnectionConfiguration.SecurityMode.disabled);
builder.setCompressionEnabled(compression);
builder.setSendPresence(false);
try {
if (SettingsManager.securityCheckCertificate()) {
SSLContext sslContext = SSLContext.getInstance("TLS");
MemorizingTrustManager mtm = new MemorizingTrustManager(Application.getInstance());
sslContext.init(null, new X509TrustManager[]{mtm}, new java.security.SecureRandom());
builder.setCustomSSLContext(sslContext);
builder.setHostnameVerifier(
mtm.wrapHostnameVerifier(new org.apache.http.conn.ssl.StrictHostnameVerifier()));
} else {
TLSUtils.acceptAllCertificates(builder);
TLSUtils.disableHostnameVerificationForTlsCertificicates(builder);
}
} catch (NoSuchAlgorithmException | KeyManagementException e) {
e.printStackTrace();
}
// setUpSASL();
final Map<String, String> registeredSASLMechanisms = SASLAuthentication.getRegisterdSASLMechanisms();
for (String mechanism : registeredSASLMechanisms.values()) {
SASLAuthentication.blacklistSASLMechanism(mechanism);
}
/*SASLAuthentication.blacklistSASLMechanism("DIGEST-MD5");*/
SASLAuthentication.unBlacklistSASLMechanism(SASLPlainMechanism.NAME);
xmppConnection = new XMPPTCPConnection(builder.build());
xmppConnection.addAsyncStanzaListener(this, ACCEPT_ALL);
xmppConnection.addConnectionListener(this);
// by default Smack disconnects in case of parsing errors
xmppConnection.setParsingExceptionCallback(new ExceptionLoggingCallback());
AccountRosterListener rosterListener = new AccountRosterListener(((AccountItem)connectionItem).getAccount());
final Roster roster = Roster.getInstanceFor(xmppConnection);
roster.addRosterListener(rosterListener);
roster.addRosterLoadedListener(rosterListener);
roster.setSubscriptionMode(Roster.SubscriptionMode.manual);
org.jivesoftware.smackx.ping.PingManager.getInstanceFor(xmppConnection).registerPingFailedListener(this);
connectionItem.onSRVResolved(this);
final String password = OAuthManager.getInstance().getPassword(protocol, token);
if (password != null) {
runOnConnectionThread(new Runnable() {
@Override
public void run() {
connect(password);
}
});
} else {
runOnConnectionThread(new Runnable() {
@Override
public void run() {
passwordRequest();
}
});
}
}
xmppConnection.login(login, password, resource);
Anyone faced this issue?
@ThameemAK why did you close the issue? if you were able to resolve it, please post your solution. I have the problem with another server, too.
We set false to this boolean(security_check_certificate_default) in preference.xml.. After that It won't ask for certificate verification. If you want to use SASL in your application, we have to create SASL certification, There are different types in SASL mechanism.
@ThameemAK can you please tell how did you set false to this boolean(security_check_certificate_default) in preference.xml
@huilgolAni19 In preference.xml(https://github.com/redsolution/xabber-android/blob/33314e05d69eadf012bd91bd00dbca03961a8e67/xabber/src/main/res/values/preferences.xml). I downloaded the project and add as module in my Project and changed the flag.