Author: werner
Date: Fri Jan 27 04:14:41 2006
New Revision: 372821

URL: http://svn.apache.org/viewcvs?rev=372821&view=rev
Log:
Store processed security elements during parsing. This enables back references 
to these elements and the data contained in these elements.
Another step to Policy language handling.

Removed:
    
webservices/wss4j/trunk/src/org/apache/ws/security/message/token/KeyInfo.java
Modified:
    webservices/wss4j/trunk/src/org/apache/ws/security/WSDocInfo.java
    webservices/wss4j/trunk/src/org/apache/ws/security/WSSConfig.java
    webservices/wss4j/trunk/src/org/apache/ws/security/WSSecurityEngine.java
    
webservices/wss4j/trunk/src/org/apache/ws/security/processor/EncryptedKeyProcessor.java
    webservices/wss4j/trunk/src/org/apache/ws/security/processor/Processor.java
    
webservices/wss4j/trunk/src/org/apache/ws/security/processor/ReferenceListProcessor.java
    
webservices/wss4j/trunk/src/org/apache/ws/security/processor/SAMLTokenProcessor.java
    
webservices/wss4j/trunk/src/org/apache/ws/security/processor/SignatureConfirmationProcessor.java
    
webservices/wss4j/trunk/src/org/apache/ws/security/processor/SignatureProcessor.java
    
webservices/wss4j/trunk/src/org/apache/ws/security/processor/TimestampProcessor.java
    
webservices/wss4j/trunk/src/org/apache/ws/security/processor/UsernameTokenProcessor.java

Modified: webservices/wss4j/trunk/src/org/apache/ws/security/WSDocInfo.java
URL: 
http://svn.apache.org/viewcvs/webservices/wss4j/trunk/src/org/apache/ws/security/WSDocInfo.java?rev=372821&r1=372820&r2=372821&view=diff
==============================================================================
--- webservices/wss4j/trunk/src/org/apache/ws/security/WSDocInfo.java (original)
+++ webservices/wss4j/trunk/src/org/apache/ws/security/WSDocInfo.java Fri Jan 
27 04:14:41 2006
@@ -32,6 +32,7 @@
  */
 
 import org.apache.ws.security.components.crypto.Crypto;
+import org.apache.ws.security.processor.Processor;
 import org.w3c.dom.Element;
 
 import java.util.Enumeration;
@@ -42,6 +43,7 @@
     Crypto crypto = null;
     Vector bst = null;
     Element assertion = null;
+    Vector processors = null;
 
     public WSDocInfo(int hash) {
         this.hash = hash;
@@ -56,7 +58,12 @@
         if (bst != null && bst.size() > 0) {
             bst.removeAllElements();
         }
+        if (processors != null && processors.size() > 0) {
+               processors.removeAllElements();
+        }
+        
         bst = null;
+        processors = null;
     }
 
     /**
@@ -81,6 +88,43 @@
         return elem;
     }
 
+    /**
+     * Get a Processor for the given Id
+     *
+     * @param id is the Id to look for
+     * @return the Security processor identified with this Id or null if 
nothing found
+     */
+    public Processor getProcessor(String id) {
+       
+       if (id == null) {
+               return null;
+       }
+
+       Processor p = null;
+        if (processors != null) {
+            for (Enumeration e = processors.elements(); e.hasMoreElements();) {
+                p = (Processor) e.nextElement();
+                String cId = p.getId();
+                if (id.equals(cId)) {
+                    break;
+                }
+            }
+        }
+        return p;
+    }
+    
+    /**
+     * Store a Processor for later access.
+     * 
+     * @param p is the Processor to store
+     */
+    public void setProcessor(Processor p) {
+        if (processors == null) {
+               processors = new Vector();
+        }
+        processors.add(p);
+    }
+    
     /**
      * @return the signature crypto class used to process
      *         the signature/verfiy

Modified: webservices/wss4j/trunk/src/org/apache/ws/security/WSSConfig.java
URL: 
http://svn.apache.org/viewcvs/webservices/wss4j/trunk/src/org/apache/ws/security/WSSConfig.java?rev=372821&r1=372820&r2=372821&view=diff
==============================================================================
--- webservices/wss4j/trunk/src/org/apache/ws/security/WSSConfig.java (original)
+++ webservices/wss4j/trunk/src/org/apache/ws/security/WSSConfig.java Fri Jan 
27 04:14:41 2006
@@ -46,7 +46,7 @@
  * <p/>
  *
  * @author Rami Jaamour ([EMAIL PROTECTED])
- * @author Werner Dittmann ([EMAIL PROTECTED])
+ * @author Werner Dittmann ([EMAIL PROTECTED])
  */
 public class WSSConfig {
     private static Log log = LogFactory.getLog(WSSConfig.class.getName());

Modified: 
webservices/wss4j/trunk/src/org/apache/ws/security/WSSecurityEngine.java
URL: 
http://svn.apache.org/viewcvs/webservices/wss4j/trunk/src/org/apache/ws/security/WSSecurityEngine.java?rev=372821&r1=372820&r2=372821&view=diff
==============================================================================
--- webservices/wss4j/trunk/src/org/apache/ws/security/WSSecurityEngine.java 
(original)
+++ webservices/wss4j/trunk/src/org/apache/ws/security/WSSecurityEngine.java 
Fri Jan 27 04:14:41 2006
@@ -248,8 +248,14 @@
             }
             QName el = new QName(elem.getNamespaceURI(), elem.getLocalName());
             Processor p = wssConfig.getProcessor(el);
