Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormkuppe2008-12-16 09:27:49 -0500
committermkuppe2008-12-16 09:27:49 -0500
commit77926febe7179e807136a7e0297f74e47657dbab (patch)
tree3eb37a6c2b94663401dc5ff15304d06bf777c68d
parent31eb897616578c1faad852235cb2a19f881b88fc (diff)
downloadorg.eclipse.ecf-77926febe7179e807136a7e0297f74e47657dbab.tar.gz
org.eclipse.ecf-77926febe7179e807136a7e0297f74e47657dbab.tar.xz
org.eclipse.ecf-77926febe7179e807136a7e0297f74e47657dbab.zip
NEW - bug 258927: [Discovery][SLP] byte service properties aren't correctly converted into an octet sequence (Base64)
https://bugs.eclipse.org/bugs/show_bug.cgi?id=258927
-rw-r--r--providers/bundles/org.eclipse.ecf.provider.jslp/src/org/eclipse/ecf/internal/provider/jslp/ServicePropertiesAdapter.java13
1 files changed, 7 insertions, 6 deletions
diff --git a/providers/bundles/org.eclipse.ecf.provider.jslp/src/org/eclipse/ecf/internal/provider/jslp/ServicePropertiesAdapter.java b/providers/bundles/org.eclipse.ecf.provider.jslp/src/org/eclipse/ecf/internal/provider/jslp/ServicePropertiesAdapter.java
index d2002e619..f735fb9a6 100644
--- a/providers/bundles/org.eclipse.ecf.provider.jslp/src/org/eclipse/ecf/internal/provider/jslp/ServicePropertiesAdapter.java
+++ b/providers/bundles/org.eclipse.ecf.provider.jslp/src/org/eclipse/ecf/internal/provider/jslp/ServicePropertiesAdapter.java
@@ -12,8 +12,7 @@ package org.eclipse.ecf.internal.provider.jslp;
import java.util.*;
import org.eclipse.core.runtime.Assert;
-import org.eclipse.ecf.core.util.StringUtils;
-import org.eclipse.ecf.core.util.Trace;
+import org.eclipse.ecf.core.util.*;
import org.eclipse.ecf.discovery.*;
import org.eclipse.ecf.discovery.identity.IServiceID;
@@ -67,9 +66,10 @@ public class ServicePropertiesAdapter {
String[] strs = StringUtils.split(value.substring(4), "\\"); //$NON-NLS-1$
byte[] b = new byte[strs.length];
for (int i = 0; i < strs.length; i++) {
- b[i] = new Byte(strs[i]).byteValue();
+ byte parseInt = (byte) Integer.parseInt(strs[i], 16);
+ b[i] = parseInt;
}
- serviceProperties.setPropertyBytes(key, b);
+ serviceProperties.setPropertyBytes(key, Base64.decodeFromCharArray(b));
} else if (value.equalsIgnoreCase("true") || value.equalsIgnoreCase("false")) { //$NON-NLS-1$ //$NON-NLS-2$
serviceProperties.setProperty(key, new Boolean(value));
} else if (isInteger(value)) {
@@ -119,11 +119,12 @@ public class ServicePropertiesAdapter {
String key = (String) propertyNames.nextElement();
byte[] propertyBytes = serviceProperties.getPropertyBytes(key);
if (propertyBytes != null) {
+ byte[] encode = Base64.encodeToCharArray(propertyBytes);
StringBuffer buf = new StringBuffer();
buf.append(SLP_BYTE_PREFIX);
- for (int i = 0; i < propertyBytes.length; i++) {
+ for (int i = 0; i < encode.length; i++) {
buf.append("\\"); //$NON-NLS-1$
- buf.append(propertyBytes[i]);
+ buf.append(Integer.toHexString(encode[i]));
}
dict.put(key, buf.toString());
} else {

Back to the top