cxf-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "AKROUR (JIRA)" <>
Subject [jira] [Created] (CXF-6328) Username of UsernameToken is null when it is provided as in a CDATA section
Date Thu, 02 Apr 2015 13:30:21 GMT
AKROUR created CXF-6328:

             Summary: Username of UsernameToken is null when it is provided as in a CDATA
                 Key: CXF-6328
             Project: CXF
          Issue Type: Bug
          Components: JAX-WS Runtime
    Affects Versions: 2.7.14
         Environment: Windows 
Java 7 SE
            Reporter: AKROUR
            Priority: Minor


A user invoking a WS, cannot be authenticated by a Username Token if its username is provided
in a CDATA section.

For instance, if the user uses the following username token:
<wsse:UsernameToken xmlns:wsse="">
then the username provided to the UsernameTokenValidator will be 'null' and not 'wernerd'.

The reason is the method nodeString(Element e) of the UsernameToken considers only node of
type TEXT. It should considers CDATA_SECTION_NODE too.

A fix could be something like that:
     * Returns the data of an element as String or null if either the the element
     * does not contain a Text node or the node is empty.
     * @param e DOM element
     * @return Element text node data as String
    private String nodeString(Element e) {
        if (e != null) {
            Node node = e.getFirstChild();
            StringBuilder builder = new StringBuilder();
            boolean found = false;
            while (node != null) {
                if (Node.TEXT_NODE == node.getNodeType()) {
                    found = true;
// FIX START                
                else if (Node.CDATA_SECTION_NODE == node.getNodeType()) {
                    found = true;
                node = node.getNextSibling();
           if (!found) {
                return null;
            return builder.toString();
        return null;

A workaround is not to send the username in CDATA.

This message was sent by Atlassian JIRA

View raw message