1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2024-11-26 05:52:06 +01:00

Configuration flag for disabling session request on login

Although this was mandatory on RFC 3921, RFC 6120/6121 don't even mention this part of the protocol.

Signed-off-by: Daniele Ricci <daniele.athome@gmail.com>
This commit is contained in:
Daniele Ricci 2014-03-15 14:47:55 +01:00
parent 364cbd81da
commit 596008e90a
2 changed files with 25 additions and 1 deletions

View file

@ -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

View file

@ -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();
}