mirror of
https://codeberg.org/Mercury-IM/Smack
synced 2025-09-10 02:39:42 +02:00
Add smack-android and redesign SASL authentication
This commit marks an important milestone with the addition of the smack-android subproject. Smack is now able to run native on Android without requiring any modifications, which makes the aSmack build environment obsolete. It was necessary to redesign the code for SASL authentication to achieve this. Smack now comes with smack-sasl-provided for SASL implementations that do not rely on additional APIs like javax for platforms where those APIs are not available like Android.
This commit is contained in:
parent
5a2149718a
commit
89dc3a0e85
39 changed files with 1562 additions and 675 deletions
|
@ -35,9 +35,9 @@ import org.jivesoftware.smack.packet.Packet;
|
|||
import org.jivesoftware.smack.packet.Presence;
|
||||
import org.jivesoftware.smack.parsing.ParsingExceptionCallback;
|
||||
import org.jivesoftware.smack.parsing.UnparsablePacket;
|
||||
import org.jivesoftware.smack.sasl.SASLMechanism.Challenge;
|
||||
import org.jivesoftware.smack.sasl.SASLMechanism.SASLFailure;
|
||||
import org.jivesoftware.smack.sasl.SASLMechanism.Success;
|
||||
import org.jivesoftware.smack.sasl.packet.SaslStanzas.Challenge;
|
||||
import org.jivesoftware.smack.sasl.packet.SaslStanzas.SASLFailure;
|
||||
import org.jivesoftware.smack.sasl.packet.SaslStanzas.Success;
|
||||
import org.jivesoftware.smack.util.ArrayBlockingQueueWithShutdown;
|
||||
import org.jivesoftware.smack.util.PacketParserUtils;
|
||||
import org.jivesoftware.smack.util.TLSUtils;
|
||||
|
@ -54,7 +54,6 @@ import javax.net.ssl.SSLSocket;
|
|||
import javax.security.auth.callback.Callback;
|
||||
import javax.security.auth.callback.CallbackHandler;
|
||||
import javax.security.auth.callback.PasswordCallback;
|
||||
import javax.security.sasl.SaslException;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.BufferedWriter;
|
||||
|
@ -247,7 +246,7 @@ public class XMPPTCPConnection extends AbstractXMPPConnection {
|
|||
}
|
||||
|
||||
@Override
|
||||
public synchronized void login(String username, String password, String resource) throws XMPPException, SmackException, SaslException, IOException {
|
||||
public synchronized void login(String username, String password, String resource) throws XMPPException, SmackException, IOException {
|
||||
if (!isConnected()) {
|
||||
throw new NotConnectedException();
|
||||
}
|
||||
|
@ -266,7 +265,7 @@ public class XMPPTCPConnection extends AbstractXMPPConnection {
|
|||
saslAuthentication.authenticate(resource, config.getCallbackHandler());
|
||||
}
|
||||
} else {
|
||||
throw new SaslException("No non-anonymous SASL authentication mechanism available");
|
||||
throw new SmackException("No non-anonymous SASL authentication mechanism available");
|
||||
}
|
||||
|
||||
// If compression is enabled then request the server to use stream compression. XEP-170
|
||||
|
@ -312,7 +311,7 @@ public class XMPPTCPConnection extends AbstractXMPPConnection {
|
|||
}
|
||||
|
||||
@Override
|
||||
public synchronized void loginAnonymously() throws XMPPException, SmackException, SaslException, IOException {
|
||||
public synchronized void loginAnonymously() throws XMPPException, SmackException, IOException {
|
||||
if (!isConnected()) {
|
||||
throw new NotConnectedException();
|
||||
}
|
||||
|
@ -324,7 +323,7 @@ public class XMPPTCPConnection extends AbstractXMPPConnection {
|
|||
saslAuthentication.authenticateAnonymously();
|
||||
}
|
||||
else {
|
||||
throw new SaslException("No anonymous SASL authentication mechanism available");
|
||||
throw new SmackException("No anonymous SASL authentication mechanism available");
|
||||
}
|
||||
|
||||
String response = bindResourceAndEstablishSession(null);
|
||||
|
@ -1063,7 +1062,8 @@ public class XMPPTCPConnection extends AbstractXMPPConnection {
|
|||
getSASLAuthentication().challengeReceived(challengeData);
|
||||
}
|
||||
else if (name.equals("success")) {
|
||||
processPacket(new Success(parser.nextText()));
|
||||
Success success = new Success(parser.nextText());
|
||||
processPacket(success);
|
||||
// We now need to bind a resource for the connection
|
||||
// Open a new stream and wait for the response
|
||||
packetWriter.openStream();
|
||||
|
@ -1072,7 +1072,7 @@ public class XMPPTCPConnection extends AbstractXMPPConnection {
|
|||
resetParser();
|
||||
// The SASL authentication with the server was successful. The next step
|
||||
// will be to bind the resource
|
||||
getSASLAuthentication().authenticated();
|
||||
getSASLAuthentication().authenticated(success);
|
||||
}
|
||||
else if (name.equals("compressed")) {
|
||||
// Server confirmed that it's possible to use stream compression. Start
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue