From 647d6323ca7b5190a7a63d45427bd318ea699165 Mon Sep 17 00:00:00 2001 From: Gaston Dombiak Date: Thu, 8 Dec 2005 21:10:04 +0000 Subject: [PATCH] Request resource binding or session establishment only if they were provided by the server. SMACK-110 git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/trunk@3178 b35dd754-fafc-0310-a699-88a17e54d16e --- .../jivesoftware/smack/SASLAuthentication.java | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/source/org/jivesoftware/smack/SASLAuthentication.java b/source/org/jivesoftware/smack/SASLAuthentication.java index 1ff36aca9..7b5aa48fc 100644 --- a/source/org/jivesoftware/smack/SASLAuthentication.java +++ b/source/org/jivesoftware/smack/SASLAuthentication.java @@ -273,12 +273,7 @@ public class SASLAuthentication implements UserAuthentication { } } - private String bindResourceAndEstablishSession(String resource) throws IOException, - XMPPException { - // We now need to bind a resource for the connection - // Open a new stream and wait for the response - connection.packetWriter.openStream(); - + private String bindResourceAndEstablishSession(String resource) throws XMPPException { // Wait until server sends response containing the element synchronized (this) { if (!resourceBinded) { @@ -289,6 +284,11 @@ public class SASLAuthentication implements UserAuthentication { } } + if (!resourceBinded) { + // Server never offered resource binding + throw new XMPPException("Resource binding not offered by server"); + } + Bind bindResource = new Bind(); bindResource.setResource(resource); @@ -324,6 +324,10 @@ public class SASLAuthentication implements UserAuthentication { throw new XMPPException(ack.getError()); } } + else { + // Server never offered session establishment + throw new XMPPException("Session establishment not offered by server"); + } return userJID; }