Commit d064c3ee authored by Gaston Dombiak's avatar Gaston Dombiak Committed by gato

Fixed base64 encoding problem. JM-644

git-svn-id: http://svn.igniterealtime.org/svn/repos/wildfire/trunk@3784 b35dd754-fafc-0310-a699-88a17e54d16e
parent 73c80095
......@@ -203,7 +203,6 @@ public class StringUtils {
for (; i < len; i++) {
ch = input[i];
if (ch > '>') {
continue;
}
else if (ch == '<') {
if (i + 3 < len && input[i + 1] == 'b' && input[i + 2] == 'r' && input[i + 3] == '>') {
......@@ -250,7 +249,6 @@ public class StringUtils {
for (; i < len; i++) {
ch = input[i];
if (ch > '>') {
continue;
}
else if (ch == '<') {
if (i > last) {
......@@ -425,7 +423,7 @@ public class StringUtils {
public static String encodeBase64(String data) {
byte[] bytes = null;
try {
bytes = data.getBytes("ISO-8859-1");
bytes = data.getBytes("UTF-8");
}
catch (UnsupportedEncodingException uee) {
Log.error(uee);
......@@ -453,14 +451,8 @@ public class StringUtils {
* @param data a base64 encoded String to decode.
* @return the decoded String.
*/
public static String decodeBase64(String data) {
byte [] bytes = Base64.decode(data);
try {
return new String(bytes, "UTF-8");
}
catch (UnsupportedEncodingException uee) {
return new String(bytes);
}
public static byte[] decodeBase64(String data) {
return Base64.decode(data);
}
/**
......@@ -754,7 +746,6 @@ public class StringUtils {
for (; i < len; i++) {
ch = input[i];
if (ch > '>') {
continue;
}
else if (ch == '<') {
if (i > last) {
......
......@@ -165,8 +165,7 @@ public class SASLAuthentication {
byte[] token = new byte[0];
if (doc.isTextOnly()) {
// If auth request includes a value then validate it
token = StringUtils.decodeBase64(doc.getText())
.getBytes(CHARSET);
token = StringUtils.decodeBase64(doc.getText());
if (token == null) {
token = new byte[0];
}
......@@ -190,7 +189,7 @@ public class SASLAuthentication {
boolean ssComplete = ss.isComplete();
String response = doc.getTextTrim();
try {
byte[] data = StringUtils.decodeBase64(response).getBytes(CHARSET);
byte[] data = StringUtils.decodeBase64(response);
if (data == null) {
data = new byte[0];
}
......@@ -272,7 +271,7 @@ public class SASLAuthentication {
if (response != null && response.length() > 0) {
// Parse data and obtain username & password
String data = StringUtils.decodeBase64(response);
String data = new String(StringUtils.decodeBase64(response), CHARSET);
StringTokenizer tokens = new StringTokenizer(data, "\0");
if (tokens.countTokens() > 2) {
// Skip the "authorization identity"
......@@ -311,7 +310,7 @@ public class SASLAuthentication {
}
if (hostname != null && hostname.length() > 0) {
hostname = StringUtils.decodeBase64(hostname);
hostname = new String(StringUtils.decodeBase64(hostname), CHARSET);
// Check if cerificate validation is disabled for s2s
if (session instanceof IncomingServerSession) {
// Flag that indicates if certificates of the remote server should be validated.
......@@ -373,7 +372,7 @@ public class SASLAuthentication {
// Give a number of retries before closing the connection
Integer retries = (Integer) session.getSessionData("authRetries");
if (retries == null) {
retries = new Integer(1);
retries = 1;
}
else {
retries = retries + 1;
......
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