Good functionality, flexible API; just a couple of suggestions, related to
my experiences using the library to implement a subset of OASIS-WSSE:

1) expose fully specified encryptData method (required for customised
embedding of encrypted elements with control of content mode).

2) make key/data refs work for fragment URIs (my patch is a bit of a hack
for this, removing the validation, but at least applications can then use
these refs) A more elaborate fix may be possible, but I don't really want
to dig that deeply into the URI code.

diff attached

C

Index: XMLCipher.java
===================================================================
RCS file: 
/home/cvspublic/xml-security/src/org/apache/xml/security/encryption/XMLCipher.java,v
retrieving revision 1.34
diff -r1.34 XMLCipher.java
909c909,923
<     private EncryptedData encryptData(Document context, Element element, 
boolean contentMode) throws
---
> 
>     /**
>      * Returns an <code>EncryptedData</code> interface. Use this operation if
>      * you want to have full control over the contents of the
>      * <code>EncryptedData</code> structure.
>        *
>        * This does not change the source document in any way.
>      *
>      *
>      * @param context the context <code>Document</code>.
>      * @param element the <code>Element</code> that will be encrypted.
>      * @param contentMode true if element content only is to be encrypted
>      * @throws XMLEncryptionException.
>      */
>     public EncryptedData encryptData(Document context, Element element, 
> boolean contentMode) throws // cbrettin changed to public
2556,2564c2570,2575
<                 list = element.getElementsByTagNameNS(
<                     EncryptionConstants.EncryptionSpecNS, 
<                     EncryptionConstants._TAG_DATAREFERENCE);
<                 for (int i = 0; i < list.getLength() ; i++) {
<                     String uri = null;
<                     try {
<                         uri = new URI(
<                             ((Element) 
list.item(0)).getNodeValue()).toString();
<                     } catch (URI.MalformedURIException mfue) {
---
>                     list = element.getElementsByTagNameNS(
>                         EncryptionConstants.EncryptionSpecNS, 
>                         EncryptionConstants._TAG_DATAREFERENCE);
>                     for (int i = 0; i < list.getLength() ; i++) {
>                         String uri = ((Element) 
> list.item(i)).getAttribute("URI");
>                         result.add(result.newDataReference(uri));
2566,2567c2577
<                     result.add(result.newDataReference(uri));
<                 }
---
>                     break;
2569,2577c2579,2584
<                 list = element.getElementsByTagNameNS(
<                     EncryptionConstants.EncryptionSpecNS, 
<                     EncryptionConstants._TAG_KEYREFERENCE);
<                 for (int i = 0; i < list.getLength() ; i++) {
<                     String uri = null;
<                     try {
<                         uri = new URI(
<                             ((Element) 
list.item(0)).getNodeValue()).toString();
<                     } catch (URI.MalformedURIException mfue) {
---
>                     list = element.getElementsByTagNameNS(
>                         EncryptionConstants.EncryptionSpecNS, 
>                         EncryptionConstants._TAG_KEYREFERENCE);
>                     for (int i = 0; i < list.getLength() ; i++) {
>                         String uri = ((Element) 
> list.item(i)).getAttribute("URI");
>                         result.add(result.newKeyReference(uri));
2579,2580d2585
<                     result.add(result.newKeyReference(uri));
<                 }

Reply via email to