Hi can someone help? I want to report some bugs but there does not seem to
be a bugzillia entry for this project.

I'm testing on a non-ANSI system and I am getting a few code-page problems.
The fixed code is detailed below. There were also a couple of fixes required
for the xml-security project as well. These are all issue relating to
calling string.getBytes(), resulting in the xml being returned as as an
EBIDIC code-page byte-array. The fix is to use string.getBytes("UTF-8"). The
modified code has been tested on Windows & z/OS for both username token &
X509.

Please advise, thanks, Dan.



org.apache.ws.security.WSSecurityEngine:
--------------------------------------------------------------

   public static byte[] getDecodedBase64EncodedData(Element element) throws
WSSecurityException {
        StringBuffer sb = new StringBuffer();
        NodeList children = element.getChildNodes();
        int iMax = children.getLength();
        for (int i = 0; i < iMax; i++) { 
            Node curr = children.item(i);
            if (curr.getNodeType() == Node.TEXT_NODE)
                sb.append(((Text) curr).getData());
        }
        String encodedData = sb.toString();
        try {
            return Base64.decode(encodedData.getBytes("UTF-8")); //
****************** CodePageFixDan
        } catch (Exception e) {
            throw new WSSecurityException(WSSecurityException.FAILURE,
                    null,
                    null,
                    e);
        }
    }


org.apache.ws.security.message.token.BinarySecurity:
----------------------------------------------------------------------------
----

    public byte[] getToken() {
        Text node = getFirstNode();
        if (node == null) {
                System.out.println("getFirstNode() = null");
            return null;
        }
        try {
            return Base64.decode(node.getData().getBytes("UTF-8")); //
****************** CodePageFixDan

        } catch (Exception e) {
                e.printStackTrace();
            return null;
        }
    }


org.apache.xml.security.encryption.XMLCipherInput:
---------------------------------------------------------------------------

private byte[] getDecryptBytes() throws XMLEncryptionException {
...
...
        try {
                encryptedBytes =
Base64.decode(base64EncodedEncryptedOctets.getBytes("UTF-8")); //
****************** CodePageFixDan

        } catch (Exception bde) {
            throw new XMLEncryptionException("empty", bde);
        }

                return (encryptedBytes);
}


org.apache.xml.security.utils.Base64:
------------------------------------------------------

   public final static byte[] decode(String encoded) throws
Base64DecodingException {

       if (encoded == null)
           return null;

       try {
                return decodeInternal(encoded.getBytes("UTF-8")); //
****************** CodePageFixDan

        } catch (Exception e) {
                e.printStackTrace();
                return null;
        }
   }


org.apache.xml.security.utils.XMLUtils:
--------------------------------------------------------

   public static void outputDOM(Node contextNode, OutputStream os,
                                boolean addPreamble) {

      try {
         if (addPreamble) {
            os.write("<?xml version=\"1.0\"
encoding=\"UTF-8\"?>\n".getBytes("UTF-8")); // ******************
CodePageFixDan
         }

         os.write(
            Canonicalizer.getInstance(
 
Canonicalizer.ALGO_ID_C14N_WITH_COMMENTS).canonicalizeSubtree(
               contextNode));
      } catch (IOException ex) {}
      catch (InvalidCanonicalizerException ex) {
         ex.printStackTrace();
      } catch (CanonicalizationException ex) {
         ex.printStackTrace();
      }
   }





**********************************************************************
This email and any files sent with it are intended only for the named
recipient. If you are not the named recipient please telephone/email
the sender immediately. You should not disclose the content or
take/retain/distribute any copies.
**********************************************************************



Norwich Union Insurance Limited 
Registered Office 8 Surrey Street Norwich, NR1 3NG
Registered in England Number 99122 
Member of the General Insurance Standards Council 
Authorised and Regulated by the Financial Services Authority

For Further enquiries 01603 622200

Reply via email to