Author: werner
Date: Thu Jan 26 07:52:06 2006
New Revision: 372555

URL: http://svn.apache.org/viewcvs?rev=372555&view=rev
Log:
Add Id handling to Encrypt and Signature, add documentation.

Modified:
    webservices/wss4j/trunk/src/org/apache/ws/security/message/WSSecEncrypt.java
    
webservices/wss4j/trunk/src/org/apache/ws/security/message/WSSecSignature.java
    webservices/wss4j/trunk/src/org/apache/ws/security/message/package.html

Modified: 
webservices/wss4j/trunk/src/org/apache/ws/security/message/WSSecEncrypt.java
URL: 
http://svn.apache.org/viewcvs/webservices/wss4j/trunk/src/org/apache/ws/security/message/WSSecEncrypt.java?rev=372555&r1=372554&r2=372555&view=diff
==============================================================================
--- 
webservices/wss4j/trunk/src/org/apache/ws/security/message/WSSecEncrypt.java 
(original)
+++ 
webservices/wss4j/trunk/src/org/apache/ws/security/message/WSSecEncrypt.java 
Thu Jan 26 07:52:06 2006
@@ -222,6 +222,17 @@
        }
 
        /**
+        * Get the id generated during <code>prepare()</code>.
+        * 
+        * Returns the the value of wsu:Id attribute of the EncryptedKey 
element.
+        * 
+        * @return Return the wsu:Id of this token or null if 
<code>prepare()</code>
+        *         was not called before.
+        */
+       public String getId() {
+               return encKeyId;
+       }
+       /**
         * Initialize a WSSec Encrypt.
         * 
         * The method prepares and initializes a WSSec Encrypt structure after 
the
@@ -318,10 +329,7 @@
                 */
                xencEncryptedKey = createEnrcyptedKey(doc, keyEncAlgo);
                encKeyId = "EncKeyId-" + xencEncryptedKey.hashCode();
-               String prefix = WSSecurityUtil.setNamespace(xencEncryptedKey,
-                               WSConstants.WSU_NS, WSConstants.WSU_PREFIX);
-               xencEncryptedKey.setAttributeNS(WSConstants.WSU_NS, prefix + 
":Id",
-                               encKeyId);
+               xencEncryptedKey.setAttributeNS(null, "Id",     encKeyId);
 
                KeyInfo keyInfo = new KeyInfo(doc);
 

Modified: 
webservices/wss4j/trunk/src/org/apache/ws/security/message/WSSecSignature.java
URL: 
http://svn.apache.org/viewcvs/webservices/wss4j/trunk/src/org/apache/ws/security/message/WSSecSignature.java?rev=372555&r1=372554&r2=372555&view=diff
==============================================================================
--- 
webservices/wss4j/trunk/src/org/apache/ws/security/message/WSSecSignature.java 
(original)
+++ 
webservices/wss4j/trunk/src/org/apache/ws/security/message/WSSecSignature.java 
Thu Jan 26 07:52:06 2006
@@ -215,6 +215,21 @@
        }
 
        /**
+        * Get the id generated during <code>prepare()</code>.
+        * 
+        * Returns the the value of wsu:Id attribute of the Signature element.
+        * 
+        * @return Return the wsu:Id of this token or null if 
<code>prepare()</code>
+        *         was not called before.
+        */
+       public String getId() {
+               if (sig == null) {
+                       return null;
+               }
+               return sig.getId();
+       }
+
+       /**
         * Initialize a WSSec Signature.
         * 
         * The method sets up and initializes a WSSec Signature structure after 
the
@@ -319,6 +334,8 @@
                }
 
                sig.addResourceResolver(EnvelopeIdResolver.getInstance());
+               String sigUri = "Signature-" + sig.hashCode();
+               sig.setId(sigUri);
 
                keyInfo = sig.getKeyInfo();
                keyInfoUri = "KeyId-" + keyInfo.hashCode();

Modified: 
webservices/wss4j/trunk/src/org/apache/ws/security/message/package.html
URL: 
http://svn.apache.org/viewcvs/webservices/wss4j/trunk/src/org/apache/ws/security/message/package.html?rev=372555&r1=372554&r2=372555&view=diff
==============================================================================
--- webservices/wss4j/trunk/src/org/apache/ws/security/message/package.html 
(original)
+++ webservices/wss4j/trunk/src/org/apache/ws/security/message/package.html Thu 
Jan 26 07:52:06 2006
@@ -129,6 +129,21 @@
 <code>build()</code> method in the old classes. Thus, if the flexibilty is not
 required you may use this method for convenience.
 
+<h3>Each top level security element has wsu:Id or plain Id attribute</h3>
+The <code>prepare()</code> method autmatically generates an Id string for each 
new
+element and sets the wsu:Id or plain Id attribute. Which type 
+of Id to use is determined by the security element. The <e>EncryptedKey</e> 
and <e>Signature</e> 
+elements have a plain Id according to the W3C specifications, elements defined 
by 
+the OASIS WS Security specifications contain a wsu:Id. 
+<p/>
+Each <code>WSSec*</code> class has a <code>getId()</code> that returns the id 
strig
+regardless if its qualified or not.
+<p/>
+The security processing uses these Id to identify each top level security 
element to
+provide additional further processing of an element, for example to encrypt a 
Signature or
+any other top level element. Also a Signature may include each top level 
element. Which
+parts of a message to sign and/or encrypt is controlled by the Security Policy
+
 @since WSS4J 2.0
 </body>
 </html>



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to