diff --git a/core/src/main/java/org/jivesoftware/smack/ConnectionConfiguration.java b/core/src/main/java/org/jivesoftware/smack/ConnectionConfiguration.java index 567e56e6a..56bcd1ca1 100644 --- a/core/src/main/java/org/jivesoftware/smack/ConnectionConfiguration.java +++ b/core/src/main/java/org/jivesoftware/smack/ConnectionConfiguration.java @@ -17,6 +17,7 @@ package org.jivesoftware.smack; +import org.jivesoftware.smack.packet.Session; import org.jivesoftware.smack.proxy.ProxyInfo; import org.jivesoftware.smack.util.DNSUtil; import org.jivesoftware.smack.util.dns.HostAddress; @@ -77,6 +78,7 @@ public class ConnectionConfiguration implements Cloneable { private String resource; private boolean sendPresence = true; private boolean rosterLoadedAtLogin = true; + private boolean legacySessionDisabled = false; private SecurityMode securityMode = SecurityMode.enabled; /** @@ -449,6 +451,28 @@ public class ConnectionConfiguration implements Cloneable { this.rosterLoadedAtLogin = rosterLoadedAtLogin; } + /** + * Returns true if a {@link Session} will be requested on login if the server + * supports it. Although this was mandatory on RFC 3921, RFC 6120/6121 don't + * even mention this part of the protocol. + * + * @return true if a session has to be requested when logging in. + */ + public boolean isLegacySessionDisabled() { + return legacySessionDisabled; + } + + /** + * Sets if a {@link Session} will be requested on login if the server supports + * it. Although this was mandatory on RFC 3921, RFC 6120/6121 don't even + * mention this part of the protocol. + * + * @param legacySessionDisabled if a session has to be requested when logging in. + */ + public void setLegacySessionDisabled(boolean legacySessionDisabled) { + this.legacySessionDisabled = legacySessionDisabled; + } + /** * Returns a CallbackHandler to obtain information, such as the password or * principal information during the SASL authentication. A CallbackHandler diff --git a/core/src/main/java/org/jivesoftware/smack/SASLAuthentication.java b/core/src/main/java/org/jivesoftware/smack/SASLAuthentication.java index 8323d97cb..7c7e0e9a3 100644 --- a/core/src/main/java/org/jivesoftware/smack/SASLAuthentication.java +++ b/core/src/main/java/org/jivesoftware/smack/SASLAuthentication.java @@ -433,7 +433,7 @@ public class SASLAuthentication { Bind response = (Bind) connection.createPacketCollectorAndSend(bindResource).nextResultOrThrow(); String userJID = response.getJid(); - if (sessionSupported) { + if (sessionSupported && !connection.getConfiguration().isLegacySessionDisabled()) { Session session = new Session(); connection.createPacketCollectorAndSend(session).nextResultOrThrow(); }