[jbossws-commits] JBossWS SVN: r9476 - in stack/native/branches/dlofthouse/JBPAPP-1746/src: main/java/org/jboss/ws/extensions/security and 1 other directories.

jbossws-commits at lists.jboss.org jbossws-commits at lists.jboss.org
Tue Mar 3 13:39:19 EST 2009


Author: darran.lofthouse at jboss.com
Date: 2009-03-03 13:39:19 -0500 (Tue, 03 Mar 2009)
New Revision: 9476

Modified:
   stack/native/branches/dlofthouse/JBPAPP-1746/src/main/java/org/jboss/ws/core/jaxws/client/DispatchImpl.java
   stack/native/branches/dlofthouse/JBPAPP-1746/src/main/java/org/jboss/ws/extensions/security/WSSecurityDispatcher.java
   stack/native/branches/dlofthouse/JBPAPP-1746/src/test/java/org/jboss/test/ws/jaxws/samples/wssecurity/SimpleDispatchTestCase.java
Log:
Backport 2

Modified: stack/native/branches/dlofthouse/JBPAPP-1746/src/main/java/org/jboss/ws/core/jaxws/client/DispatchImpl.java
===================================================================
--- stack/native/branches/dlofthouse/JBPAPP-1746/src/main/java/org/jboss/ws/core/jaxws/client/DispatchImpl.java	2009-03-03 16:16:33 UTC (rev 9475)
+++ stack/native/branches/dlofthouse/JBPAPP-1746/src/main/java/org/jboss/ws/core/jaxws/client/DispatchImpl.java	2009-03-03 18:39:19 UTC (rev 9476)
@@ -236,6 +236,10 @@
             EndpointInfo epInfo = new EndpointInfo(epMetaData, targetAddress, callProps);
             resMsg = getRemotingConnection().invoke(reqMsg, epInfo, false);
 
+            //Pivot, switch to response ctx and save the response message there
+            msgContext = MessageContextJAXWS.processPivot(msgContext);
+            msgContext.setMessageAbstraction(resMsg);
+            
             // Call the  response handler chain, removing the fault type entry will not call handleFault for that chain 
             handlerPass = callResponseHandlerChain(portName, handlerType[2]);
             faultType[2] = null;
@@ -252,6 +256,7 @@
       }
       catch (Exception ex)
       {
+         msgContext = MessageContextJAXWS.processPivot(msgContext);
          if (faultType[2] != null)
             callFaultHandlerChain(portName, faultType[2], ex);
          if (faultType[1] != null)

Modified: stack/native/branches/dlofthouse/JBPAPP-1746/src/main/java/org/jboss/ws/extensions/security/WSSecurityDispatcher.java
===================================================================
--- stack/native/branches/dlofthouse/JBPAPP-1746/src/main/java/org/jboss/ws/extensions/security/WSSecurityDispatcher.java	2009-03-03 16:16:33 UTC (rev 9475)
+++ stack/native/branches/dlofthouse/JBPAPP-1746/src/main/java/org/jboss/ws/extensions/security/WSSecurityDispatcher.java	2009-03-03 18:39:19 UTC (rev 9476)
@@ -132,8 +132,14 @@
             opMetaData = soapMessage.getOperationMetaData(epMetaData);
          }
 
-         String operation = opMetaData.getQName().toString();
-         String port = opMetaData.getEndpointMetaData().getPortName().getLocalPart();
+         String operation = null;
+         String port = null;
+         if (opMetaData != null)
+         {
+            operation = opMetaData.getQName().toString();
+            port = opMetaData.getEndpointMetaData().getPortName().getLocalPart();
+         }
+          
 
          if (hasRequirements(config, operation, port))
             throw convertToFault(new InvalidSecurityHeaderException("This service requires <wsse:Security>, which is missing."));

Modified: stack/native/branches/dlofthouse/JBPAPP-1746/src/test/java/org/jboss/test/ws/jaxws/samples/wssecurity/SimpleDispatchTestCase.java
===================================================================
--- stack/native/branches/dlofthouse/JBPAPP-1746/src/test/java/org/jboss/test/ws/jaxws/samples/wssecurity/SimpleDispatchTestCase.java	2009-03-03 16:16:33 UTC (rev 9475)
+++ stack/native/branches/dlofthouse/JBPAPP-1746/src/test/java/org/jboss/test/ws/jaxws/samples/wssecurity/SimpleDispatchTestCase.java	2009-03-03 18:39:19 UTC (rev 9476)
@@ -49,21 +49,23 @@
  * http://jira.jboss.org/jira/browse/JBWS-1817
  *
  * @author Thomas.Diesler at jboss.com