+            /*
+             * Call the processor for this token. After the processor returns, 
+             * store it for later retrival. The token processor may store some
+             * information about the processed token
+             */
             if (p != null) {
                 p.handleToken((Element) elem, sigCrypto, decCrypto, cb, 
wsDocInfo, returnResults, wssConfig);
+                wsDocInfo.setProcessor(p);
             } else {
                 /*
                 * Add check for a BinarySecurityToken, add info to WSDocInfo. 
If BST is

Modified: 
webservices/wss4j/trunk/src/org/apache/ws/security/processor/EncryptedKeyProcessor.java
URL: 
http://svn.apache.org/viewcvs/webservices/wss4j/trunk/src/org/apache/ws/security/processor/EncryptedKeyProcessor.java?rev=372821&r1=372820&r2=372821&view=diff
==============================================================================
--- 
webservices/wss4j/trunk/src/org/apache/ws/security/processor/EncryptedKeyProcessor.java
 (original)
+++ 
webservices/wss4j/trunk/src/org/apache/ws/security/processor/EncryptedKeyProcessor.java
 Fri Jan 27 04:14:41 2006
@@ -56,8 +56,9 @@
     private static Log tlog =
             LogFactory.getLog("org.apache.ws.security.TIME");
 
-    byte[] decryptedBytes = null;
-    WSSConfig wssConfig = null;
+    private byte[] decryptedBytes = null;
+    private WSSConfig wssConfig = null;
+    private String encryptedKeyId = null;
 
     public void handleToken(Element elem, Crypto crypto, Crypto decCrypto, 
CallbackHandler cb, WSDocInfo wsDocInfo, Vector returnResults, WSSConfig wsc) 
throws WSSecurityException {
         if (log.isDebugEnabled()) {
@@ -73,6 +74,8 @@
                     "noCallback");
         }
         handleEncryptedKey((Element) elem, cb, decCrypto);
+        encryptedKeyId = elem.getAttributeNS(null, "Id");
+
         returnResults.add(0, new WSSecurityEngineResult(WSConstants.ENCR, 
null, null, null, null));
     }
 
@@ -135,10 +138,14 @@
                 Element secRefToken;
                 secRefToken = (Element) WSSecurityUtil.getDirectChild(keyInfo,
                         "SecurityTokenReference", WSConstants.WSSE_NS);
-                if (secRefToken == null) {
-                    secRefToken = (Element) 
WSSecurityUtil.getDirectChild(keyInfo,
-                            "KeyName", WSConstants.SIG_NS);
-                }
+                /*
+                 * EncryptedKey must a a STR as child of KeyInfo, KeyName  
+                 * valid only for EncryptedData
+                 */
+//                if (secRefToken == null) {
+//                    secRefToken = (Element) 
WSSecurityUtil.getDirectChild(keyInfo,
+//                            "KeyName", WSConstants.SIG_NS);
+//                }
                 if (secRefToken == null) {
                     throw new WSSecurityException
                             (WSSecurityException.INVALID_SECURITY, 
"noSecTokRef");
@@ -403,6 +410,25 @@
         }
     }
 
+    /**
+     * Get the Id of the encrypted key element.
+     * 
+     * @return The Id string
+     */
+    public String getId() {
+       return encryptedKeyId;
+    }
+    
+    
+    /**
+     * Get the decrypted key.
+     * 
+     * The encrypted key element contains an encrypted session key. The
+     * security functions use the session key to encrypt contents of the 
message
+     * with symmetrical encryption methods.
+     *  
+     * @return The decrypted key.
+     */
     public byte[] getDecryptedBytes() {
         return decryptedBytes;
     }

Modified: 
webservices/wss4j/trunk/src/org/apache/ws/security/processor/Processor.java
URL: 
http://svn.apache.org/viewcvs/webservices/wss4j/trunk/src/org/apache/ws/security/processor/Processor.java?rev=372821&r1=372820&r2=372821&view=diff
==============================================================================
--- webservices/wss4j/trunk/src/org/apache/ws/security/processor/Processor.java 
(original)
+++ webservices/wss4j/trunk/src/org/apache/ws/security/processor/Processor.java 
Fri Jan 27 04:14:41 2006
@@ -30,4 +30,11 @@
        public void handleToken(Element elem, Crypto crypto, Crypto decCrypto,
                        CallbackHandler cb, WSDocInfo wsDocInfo, Vector 
returnResults,
                        WSSConfig config) throws WSSecurityException;
+       
+    /**
+     * Get the Id of the processoer.
+     * 
+     * @return The Id string
+     */
+       public String getId();
 }

