Commit 8cfc049d authored by Armando Jagucki's avatar Armando Jagucki Committed by ajagucki

Re-encode the clearspace group chat auth token to base64 before sending it to the web service.

git-svn-id: http://svn.igniterealtime.org/svn/repos/openfire/trunk@10000 b35dd754-fafc-0310-a699-88a17e54d16e
parent b0613250
package org.jivesoftware.openfire.clearspace;
import javax.security.sasl.SaslServer;
import org.dom4j.Element;
import static org.jivesoftware.openfire.clearspace.ClearspaceManager.HttpType.GET;
import org.jivesoftware.util.Log;
import org.jivesoftware.util.StringUtils;
import javax.security.sasl.SaslException;
import javax.security.sasl.SaslServer;
import java.util.StringTokenizer;
import static org.jivesoftware.openfire.clearspace.ClearspaceManager.HttpType.GET;
import org.dom4j.Element;
/**
* Implements the CLEARSPACE server-side SASL mechanism.
*
......@@ -55,9 +57,10 @@ public class ClearspaceSaslServer implements SaslServer {
*/
public byte[] evaluateResponse(byte[] response) throws SaslException {
ClearspaceManager csManager = ClearspaceManager.getInstance();
String responseStr = new String(response);
// Parse data and obtain jid & auth token
StringTokenizer tokens = new StringTokenizer(new String(response), "\u0000");
// Parse data and obtain jid & random string
StringTokenizer tokens = new StringTokenizer(responseStr, "\u0000");
if (tokens.countTokens() != 2) {
// Info was not provided correctly
completed = false;
......@@ -65,15 +68,15 @@ public class ClearspaceSaslServer implements SaslServer {
}
jid = tokens.nextToken();
String authToken = tokens.nextToken();
try {
Element resultElement = csManager.executeRequest(GET, "groupChatAuthService/isAuthTokenValid/" + authToken);
responseStr = StringUtils.encodeBase64(responseStr);
Element resultElement = csManager.executeRequest(GET, "groupChatAuthService/isAuthTokenValid/" + responseStr);
if ("true".equals(WSUtils.getReturn(resultElement))) {
completed = true;
}
} catch (Exception e) {
e.printStackTrace();
Log.error("Failed communicating with Clearspace" , e);
}
return null;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment