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; }