Modified: 
webservices/wss4j/trunk/src/org/apache/ws/security/processor/ReferenceListProcessor.java
URL: 
http://svn.apache.org/viewcvs/webservices/wss4j/trunk/src/org/apache/ws/security/processor/ReferenceListProcessor.java?rev=372821&r1=372820&r2=372821&view=diff
==============================================================================
--- 
webservices/wss4j/trunk/src/org/apache/ws/security/processor/ReferenceListProcessor.java
 (original)
+++ 
webservices/wss4j/trunk/src/org/apache/ws/security/processor/ReferenceListProcessor.java
 Fri Jan 27 04:14:41 2006
@@ -25,6 +25,8 @@
 import org.apache.ws.security.WSSecurityEngineResult;
 import org.apache.ws.security.WSSecurityException;
 import org.apache.ws.security.components.crypto.Crypto;
+import org.apache.ws.security.message.token.SecurityTokenReference;
+import org.apache.ws.security.message.token.Reference;
 import org.apache.ws.security.util.WSSecurityUtil;
 import org.apache.xml.security.encryption.XMLCipher;
 import org.apache.xml.security.encryption.XMLEncryptionException;
@@ -37,91 +39,112 @@
 import java.util.Vector;
 
 public class ReferenceListProcessor implements Processor {
-    private static Log log = 
LogFactory.getLog(ReferenceListProcessor.class.getName());
-    
-    WSSConfig wssConfig = null;    
-
-    public void handleToken(Element elem, Crypto crypto, Crypto decCrypto, 
CallbackHandler cb, WSDocInfo wsDocInfo, Vector returnResults, WSSConfig wsc) 
throws WSSecurityException {
-        if (log.isDebugEnabled()) {
-            log.debug("Found reference list element");
-        }
-        wssConfig = wsc;        
-        if (cb == null) {
-            throw new WSSecurityException(WSSecurityException.FAILURE,
-                    "noCallback");
-        }
-        handleReferenceList((Element) elem, cb);
-        returnResults.add(0, new WSSecurityEngineResult(WSConstants.ENCR, 
null, null, null, null));
-    }
-
-    /**
-     * Dereferences and decodes encrypted data elements.
-     *
-     * @param elem contains the <code>ReferenceList</code> to the
-     *             encrypted data elements
-     * @param cb   the callback handler to get the key for a key name
-     *             stored if <code>KeyInfo</code> inside the encrypted
-     *             data elements
-     */
-    private void handleReferenceList(Element elem, CallbackHandler cb)
-            throws WSSecurityException {
-
-        Document doc = elem.getOwnerDocument();
-
-        Node tmpE = null;
-        for (tmpE = elem.getFirstChild();
-             tmpE != null;
-             tmpE = tmpE.getNextSibling()) {
-            if (tmpE.getNodeType() != Node.ELEMENT_NODE) {
-                continue;
-            }
-            if (!tmpE.getNamespaceURI().equals(WSConstants.ENC_NS)) {
-                continue;
-            }
-            if (tmpE.getLocalName().equals("DataReference")) {
-                String dataRefURI = ((Element) tmpE).getAttribute("URI");
-                decryptDataRefEmbedded(doc, dataRefURI, cb);
-            }
-        }
-    }
-
-    public void decryptDataRefEmbedded(Document doc,
-                                       String dataRefURI,
-                                       CallbackHandler cb)
-            throws WSSecurityException {
-
-        if (log.isDebugEnabled()) {
-            log.debug("Embedded found data refernce: " + dataRefURI);
-        }
-        /*
-         * Look up the encrypted data. First try wsu:Id="someURI". If no such 
Id then
-         * try the generic lookup to find Id="someURI"
-         */
-        Element encBodyData = null;
-        if ((encBodyData = WSSecurityUtil.getElementByWsuId(doc, dataRefURI)) 
== null) {
-            encBodyData = WSSecurityUtil.getElementByGenId(doc, dataRefURI);
-        }
-        if (encBodyData == null) {
-            throw new WSSecurityException
-                    (WSSecurityException.INVALID_SECURITY,
-                            "dataRef", new Object[]{dataRefURI});
-        }
-
-        boolean content = X509Util.isContent(encBodyData);
-
-        // Now figure out the encryption algorithm
-        String symEncAlgo = X509Util.getEncAlgo(encBodyData);
-
-        Element tmpE =
-                (Element) WSSecurityUtil.findElement((Node) encBodyData,
-                        "KeyInfo",
-                        WSConstants.SIG_NS);
-
-        SecretKey symmetricKey = X509Util.getSharedKey(tmpE, symEncAlgo, cb);
-
-        // initialize Cipher ....
-        XMLCipher xmlCipher = null;
-        try {
+       private static Log log = LogFactory.getLog(ReferenceListProcessor.class
+                       .getName());
+
+       private boolean debug = false;
+
+       WSSConfig wssConfig = null;
+
+       WSDocInfo wsDocInfo = null;
+
+       public void handleToken(Element elem, Crypto crypto, Crypto decCrypto,
+                       CallbackHandler cb, WSDocInfo wdi, Vector returnResults,
+                       WSSConfig wsc) throws WSSecurityException {
+
+               debug = log.isDebugEnabled();
+               if (debug) {
+                       log.debug("Found reference list element");
+               }
+               if (cb == null) {
+                       throw new 
WSSecurityException(WSSecurityException.FAILURE,
+                                       "noCallback");
+               }
+               wssConfig = wsc;
+               wsDocInfo = wdi;
+               handleReferenceList((Element) elem, cb);
+               returnResults.add(0, new 
WSSecurityEngineResult(WSConstants.ENCR, null,
+                               null, null, null));
+       }
+
+       /**
+        * Dereferences and decodes encrypted data elements.
+        * 
+        * @param elem
+        *            contains the <code>ReferenceList</code> to the encrypted
+        *            data elements
+        * @param cb
+        *            the callback handler to get the key for a key name stored 
if
+        *            <code>KeyInfo</code> inside the encrypted data elements
+        */
+       private void handleReferenceList(Element elem, CallbackHandler cb)
+                       throws WSSecurityException {
+
+               Document doc = elem.getOwnerDocument();
+
+               Node tmpE = null;
+               for (tmpE = elem.getFirstChild(); tmpE != null; tmpE = tmpE
+                               .getNextSibling()) {
+                       if (tmpE.getNodeType() != Node.ELEMENT_NODE) {
+                               continue;
+                       }
+                       if (!tmpE.getNamespaceURI().equals(WSConstants.ENC_NS)) 
{
+                               continue;
+                       }
+                       if (tmpE.getLocalName().equals("DataReference")) {
+                               String dataRefURI = ((Element) 
tmpE).getAttribute("URI");
+                               decryptDataRefEmbedded(doc, dataRefURI, cb);
+                       }
+               }
+       }
+
+       public void decryptDataRefEmbedded(Document doc, String dataRefURI,
+                       CallbackHandler cb) throws WSSecurityException {
+
+               if (log.isDebugEnabled()) {
+                       log.debug("Embedded found data refernce: " + 
dataRefURI);
+               }
+               /*
+                * Look up the encrypted data. First try wsu:Id="someURI". If 
no such Id
+                * then try the generic lookup to find Id="someURI"
+                */
+               Element encBodyData = null;
+               if ((encBodyData = WSSecurityUtil.getElementByWsuId(doc, 
dataRefURI)) == null) {
+                       encBodyData = WSSecurityUtil.getElementByGenId(doc, 
dataRefURI);
+               }
+               if (encBodyData == null) {
+                       throw new 
WSSecurityException(WSSecurityException.INVALID_SECURITY,
+                                       "dataRef", new Object[] { dataRefURI });
+               }
+
+               boolean content = X509Util.isContent(encBodyData);
+
+               // Now figure out the encryption algorithm
+               String symEncAlgo = X509Util.getEncAlgo(encBodyData);
+
+               Element tmpE = (Element) WSSecurityUtil.findElement((Node) 
encBodyData,
+                               "KeyInfo", WSConstants.SIG_NS);
+               if (tmpE == null) {
+                       throw new 
WSSecurityException(WSSecurityException.INVALID_SECURITY,
+                                       "noKeyinfo");
+               }
+
+               /*
+                * Try to get a security reference token, if none found try to 
get a
+                * shared key using a KeyName.
+                */
+               Element secRefToken = (Element) 
WSSecurityUtil.getDirectChild(tmpE,
+                               "SecurityTokenReference", WSConstants.WSSE_NS);
+
+               SecretKey symmetricKey = null;
+               if (secRefToken == null) {
+                       symmetricKey = X509Util.getSharedKey(tmpE, symEncAlgo, 
cb);
+               } else
+                       symmetricKey = getKeyFromReference(secRefToken, 
symEncAlgo);
+
+               // initialize Cipher ....
+               XMLCipher xmlCipher = null;
+               try {
                        String provider = wssConfig.getJceProviderId();
                        if (provider == null) {
                                xmlCipher = XMLCipher.getInstance(symEncAlgo);
@@ -129,18 +152,77 @@
                                xmlCipher = 
XMLCipher.getProviderInstance(symEncAlgo, provider);
                        }
                        xmlCipher.init(XMLCipher.DECRYPT_MODE, symmetricKey);
-        } catch (XMLEncryptionException e1) {
-            throw new 
WSSecurityException(WSSecurityException.UNSUPPORTED_ALGORITHM, null, null, e1);
-        }
-
-        if (content) {
-            encBodyData = (Element) encBodyData.getParentNode();
-        }
-        try {
-            xmlCipher.doFinal(doc, encBodyData, content);
-        } catch (Exception e) {
-            throw new WSSecurityException(WSSecurityException.FAILED_ENC_DEC, 
null, null, e);
-        }
-    }
-
+               } catch (XMLEncryptionException e1) {
+                       throw new WSSecurityException(
+                                       
WSSecurityException.UNSUPPORTED_ALGORITHM, null, null, e1);
+               }
+
+               if (content) {
+                       encBodyData = (Element) encBodyData.getParentNode();
+               }
+               try {
+                       xmlCipher.doFinal(doc, encBodyData, content);
+               } catch (Exception e) {
+                       throw new 
WSSecurityException(WSSecurityException.FAILED_ENC_DEC,
+                                       null, null, e);
+               }
+       }
+
+       /*
+        * (non-Javadoc)
+        * 
+        * @see org.apache.ws.security.processor.Processor#getId()
+        * 
+        * A reference list does not have an id.
+        */
+       public String getId() {
+               return null;
+       }
+
+       /**
+        * Retrieves a secret key (session key) from a already parsed 
EncryptedKey
+        * element
+        * 
+        * This method takes a security token reference (STR) element and 
checks if
+        * it contains a Reference element. Then it gets the vale of the URI
+        * attribute of the Reference and uses the retrieved value to lookup an
+        * EncrypteKey element to get the decrypted session key bytes. Using the
+        * algorithm parameter these bytes are converted into a secret key.
+        * 
+        * <p/>
+        * 
+        * This method requires that the EncyrptedKey element is already 
available,
+        * thus requires a strict layout of the security header. This method
+        * supports EncryptedKey elements within the same message.
+        * 
+        * @param secRefToken
+        *            The element containg the STR
+        * @param algorithm
+        *            A string that identifies the symmetric decryption 
algorithm
+        * @return The secret key for the specified algorithm
+        * @throws WSSecurityException
+        */
+       private SecretKey getKeyFromReference(Element secRefToken, String 
algorithm)
+                       throws WSSecurityException {
+
+               SecurityTokenReference secRef = new 
SecurityTokenReference(secRefToken);
+               byte[] decryptedData = null;
+
+               if (secRef.containsReference()) {
+                       Reference reference = secRef.getReference();
+                       String uri = reference.getURI();
+                       String id = uri.substring(1);
+                       Processor p = wsDocInfo.getProcessor(id);
+                       if (p == null || !(p instanceof EncryptedKeyProcessor)) 
{
+                               throw new WSSecurityException(
+                                               
WSSecurityException.FAILED_ENC_DEC, "unsupportedKeyId");
+                       }
+                       EncryptedKeyProcessor ekp = (EncryptedKeyProcessor) p;
+                       decryptedData = ekp.getDecryptedBytes();
+               } else {
+                       throw new 
WSSecurityException(WSSecurityException.FAILED_ENC_DEC,
+                                       "noReference");
+               }
+               return WSSecurityUtil.prepareSecretKey(algorithm, 
decryptedData);
+       }
 }

