Skip to content
Snippets Groups Projects
Commit 5551f94c authored by ribeaudc's avatar ribeaudc
Browse files

Using commons-lang for xmlEn/Decoding.

SVN: 109
parent defb6239
No related branches found
No related tags found
No related merge requests found
...@@ -21,6 +21,7 @@ import java.text.MessageFormat; ...@@ -21,6 +21,7 @@ import java.text.MessageFormat;
import org.apache.commons.httpclient.HttpClient; import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.methods.PostMethod; import org.apache.commons.httpclient.methods.PostMethod;
import org.apache.commons.httpclient.methods.StringRequestEntity; import org.apache.commons.httpclient.methods.StringRequestEntity;
import org.apache.commons.lang.StringEscapeUtils;
import ch.systemsx.cisd.authentication.IAuthenticationService; import ch.systemsx.cisd.authentication.IAuthenticationService;
import ch.systemsx.cisd.common.exceptions.CheckedExceptionTunnel; import ch.systemsx.cisd.common.exceptions.CheckedExceptionTunnel;
...@@ -84,8 +85,8 @@ public class CrowdAuthenticationService implements IAuthenticationService ...@@ -84,8 +85,8 @@ public class CrowdAuthenticationService implements IAuthenticationService
public boolean authenticate(String user, String password) public boolean authenticate(String user, String password)
{ {
String applicationToken = xmlEncode(execute("token", AUTHENTICATE_APPL, application, applicationPassword)); String applicationToken = StringEscapeUtils.unescapeXml(execute("token", AUTHENTICATE_APPL, application, applicationPassword));
String userToken = xmlEncode(execute("out", AUTHENTICATE_USER, application, applicationToken, user, password)); String userToken = StringEscapeUtils.unescapeXml(execute("out", AUTHENTICATE_USER, application, applicationToken, user, password));
return userToken != null; return userToken != null;
} }
...@@ -94,7 +95,7 @@ public class CrowdAuthenticationService implements IAuthenticationService ...@@ -94,7 +95,7 @@ public class CrowdAuthenticationService implements IAuthenticationService
Object[] decodedArguments = new Object[args.length]; Object[] decodedArguments = new Object[args.length];
for (int i = 0; i < args.length; i++) for (int i = 0; i < args.length; i++)
{ {
decodedArguments[i] = xmlDecode(args[i]); decodedArguments[i] = StringEscapeUtils.escapeXml(args[i]);
} }
String response = execute(template.format(decodedArguments)); String response = execute(template.format(decodedArguments));
return pickElementContent(response, responseElement); return pickElementContent(response, responseElement);
...@@ -144,38 +145,4 @@ public class CrowdAuthenticationService implements IAuthenticationService ...@@ -144,38 +145,4 @@ public class CrowdAuthenticationService implements IAuthenticationService
} }
} }
private String xmlDecode(String text)
{
StringBuilder builder = new StringBuilder();
for (int i = 0, n = text.length(); i < n; i++)
{
char c = text.charAt(i);
switch (c)
{
case '<':
builder.append("&lt;");
break;
case '>':
builder.append("&gt;");
break;
case '&':
builder.append("&amp;");
break;
case '"':
builder.append("&quot;");
break;
default:
builder.append(c);
break;
}
}
return new String(builder);
}
private String xmlEncode(String xml)
{
// TODO implementation
return xml;
}
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment