Browse Source

Fix processing of base-64 encoded data

David Boreham 20 years ago
parent
commit
d610a501a0

+ 1 - 1
ldap/clients/dsmlgw/src/com/netscape/dsml/gateway/OperationAdd.java

@@ -32,7 +32,7 @@ public class OperationAdd extends GenericOperation {
                         attr = attr.getNextSibling();
                       
                     String attrName = nl.item(i).getAttributes().getNamedItem("name").getNodeValue();
-                    String attrValue;
+                    byte[] attrValue;
                     
                     if (nl.item(i).getFirstChild().getNodeType() == Node.ELEMENT_NODE)
                         attrValue = ParseValue.parseValueFromNode( nl.item(i).getFirstChild()  );

+ 5 - 4
ldap/clients/dsmlgw/src/com/netscape/dsml/gateway/ParseValue.java

@@ -14,8 +14,8 @@ public class ParseValue {
     public ParseValue() {
     }
     
-    public static String parseValueFromNode(org.w3c.dom.Node n) {
-        String ret = null;
+    public static byte[] parseValueFromNode(org.w3c.dom.Node n) {
+        byte[] ret = null;
         // <xsd:union memberTypes="xsd:string xsd:base64Binary xsd:anyURI"/>
         
         org.w3c.dom.Node type = n.getAttributes().getNamedItem("xsi:type");
@@ -23,9 +23,10 @@ public class ParseValue {
             // This value is encoded in base64. decode it.
             sun.misc.BASE64Decoder bd = new sun.misc.BASE64Decoder();
             try {
-                ret = new String( bd.decodeBuffer( n.getFirstChild().getNodeValue() ) ) ; 
+                ret = bd.decodeBuffer( n.getFirstChild().getNodeValue() )  ; 
             } 
             catch (org.w3c.dom.DOMException de) {
+                ret = "".getBytes();
             }
             catch (Exception e) {
                 // couldn't decode auth info
@@ -33,7 +34,7 @@ public class ParseValue {
             
         } else {
             // anyURI is unsupported.
-            ret = new String(n.getFirstChild().getNodeValue());
+            ret = new String(n.getFirstChild().getNodeValue()).getBytes();
             
         }
         return ret;