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

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
This commit is contained in:
Gaston Dombiak 2005-12-08 21:10:04 +00:00 committed by gato
parent 17e97fe0ee
commit 647d6323ca

View file

@ -273,12 +273,7 @@ public class SASLAuthentication implements UserAuthentication {
} }
} }
private String bindResourceAndEstablishSession(String resource) throws IOException, private String bindResourceAndEstablishSession(String resource) throws XMPPException {
XMPPException {
// We now need to bind a resource for the connection
// Open a new stream and wait for the response
connection.packetWriter.openStream();
// Wait until server sends response containing the <bind> element // Wait until server sends response containing the <bind> element
synchronized (this) { synchronized (this) {
if (!resourceBinded) { 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(); Bind bindResource = new Bind();
bindResource.setResource(resource); bindResource.setResource(resource);
@ -324,6 +324,10 @@ public class SASLAuthentication implements UserAuthentication {
throw new XMPPException(ack.getError()); throw new XMPPException(ack.getError());
} }
} }
else {
// Server never offered session establishment
throw new XMPPException("Session establishment not offered by server");
}
return userJID; return userJID;
} }