If the action order on the outbound side is encrypt then sign and the signature parts include the XML Encryption elements by name and namespace, the signature action introduces a namespaced (wsu) Id attribute on the signed XML Encryption elements.
<xenc:EncryptedData xmlns:xenc="..." Id="EncDataId-659" Type="http://www.w3.org/2001/04/xmlenc#Element">
<xenc:EncryptedData xmlns:wsu="..." xmlns:xenc="..." Id="EncDataId-659" Type="http://www.w3.org/2001/04/xmlenc#Element" wsu:Id="id-663">
The signature is created with the reference to the wsu:Id attribute. The second attribute is not schema valid per the XML Encryption spec data structure . As the XML Encryption spec already defines an Id attribute on the appropriate data structures, WSS4J should leverage this preexisting attribute when creating signatures that reference the primary structures from XML Encryption.
As the XPointer definition requires that the attribute referenced is a schema defined ID , the preexisting Id attribute meets this requirement. While it could be considered a slippery slope to alter the signature code to accommodate the specific structure of arbitrary elements to be signed, the XML Encryption elements are well know structures and are deeply ingrained in WSS4J. Therefore, I feel that this change has a place in WSS4J. A more complete solution would include a pluggable strategy for allowing users to inject/reuse IDs on a per element basis; however, this issue and its patches are meant to resolve the immediate need related only to XML Encryption elements.