Modified: 
webservices/wss4j/trunk/src/org/apache/ws/security/processor/SAMLTokenProcessor.java
URL: 
http://svn.apache.org/viewcvs/webservices/wss4j/trunk/src/org/apache/ws/security/processor/SAMLTokenProcessor.java?rev=372821&r1=372820&r2=372821&view=diff
==============================================================================
--- 
webservices/wss4j/trunk/src/org/apache/ws/security/processor/SAMLTokenProcessor.java
 (original)
+++ 
webservices/wss4j/trunk/src/org/apache/ws/security/processor/SAMLTokenProcessor.java
 Fri Jan 27 04:14:41 2006
@@ -65,4 +65,12 @@
         return assertion;
     }
 
+    /* (non-Javadoc)
+     * @see org.apache.ws.security.processor.Processor#getId()
+     * TODO The Id of a SAML token?
+     */
+    public String getId() {
+       return null;
+    }
+
 }

Modified: 
webservices/wss4j/trunk/src/org/apache/ws/security/processor/SignatureConfirmationProcessor.java
URL: 
http://svn.apache.org/viewcvs/webservices/wss4j/trunk/src/org/apache/ws/security/processor/SignatureConfirmationProcessor.java?rev=372821&r1=372820&r2=372821&view=diff
==============================================================================
--- 
webservices/wss4j/trunk/src/org/apache/ws/security/processor/SignatureConfirmationProcessor.java
 (original)