+ * @author alessio.soldano at jboss.com
  * @since 02-Oct-2007
  */
 public class SimpleDispatchTestCase extends JBossWSTest
 {
-   private static Dispatch dispatch;
+   private static Dispatch usernameDispatch;
+   private static Dispatch encryptDispatch;
 
    public static Test suite() throws Exception
    {
-      return new JBossWSTestSetup(SimpleDispatchTestCase.class, "jaxws-samples-wssecurity-username.war");
+      return new JBossWSTestSetup(SimpleDispatchTestCase.class, "jaxws-samples-wssecurity-username.war jaxws-samples-wssecurity-encrypt.war");
    }
 
    @Override
    protected void setUp() throws Exception
    {
-      if (dispatch == null)
+      if (usernameDispatch == null)
       {
          URL wsdlURL = new File("resources/jaxws/samples/wssecurity/simple-username/META-INF/wsdl/UsernameService.wsdl").toURL();
          URL securityURL = new File("resources/jaxws/samples/wssecurity/simple-username/META-INF/jboss-wsse-client.xml").toURL();
@@ -71,11 +73,27 @@
          QName portName = new QName("http://org.jboss.ws/samples/wssecurity", "UsernameEndpointPort");
 
          Service service = Service.create(wsdlURL, serviceName);
-         dispatch = service.createDispatch(portName, Source.class, Mode.PAYLOAD);
+         usernameDispatch = service.createDispatch(portName, Source.class, Mode.PAYLOAD);
 
-         ((ConfigProvider)dispatch).setSecurityConfig(securityURL.toExternalForm());
-         ((ConfigProvider)dispatch).setConfigName("Standard WSSecurity Client");
+         ((ConfigProvider)usernameDispatch).setSecurityConfig(securityURL.toExternalForm());
+         ((ConfigProvider)usernameDispatch).setConfigName("Standard WSSecurity Client");
       }
+      if (encryptDispatch == null)
+      {
+         URL wsdlURL = new File("wsprovide/resources/jaxws/samples/wssecurity/HelloService.wsdl").toURL();
+         URL securityURL = new File("resources/jaxws/samples/wssecurity/simple-encrypt/META-INF/jboss-wsse-client.xml").toURL();
+         QName serviceName = new QName("http://org.jboss.ws/samples/wssecurity", "HelloService");
+         QName portName = new QName("http://org.jboss.ws/samples/wssecurity", "HelloPort");
+
+         Service service = Service.create(wsdlURL, serviceName);
+         encryptDispatch = service.createDispatch(portName, Source.class, Mode.PAYLOAD);
+
+         ((ConfigProvider)encryptDispatch).setSecurityConfig(securityURL.toExternalForm());
+         ((ConfigProvider)encryptDispatch).setConfigName("Standard WSSecurity Client");
+         
+         encryptDispatch.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
+               "http://" + getServerHost() + ":8080/jaxws-samples-wssecurity-encrypt");
+      }
    }
 
    public void testUsernameTokenNegative() throws Exception
@@ -83,7 +101,7 @@
       try
       {
          String payload = "<ns1:getUsernameToken xmlns:ns1='http://org.jboss.ws/samples/wssecurity'/>";
-         dispatch.invoke(new StreamSource(new StringReader(payload)));
+         usernameDispatch.invoke(new StreamSource(new StringReader(payload)));
          fail("Server should respond with [401] - Unauthorized");
       }
       catch (Exception ex)
@@ -94,16 +112,27 @@
 
    public void testUsernameToken() throws Exception
    {
-      Map<String, Object> reqContext = dispatch.getRequestContext();
+      Map<String, Object> reqContext = usernameDispatch.getRequestContext();
       reqContext.put(BindingProvider.USERNAME_PROPERTY, "kermit");
       reqContext.put(BindingProvider.PASSWORD_PROPERTY, "thefrog");
 
       String payload = "<ns1:getUsernameToken xmlns:ns1='http://org.jboss.ws/samples/wssecurity'/>";
-      Source retObj = (Source)dispatch.invoke(new StreamSource(new StringReader(payload)));
+      Source retObj = (Source)usernameDispatch.invoke(new StreamSource(new StringReader(payload)));
       
       Element docElement = DOMUtils.sourceToElement(retObj);
       Element retElement = DOMUtils.getFirstChildElement(docElement);
       String retPayload = DOMWriter.printNode(retElement, false);
       assertEquals("<return>kermit</return>", retPayload);
    }
+   
+   public void testEncrypt() throws Exception
+   {
+      String payload = "<ns1:echoUserType xmlns:ns1='http://org.jboss.ws/samples/wssecurity'><user><msg>Kermit</msg></user></ns1:echoUserType>";
+      Source retObj = (Source)encryptDispatch.invoke(new StreamSource(new StringReader(payload)));
+      
+      Element docElement = DOMUtils.sourceToElement(retObj);
+      Element retElement = DOMUtils.getFirstChildElement(docElement);
+      String retPayload = DOMWriter.printNode(retElement, false);
+      assertEquals("<return><msg>Kermit</msg></return>", retPayload);
+   }
 }
\ No newline at end of file




More information about the jbossws-commits mailing list