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
1 changed files with 10 additions and 6 deletions

View File

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