+++ 
webservices/wss4j/trunk/src/org/apache/ws/security/processor/SignatureConfirmationProcessor.java
 Fri Jan 27 04:14:41 2006
@@ -34,6 +34,8 @@
 public class SignatureConfirmationProcessor implements Processor {
     private static Log log = 
LogFactory.getLog(SignatureConfirmationProcessor.class.getName());
 
+    private String scId;
+    
     public void handleToken(Element elem, Crypto crypto, Crypto decCrypto, 
CallbackHandler cb, WSDocInfo wsDocInfo, Vector returnResults, WSSConfig wsc) 
throws WSSecurityException {
         if (log.isDebugEnabled()) {
             log.debug("Found SignatureConfirmation list element");
@@ -45,5 +47,14 @@
                 (Element) elem);
         returnResults.add(0, new WSSecurityEngineResult(WSConstants.SC,
                 sigConf));
+        
+        scId = elem.getAttributeNS(WSConstants.WSU_NS, "Id");
     }
+    
+    /* (non-Javadoc)
+     * @see org.apache.ws.security.processor.Processor#getId()
+     */
+    public String getId() {
+       return scId;
+    }    
 }

Modified: 
webservices/wss4j/trunk/src/org/apache/ws/security/processor/SignatureProcessor.java
URL: 
http://svn.apache.org/viewcvs/webservices/wss4j/trunk/src/org/apache/ws/security/processor/SignatureProcessor.java?rev=372821&r1=372820&r2=372821&view=diff
==============================================================================
--- 
webservices/wss4j/trunk/src/org/apache/ws/security/processor/SignatureProcessor.java
 (original)
