You are viewing a plain text version of this content. The canonical link for it is here.
Posted to axis-cvs@ws.apache.org by ru...@apache.org on 2006/10/06 03:26:57 UTC

svn commit: r453452 - in /webservices/axis2/trunk/java/modules: integration/test/org/apache/rampart/RampartTest.java security/src/org/apache/rampart/MessageBuilder.java security/src/org/apache/rampart/RampartMessageData.java

Author: ruchithf
Date: Thu Oct  5 18:26:56 2006
New Revision: 453452

URL: http://svn.apache.org/viewvc?view=rev&rev=453452
Log:
Use a property in options to indicate a wst:Cancel request
Updated RampartTest to use the new mechanism


Modified:
    webservices/axis2/trunk/java/modules/integration/test/org/apache/rampart/RampartTest.java
    webservices/axis2/trunk/java/modules/security/src/org/apache/rampart/MessageBuilder.java
    webservices/axis2/trunk/java/modules/security/src/org/apache/rampart/RampartMessageData.java

Modified: webservices/axis2/trunk/java/modules/integration/test/org/apache/rampart/RampartTest.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/integration/test/org/apache/rampart/RampartTest.java?view=diff&rev=453452&r1=453451&r2=453452
==============================================================================
--- webservices/axis2/trunk/java/modules/integration/test/org/apache/rampart/RampartTest.java (original)
+++ webservices/axis2/trunk/java/modules/integration/test/org/apache/rampart/RampartTest.java Thu Oct  5 18:26:56 2006
@@ -30,7 +30,6 @@
 import org.apache.axis2.integration.UtilServer;
 import org.apache.neethi.Policy;
 import org.apache.neethi.PolicyEngine;
-import org.apache.rahas.RahasConstants;
 
 import javax.xml.namespace.QName;
 
@@ -101,7 +100,7 @@
                 serviceClient.sendReceive(getEchoElement());
                 
                 //Cancel the token
-                options.setAction(RahasConstants.WST_NS_05_02 + RahasConstants.RST_ACTION_CANCEL_SCT);
+                options.setProperty(RampartMessageData.CANCEL_REQUEST, Constants.VALUE_TRUE);
                 serviceClient.sendReceive(getEchoElement());
                 
             }

Modified: webservices/axis2/trunk/java/modules/security/src/org/apache/rampart/MessageBuilder.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/security/src/org/apache/rampart/MessageBuilder.java?view=diff&rev=453452&r1=453451&r2=453452
==============================================================================
--- webservices/axis2/trunk/java/modules/security/src/org/apache/rampart/MessageBuilder.java (original)
+++ webservices/axis2/trunk/java/modules/security/src/org/apache/rampart/MessageBuilder.java Thu Oct  5 18:26:56 2006
@@ -18,6 +18,10 @@
 
 import org.apache.axiom.om.OMElement;
 import org.apache.axis2.AxisFault;
+import org.apache.axis2.Constants;
+import org.apache.axis2.addressing.AddressingConstants;
+import org.apache.axis2.addressing.AddressingConstants.Final;
+import org.apache.axis2.addressing.AddressingConstants.Submission;
 import org.apache.axis2.context.MessageContext;
 import org.apache.axis2.context.OperationContext;
 import org.apache.axis2.wsdl.WSDLConstants;
@@ -37,6 +41,8 @@
 import org.w3c.dom.Element;
 import org.w3c.dom.Node;
 
+import javax.xml.namespace.QName;
+
 public class MessageBuilder {
     
     private static Log log = LogFactory.getLog(MessageBuilder.class);
@@ -65,15 +71,33 @@
             }
         }
         
-        String action = msgCtx.getOptions().getAction();
-        System.out.println("MessageBuilder: 52: " + action);
-        if(action !=null && (action.equals(RahasConstants.WST_NS_05_02 + RahasConstants.RST_ACTION_CANCEL_SCT) ||
-                action.equals(RahasConstants.WST_NS_05_12 + RahasConstants.RSTR_ACTION_CANCEL_SCT))) {
-            
-            //set payload to a cancel request
-            String ctxIdKey = RampartUtil.getContextIdentifierKey(msgCtx);
-            String tokenId = (String)RampartUtil.getContextMap(msgCtx).get(ctxIdKey);
+        
+        String isCancelreq = (String)msgCtx.getProperty(RampartMessageData.CANCEL_REQUEST);
+        if(isCancelreq != null && Constants.VALUE_TRUE.equals(isCancelreq)) {
             try {
+                
+                String cancelAction = TrustUtil.getWSTNamespace(rmd.getWstVersion()) + RahasConstants.RST_ACTION_CANCEL_SCT;
+                //Set action
+                msgCtx.getOptions().setAction(cancelAction);
+                
+                //Change the wsa:Action header
+                String wsaNs = Final.WSA_NAMESPACE;
+                Object addressingVersionFromCurrentMsgCtxt = msgCtx.getProperty(AddressingConstants.WS_ADDRESSING_VERSION);
+                if (Submission.WSA_NAMESPACE.equals(addressingVersionFromCurrentMsgCtxt)) {
+                    wsaNs = Submission.WSA_NAMESPACE;
+                }
+                OMElement header = msgCtx.getEnvelope().getHeader();
+                if(header != null) {
+                    OMElement actionElem = header.getFirstChildWithName(new QName(wsaNs, AddressingConstants.WSA_ACTION));
+                    if(actionElem != null) {
+                        actionElem.setText(cancelAction);
+                    }
+                }
+                
+                //set payload to a cancel request
+                String ctxIdKey = RampartUtil.getContextIdentifierKey(msgCtx);
+                String tokenId = (String)RampartUtil.getContextMap(msgCtx).get(ctxIdKey);
+                
                 if(RampartUtil.isTokenValid(rmd, tokenId)) {
                     OMElement bodyElem = msgCtx.getEnvelope().getBody();
                     OMElement child = bodyElem.getFirstElement();
@@ -86,6 +110,7 @@
                 }
                 
             } catch (Exception e) {
+                e.printStackTrace();
                 throw new RampartException("errorInTokenCancellation");
             }
         }

Modified: webservices/axis2/trunk/java/modules/security/src/org/apache/rampart/RampartMessageData.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/security/src/org/apache/rampart/RampartMessageData.java?view=diff&rev=453452&r1=453451&r2=453452
==============================================================================
--- webservices/axis2/trunk/java/modules/security/src/org/apache/rampart/RampartMessageData.java (original)
+++ webservices/axis2/trunk/java/modules/security/src/org/apache/rampart/RampartMessageData.java Thu Oct  5 18:26:56 2006
@@ -74,6 +74,8 @@
 
     public static final String KEY_SCT_ISSUER_POLICY = "sct-issuer-policy";
     
+    public final static String CANCEL_REQUEST = "cancelrequest";
+    
     private MessageContext msgContext = null;
 
     private RampartPolicyData policyData = null;



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