Author: keith
Date: Sat Jul 19 10:48:27 2008
New Revision: 19643
URL: http://wso2.org/svn/browse/wso2?view=rev&revision=19643

Log:
Fixing Mashup-1000


Modified:
   
trunk/mashup/java/modules/hostobjects/src/org/wso2/mashup/hostobjects/wsrequest/WSRequestHostImpl.java

Modified: 
trunk/mashup/java/modules/hostobjects/src/org/wso2/mashup/hostobjects/wsrequest/WSRequestHostImpl.java
URL: 
http://wso2.org/svn/browse/wso2/trunk/mashup/java/modules/hostobjects/src/org/wso2/mashup/hostobjects/wsrequest/WSRequestHostImpl.java?rev=19643&r1=19642&r2=19643&view=diff
==============================================================================
--- 
trunk/mashup/java/modules/hostobjects/src/org/wso2/mashup/hostobjects/wsrequest/WSRequestHostImpl.java
      (original)
+++ 
trunk/mashup/java/modules/hostobjects/src/org/wso2/mashup/hostobjects/wsrequest/WSRequestHostImpl.java
      Sat Jul 19 10:48:27 2008
@@ -708,6 +708,7 @@
             if (wsRequest.async) { // asynchronous call to send()
                 AxisCallback callback = new 
WSRequestCallBack(Context.getCurrentContext(), wsRequest);
                 if (wsRequest.wsdlMode) {
+                    engageSecurity(wsRequest, operationName);
                     setSSLProperties(wsRequest);
                     wsRequest.sender.sendReceiveNonBlocking(operationName, 
payloadElement, callback);
                 } else {
@@ -719,46 +720,7 @@
                 wsRequest.readyState = 2;
                 // TODO do we need to call onreadystatechange here too
                 if (wsRequest.wsdlMode) {
-                    boolean needRampart = false;
-                    AxisService axisService = 
wsRequest.sender.getAxisService();
-                    AxisEndpoint axisEndpoint =
-                            
axisService.getEndpoint(axisService.getEndpointName());
-                    AxisBindingMessage axisBindingMessage = 
(AxisBindingMessage) axisEndpoint
-                            .getBinding().getChild(operationName)
-                            .getChild(WSDLConstants.MESSAGE_LABEL_IN_VALUE);
-                    Policy policy = axisBindingMessage.getEffectivePolicy();
-                    if (policy != null) {
-                        List it = (List) policy.getAlternatives().next();
-
-                        //Process policy and build policy data
-                        RampartPolicyData policyData = 
RampartPolicyBuilder.build(it);
-                        if (policyData != null) {
-                            if (policyData.isAsymmetricBinding() ||
-                                    policyData.isSymmetricBinding() ||
-                                    policyData.isTransportBinding()) {
-                                needRampart = true;
-                                Policy attchPolicy = new Policy();
-
-                                MessageContext currentMessageContext =
-                                        
MessageContext.getCurrentMessageContext();
-                                // In order to get the users keystore details 
we need his username. We stick the
-                                // username as a parameter into the service at 
deployment time
-                                String authorName = (String) 
currentMessageContext.getAxisService()
-                                        
.getParameterValue(MashupConstants.MASHUP_AUTHOR_NAME);
-
-
-                                
axisService.addParameter(WSHandlerConstants.PW_CALLBACK_REF,
-                                                         new 
PasswordCallbackHandler(authorName));
-                                attchPolicy.addAssertion(
-                                        wsRequest.getRampartConfig(wsRequest, 
authorName));
-                                
axisService.getPolicySubject().attachPolicy(attchPolicy);
-                            }                            
-                        }
-                    }
-                    if (needRampart) {
-                        wsRequest.sender.engageModule(MashupConstants.RAMPART);
-                        
wsRequest.sender.engageModule(MashupConstants.ADDRESSING);
-                    }
+                    engageSecurity(wsRequest, operationName);
                     setSSLProperties(wsRequest);
                     wsRequest.responseXML = 
wsRequest.sender.sendReceive(operationName, payloadElement);
                 } else {
@@ -788,6 +750,50 @@
         }
     }
 
+    private static void engageSecurity(WSRequestHostImpl wsRequest, QName 
operationName)
+            throws WSSPolicyException, AxisFault {
+        boolean needRampart = false;
+        AxisService axisService = wsRequest.sender.getAxisService();
+        AxisEndpoint axisEndpoint =
+                axisService.getEndpoint(axisService.getEndpointName());
+        AxisBindingMessage axisBindingMessage = (AxisBindingMessage) 
axisEndpoint
+                .getBinding().getChild(operationName)
+                .getChild(WSDLConstants.MESSAGE_LABEL_IN_VALUE);
+        Policy policy = axisBindingMessage.getEffectivePolicy();
+        if (policy != null) {
+            List it = (List) policy.getAlternatives().next();
+
+            //Process policy and build policy data
+            RampartPolicyData policyData = RampartPolicyBuilder.build(it);
+            if (policyData != null) {
+                if (policyData.isAsymmetricBinding() ||
+                        policyData.isSymmetricBinding() ||
+                        policyData.isTransportBinding()) {
+                    needRampart = true;
+                    Policy attchPolicy = new Policy();
+
+                    MessageContext currentMessageContext =
+                            MessageContext.getCurrentMessageContext();
+                    // In order to get the users keystore details we need his 
username. We stick the
+                    // username as a parameter into the service at deployment 
time
+                    String authorName = (String) 
currentMessageContext.getAxisService()
+                            
.getParameterValue(MashupConstants.MASHUP_AUTHOR_NAME);
+
+
+                    
axisService.addParameter(WSHandlerConstants.PW_CALLBACK_REF,
+                                             new 
PasswordCallbackHandler(authorName));
+                    attchPolicy.addAssertion(
+                            wsRequest.getRampartConfig(wsRequest, authorName));
+                    axisService.getPolicySubject().attachPolicy(attchPolicy);
+                }
+            }
+        }
+        if (needRampart) {
+            wsRequest.sender.engageModule(MashupConstants.RAMPART);
+            wsRequest.sender.engageModule(MashupConstants.ADDRESSING);
+        }
+    }
+
 
     /**
      * Getter for the responseText property. The raw text representing the XML 
(or non-XML) response.

_______________________________________________
Mashup-dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/mashup-dev

Reply via email to