+++ 
webservices/wss4j/trunk/src/org/apache/ws/security/processor/SignatureProcessor.java
 Fri Jan 27 04:14:41 2006
@@ -58,6 +58,8 @@
     private static Log log = 
LogFactory.getLog(SignatureProcessor.class.getName());
     private static Log tlog =
             LogFactory.getLog("org.apache.ws.security.TIME");
+    
+    private String signatureId;
 
     public void handleToken(Element elem, Crypto crypto, Crypto decCrypto, 
CallbackHandler cb, WSDocInfo wsDocInfo, Vector returnResults, WSSConfig wsc) 
throws WSSecurityException {
         if (log.isDebugEnabled()) {
@@ -86,6 +88,7 @@
                     WSConstants.SIGN, lastPrincipalFound,
                     returnCert[0], returnQname[0], signatureValue[0]));
         }
+        signatureId = elem.getAttributeNS(null, "Id");
     }
 
     /**
@@ -357,6 +360,13 @@
         }
         throw new 
WSSecurityException(WSSecurityException.UNSUPPORTED_SECURITY_TOKEN,
                 "unsupportedBinaryTokenType", new Object[]{type});
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.ws.security.processor.Processor#getId()
+     */
+    public String getId() {
+       return signatureId;
     }
 
 }

Modified: 
webservices/wss4j/trunk/src/org/apache/ws/security/processor/TimestampProcessor.java
URL: 
http://svn.apache.org/viewcvs/webservices/wss4j/trunk/src/org/apache/ws/security/processor/TimestampProcessor.java?rev=372821&r1=372820&r2=372821&view=diff
==============================================================================
--- 
webservices/wss4j/trunk/src/org/apache/ws/security/processor/TimestampProcessor.java
 (original)
