You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fx-dev@ws.apache.org by ru...@apache.org on 2005/09/04 14:49:31 UTC

svn commit: r278587 - in /webservices/wss4j/trunk/src/org/apache/ws/security: handler/WSHandler.java message/WSAddTimestamp.java message/token/Timestamp.java

Author: ruchithf
Date: Sun Sep  4 05:49:00 2005
New Revision: 278587

URL: http://svn.apache.org/viewcvs?rev=278587&view=rev
Log:
Adding support for optional wsu:Id for the wsse:Timestamp and setting the wsu:Id each time when a Timestamp or a UsernameToken is added to the wsse:Security header

Modified:
    webservices/wss4j/trunk/src/org/apache/ws/security/handler/WSHandler.java
    webservices/wss4j/trunk/src/org/apache/ws/security/message/WSAddTimestamp.java
    webservices/wss4j/trunk/src/org/apache/ws/security/message/token/Timestamp.java

Modified: webservices/wss4j/trunk/src/org/apache/ws/security/handler/WSHandler.java
URL: http://svn.apache.org/viewcvs/webservices/wss4j/trunk/src/org/apache/ws/security/handler/WSHandler.java?rev=278587&r1=278586&r2=278587&view=diff
==============================================================================
--- webservices/wss4j/trunk/src/org/apache/ws/security/handler/WSHandler.java (original)
+++ webservices/wss4j/trunk/src/org/apache/ws/security/handler/WSHandler.java Sun Sep  4 05:49:00 2005
@@ -258,6 +258,10 @@
 
         WSSAddUsernameToken builder = new WSSAddUsernameToken(reqData.getActor(), mu);
         builder.setPasswordType(reqData.getPwType());
+        
+        //Set the wsu:Id of the UNT
+        builder.setId("UsernameToken-" + System.currentTimeMillis());
+        
         // add the UsernameToken to the SOAP Enevelope
         builder.build(doc, reqData.getUsername(), password);
 
@@ -375,6 +379,9 @@
     protected void performTSAction(int actionToDo, boolean mu, Document doc, RequestData reqData) throws WSSecurityException {
         WSAddTimestamp timeStampBuilder =
                 new WSAddTimestamp(reqData.getActor(), mu);
+        
+        timeStampBuilder.setId("Timestamp-" + System.currentTimeMillis());
+        
         // add the Timestamp to the SOAP Enevelope
         timeStampBuilder.build(doc, decodeTimeToLive(reqData));
     }

Modified: webservices/wss4j/trunk/src/org/apache/ws/security/message/WSAddTimestamp.java
URL: http://svn.apache.org/viewcvs/webservices/wss4j/trunk/src/org/apache/ws/security/message/WSAddTimestamp.java?rev=278587&r1=278586&r2=278587&view=diff
==============================================================================
--- webservices/wss4j/trunk/src/org/apache/ws/security/message/WSAddTimestamp.java (original)
+++ webservices/wss4j/trunk/src/org/apache/ws/security/message/WSAddTimestamp.java Sun Sep  4 05:49:00 2005
@@ -36,7 +36,7 @@
     private static Log log = LogFactory.getLog(WSAddTimestamp.class.getName());
 
     private Timestamp ts = null;
-
+    private String id = null;
     /**
      * Constructor.
      */
@@ -97,8 +97,28 @@
             target = (Element) securityHeader.getParentNode();
         }
         ts = new Timestamp(wssConfig, doc, ttl);
+        if(id != null) {
+        	ts.setID(id);
+        }
         WSSecurityUtil.prependChildElement(doc, target, ts.getElement(), true);
         return doc;
     }
 
+    /**
+     * Set the wsu:Id value of the Timestamp
+     * @param id
+     */
+    public void setId(String id) {
+        this.id = id;
+        if (ts != null)
+            ts.setID(id);
+    }
+    
+    /**
+     * Get the wsu:Id value of the Timestamp
+     * @return
+     */
+    public String getId() {
+        return id;
+    }
 }

Modified: webservices/wss4j/trunk/src/org/apache/ws/security/message/token/Timestamp.java
URL: http://svn.apache.org/viewcvs/webservices/wss4j/trunk/src/org/apache/ws/security/message/token/Timestamp.java?rev=278587&r1=278586&r2=278587&view=diff
==============================================================================
--- webservices/wss4j/trunk/src/org/apache/ws/security/message/token/Timestamp.java (original)
+++ webservices/wss4j/trunk/src/org/apache/ws/security/message/token/Timestamp.java Sun Sep  4 05:49:00 2005
@@ -52,6 +52,8 @@
 
     protected Calendar created;
     protected Calendar expires;
+    
+    protected WSSConfig wssConfig = WSSConfig.getDefaultWSConfig();
 
     /**
      * Constructs a <code>Timestamp</code> object and parses the
@@ -207,4 +209,27 @@
     public Vector getCustomElements() {
         return this.customElements;
     }
+    
+    /**
+     * Set wsu:Id attribute of this timestamp
+     * @param id
+     */
+    public void setID(String id) {
+		String prefix = WSSecurityUtil.setNamespace(this.element, wssConfig
+				.getWsuNS(), WSConstants.WSU_PREFIX);
+		this.element.setAttributeNS(wssConfig.getWsuNS(), prefix + ":Id", id);
+    }
+    
+    /**
+     * Returns the value of the wsu:Id attribute
+     * @return
+     */
+    public String getID() {
+        if (wssConfig.getProcessNonCompliantMessages()) {
+            return WSSecurityUtil.getAttributeValueWSU(element, "Id", null);
+        } else {
+            return WSSecurityUtil.getAttributeValueWSU(element, "Id", wssConfig.getWsuNS());
+        }
+    }
+    
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: wss4j-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: wss4j-dev-help@ws.apache.org