From 391e7269e64fe29e2d7fa169b5d71ddc11ab81e9 Mon Sep 17 00:00:00 2001 From: Gaston Dombiak Date: Mon, 5 Sep 2005 22:03:47 +0000 Subject: [PATCH] Allow to perform SASL authentication over plain connections. SMACK-83 git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/trunk@2784 b35dd754-fafc-0310-a699-88a17e54d16e --- .../org/jivesoftware/smack/PacketReader.java | 44 +++++++++++++------ 1 file changed, 31 insertions(+), 13 deletions(-) diff --git a/source/org/jivesoftware/smack/PacketReader.java b/source/org/jivesoftware/smack/PacketReader.java index 148ed77ae..c1af2723d 100644 --- a/source/org/jivesoftware/smack/PacketReader.java +++ b/source/org/jivesoftware/smack/PacketReader.java @@ -288,16 +288,14 @@ class PacketReader { // Get the connection id. for (int i=0; i + * + * 1) An opening stream was sent from a non XMPP 1.0 compliant server + * 2) Stream features were received from an XMPP 1.0 compliant server that does not support TLS + * 3) TLS negotiation was successful + * + */ + private void releaseConnectionIDLock() { + synchronized(connectionIDLock) { + connectionIDLock.notifyAll(); + } + } + /** * Processes a packet after it's been fully parsed by looping through the installed * packet collectors and listeners and letting them examine the packet to see if @@ -390,17 +403,19 @@ class PacketReader { } private void parseFeatures(XmlPullParser parser) throws Exception { - boolean done = false; + boolean startTLSReceived = false; + boolean done = false; while (!done) { int eventType = parser.next(); if (eventType == XmlPullParser.START_TAG) { if (parser.getName().equals("starttls")) { + startTLSReceived = true; // Confirm the server that we want to use TLS connection.startTLSReceived(); } - else if (parser.getName().equals("mechanisms") && connection.isUsingTLS()) { - // The server is reporting available SASL mechanism. Store this information + else if (parser.getName().equals("mechanisms")) { + // The server is reporting available SASL mechanisms. Store this information // which will be used later while logging (i.e. authenticating) into // the server connection.getSASLAuthentication() @@ -421,6 +436,9 @@ class PacketReader { } } } + if (!startTLSReceived) { + releaseConnectionIDLock(); + } } /**