+++ 
webservices/wss4j/trunk/src/org/apache/ws/security/processor/TimestampProcessor.java
 Fri Jan 27 04:14:41 2006
@@ -38,6 +38,7 @@
     private static Log log = 
LogFactory.getLog(TimestampProcessor.class.getName());
 
     private WSSConfig wssConfig = null;
+    private String tsId;
     
     public void handleToken(Element elem, Crypto crypto, Crypto decCrypto, 
CallbackHandler cb, WSDocInfo wsDocInfo, Vector returnResults, WSSConfig wsc) 
throws WSSecurityException {
         if (log.isDebugEnabled()) {
@@ -52,6 +53,8 @@
         returnResults.add(0,
                 new WSSecurityEngineResult(WSConstants.TS,
                         timestamp));
+        tsId = elem.getAttributeNS(WSConstants.WSU_NS, "Id");
+
     }
 
     public void handleTimestamp(Timestamp timestamp) throws 
WSSecurityException {
@@ -83,4 +86,12 @@
                }
                return;
        }
+    
+    /* (non-Javadoc)
+     * @see org.apache.ws.security.processor.Processor#getId()
+     */
+    public String getId() {
+       return tsId;
+    }    
+    
 }

Modified: 
webservices/wss4j/trunk/src/org/apache/ws/security/processor/UsernameTokenProcessor.java
URL: 
http://svn.apache.org/viewcvs/webservices/wss4j/trunk/src/org/apache/ws/security/processor/UsernameTokenProcessor.java?rev=372821&r1=372820&r2=372821&view=diff
==============================================================================
--- 
webservices/wss4j/trunk/src/org/apache/ws/security/processor/UsernameTokenProcessor.java
 (original)
+++ 
webservices/wss4j/trunk/src/org/apache/ws/security/processor/UsernameTokenProcessor.java
 Fri Jan 27 04:14:41 2006
@@ -40,6 +40,8 @@
 public class UsernameTokenProcessor implements Processor {
     private static Log log = 
LogFactory.getLog(UsernameTokenProcessor.class.getName());
 
+    private String utId;
+    
     public void handleToken(Element elem, Crypto crypto, Crypto decCrypto, 
CallbackHandler cb, WSDocInfo wsDocInfo, Vector returnResults, WSSConfig wsc) 
throws WSSecurityException {
         if (log.isDebugEnabled()) {
             log.debug("Found UsernameToken list element");
@@ -47,6 +49,8 @@
         Principal lastPrincipalFound = handleUsernameToken((Element) elem, cb);
         returnResults.add(0, new WSSecurityEngineResult(WSConstants.UT,
                 lastPrincipalFound, null, null, null));
+        utId = elem.getAttributeNS(WSConstants.WSU_NS, "Id");
+
     }
 
     /**
@@ -140,4 +144,10 @@
         return principal;
     }
 
+    /* (non-Javadoc)
+     * @see org.apache.ws.security.processor.Processor#getId()
+     */
+    public String getId() {
+       return utId;
+    }    
 }



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

Reply via email to