Index: SASLAuthentication.java =================================================================== --- SASLAuthentication.java (revision 3827) +++ SASLAuthentication.java (working copy) @@ -189,20 +189,29 @@ boolean ssComplete = ss.isComplete(); String response = doc.getTextTrim(); try { - byte[] data = StringUtils.decodeBase64(response); - if (data == null) { - data = new byte[0]; - } - if (ssComplete) { - authenticationSuccessful(ss.getAuthorizationID()); + authenticationSuccessful(ss.getAuthorizationID(), null); success = true; isComplete = true; } else { + byte[] data = StringUtils.decodeBase64(response); + if (data == null) { + data = new byte[0]; + } + byte[] challenge = ss.evaluateResponse(data); - // Send the challenge - sendChallenge(challenge); + if (ss.isComplete()) + { + authenticationSuccessful(ss.getAuthorizationID(), challenge); + success = true; + isComplete = true; + } + else + { + // Send the challenge + sendChallenge(challenge); + } } } catch (SaslException e) { @@ -244,7 +253,7 @@ private boolean doAnonymousAuthentication() { if (XMPPServer.getInstance().getIQAuthHandler().isAllowAnonymous()) { // Just accept the authentication :) - authenticationSuccessful(null); + authenticationSuccessful(null, null); return true; } else { @@ -282,7 +291,7 @@ } try { AuthToken token = AuthFactory.authenticate(username, password); - authenticationSuccessful(token.getUsername()); + authenticationSuccessful(token.getUsername(), null); return true; } catch (UnauthorizedException e) { @@ -318,7 +327,7 @@ boolean verify = JiveGlobals.getBooleanProperty("xmpp.server.certificate.verify", true); if (!verify) { - authenticationSuccessful(hostname); + authenticationSuccessful(hostname, null); return true; } } @@ -326,7 +335,7 @@ for (Certificate certificate : connection.getSSLSession().getPeerCertificates()) { if (TLSStreamHandler.getPeerIdentities((X509Certificate) certificate) .contains(hostname)) { - authenticationSuccessful(hostname); + authenticationSuccessful(hostname, null); return true; } } @@ -348,8 +357,17 @@ connection.deliverRawText(reply.toString()); } - private void authenticationSuccessful(String username) { - connection.deliverRawText(""); + private void authenticationSuccessful(String username, String successData) { + StringBuilder reply = new StringBuilder(80); + reply.append("" + successData + ""); + } + else + { + reply.append("/>"); + } + connection.deliverRawText(reply.toString()); // We only support SASL for c2s if (session instanceof ClientSession) { ((ClientSession) session).setAuthToken(new AuthToken(username));