Author: thomas.diesler(a)jboss.com
Date: 2007-03-28 16:45:38 -0400 (Wed, 28 Mar 2007)
New Revision: 2707
Added:
trunk/jbossws-tests/src/java/org/jboss/test/ws/jaxws/samples/handlerchain/ClientMimeHandler.java
trunk/jbossws-tests/src/java/org/jboss/test/ws/jaxws/samples/handlerchain/ServerMimeHandler.java
trunk/jbossws-tests/src/java/org/jboss/test/ws/jaxws/samples/handlerchain/jaxws-handlers-client.xml
trunk/jbossws-tests/src/java/org/jboss/test/ws/jaxws/samples/handlerchain/jaxws-handlers-server.xml
Removed:
trunk/jbossws-tests/src/java/org/jboss/test/ws/jaxws/samples/handlerchain/MimeHeaderHandler.java
trunk/jbossws-tests/src/java/org/jboss/test/ws/jaxws/samples/handlerchain/jaxws-handlers.xml
Modified:
trunk/jbossws-core/src/java/javax/xml/soap/MimeHeaders.java
trunk/jbossws-core/src/java/org/jboss/ws/core/server/ServiceEndpointManager.java
trunk/jbossws-tests/ant-import/build-samples-jaxws.xml
trunk/jbossws-tests/src/java/org/jboss/test/ws/jaxrpc/samples/handler/ClientSideHandler.java
trunk/jbossws-tests/src/java/org/jboss/test/ws/jaxrpc/samples/handler/ServerSideHandler.java
trunk/jbossws-tests/src/java/org/jboss/test/ws/jaxws/samples/handlerchain/EndpointImpl.java
trunk/jbossws-tests/src/java/org/jboss/test/ws/jaxws/samples/handlerchain/EndpointWithHandlerChain.java
trunk/jbossws-tests/src/java/org/jboss/test/ws/jaxws/samples/handlerchain/HandlerChainClient.java
trunk/jbossws-tests/src/java/org/jboss/test/ws/jaxws/samples/handlerchain/HandlerChainTestCase.java
Log:
svn merge -r2701:2705
https://svn.jboss.org/repos/jbossws/branches/jbossws-1.2.1
[JBWS-1515] Service endpoint should not feed back client cookies
Modified: trunk/jbossws-core/src/java/javax/xml/soap/MimeHeaders.java
===================================================================
--- trunk/jbossws-core/src/java/javax/xml/soap/MimeHeaders.java 2007-03-28 19:01:26 UTC
(rev 2706)
+++ trunk/jbossws-core/src/java/javax/xml/soap/MimeHeaders.java 2007-03-28 20:45:38 UTC
(rev 2707)
@@ -179,6 +179,11 @@
}
}
+ public String toString()
+ {
+ return "[MimeHeaders=" + headers + "]";
+ }
+
private static class MatchingIterator implements Iterator
{
private LinkedList headers;
Modified:
trunk/jbossws-core/src/java/org/jboss/ws/core/server/ServiceEndpointManager.java
===================================================================
---
trunk/jbossws-core/src/java/org/jboss/ws/core/server/ServiceEndpointManager.java 2007-03-28
19:01:26 UTC (rev 2706)
+++
trunk/jbossws-core/src/java/org/jboss/ws/core/server/ServiceEndpointManager.java 2007-03-28
20:45:38 UTC (rev 2707)
@@ -37,11 +37,9 @@
import java.net.UnknownHostException;
import java.util.ArrayList;
import java.util.HashMap;
-import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
-import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import javax.activation.DataHandler;
@@ -49,10 +47,8 @@
import javax.management.MBeanServerFactory;
import javax.management.ObjectName;
import javax.servlet.ServletContext;
-import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
-import javax.servlet.http.HttpSession;
import javax.xml.soap.SOAPEnvelope;
import javax.xml.soap.SOAPException;
import javax.xml.soap.SOAPMessage;
@@ -325,20 +321,25 @@
ServiceEndpointInfo seInfo = wsEndpoint.getServiceEndpointInfo();
String displayAddress = getDisplayAddress(seInfo, requestURL);
- try {
+ try
+ {
ServiceEndpointDTO dto = new ServiceEndpointDTO();
dto.setSepID(sepID);
dto.setAddress(displayAddress);
dto.setSeMetrics((ServiceEndpointMetrics)wsEndpoint.getServiceEndpointMetrics().clone());
dto.setState(wsEndpoint.getState());
registered.add(dto);
- } catch (CloneNotSupportedException e) { }
+ }
+ catch (CloneNotSupportedException e)
+ {
+ }
}
return registered;
}
- private String getDisplayAddress(ServiceEndpointInfo seInfo, URL requestURL) throws
MalformedURLException {
+ private String getDisplayAddress(ServiceEndpointInfo seInfo, URL requestURL) throws
MalformedURLException
+ {
String endpointAddress = seInfo.getServerEndpointMetaData().getEndpointAddress();
URL displayURL = new URL(endpointAddress);
String endPointPath = displayURL.getPath();
@@ -399,7 +400,7 @@
public void processSOAPRequest(ObjectName sepID, InputStream inStream, OutputStream
outStream, EndpointContext context) throws Exception
{
final String SESSION_COOKIES = "org.jboss.ws.cookies";
-
+
ServiceEndpoint wsEndpoint = getServiceEndpointByID(sepID);
if (wsEndpoint == null)
throw new WSException("Cannot obtain endpoint for: " + sepID);
@@ -412,28 +413,8 @@
HttpServletRequest httpRequest = context.getHttpServletRequest();
HttpServletResponse httpResponse = context.getHttpServletResponse();
ServletHeaderSource headerSource = new ServletHeaderSource(httpRequest,
httpResponse);
-
- // Default to does not create a new HTTPSession
- Object lasySession = new HttpSessionPropertyCallback(context);
-
- Cookie[] cookies = httpRequest.getCookies();
- if (cookies != null)
- {
- HttpSession httpSession = httpRequest.getSession(true);
- lasySession = httpSession;
-
- Set<Cookie> sessionCoookies =
(Set<Cookie>)httpSession.getAttribute(SESSION_COOKIES);
- if (sessionCoookies == null)
- {
- sessionCoookies = new HashSet<Cookie>();
- httpSession.setAttribute(SESSION_COOKIES, sessionCoookies);
- }
- for (Cookie cookie : cookies)
- {
- sessionCoookies.add(cookie);
- }
- }
-
+ HttpSessionPropertyCallback httpSession = new
HttpSessionPropertyCallback(context);
+
// Associate a message context with the current thread
CommonMessageContext msgContext;
if (type == EndpointMetaData.Type.JAXRPC)
@@ -442,7 +423,7 @@
msgContext.put(MessageContextJAXRPC.SERVLET_CONTEXT, servletContext);
msgContext.put(MessageContextJAXRPC.SERVLET_REQUEST, httpRequest);
msgContext.put(MessageContextJAXRPC.SERVLET_RESPONSE, httpResponse);
- msgContext.put(MessageContextJAXRPC.SERVLET_SESSION, lasySession);
+ msgContext.put(MessageContextJAXRPC.SERVLET_SESSION, httpSession);
}
else
{
@@ -464,7 +445,7 @@
try
{
SOAPMessage resMessage = wsEndpoint.handleRequest(headerSource, context,
inStream);
-
+
// REplace the message context with the response context
msgContext = MessageContextAssociation.peekMessageContext();
@@ -492,15 +473,6 @@
httpResponse.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
}
- // Copy the cookies to the response
- HttpSession httpSession = httpRequest.getSession(false);
- Set<Cookie> sessionCoookies = httpSession != null ?
(Set<Cookie>)httpSession.getAttribute(SESSION_COOKIES) : null;
- if (sessionCoookies != null)
- {
- for (Cookie cookie : sessionCoookies)
- httpResponse.addCookie(cookie);
- }
-
sendResponse(outStream, msgContext, isFault);
}
finally
@@ -739,11 +711,11 @@
}
return server;
}
-
+
public static class HttpSessionPropertyCallback implements PropertyCallback
{
private EndpointContext context;
-
+
public HttpSessionPropertyCallback(final EndpointContext context)
{
this.context = context;
Modified: trunk/jbossws-tests/ant-import/build-samples-jaxws.xml
===================================================================
--- trunk/jbossws-tests/ant-import/build-samples-jaxws.xml 2007-03-28 19:01:26 UTC (rev
2706)
+++ trunk/jbossws-tests/ant-import/build-samples-jaxws.xml 2007-03-28 20:45:38 UTC (rev
2707)
@@ -61,7 +61,7 @@
<include
name="org/jboss/test/ws/jaxws/samples/handlerchain/EndpointImpl.class"/>
<include
name="org/jboss/test/ws/jaxws/samples/handlerchain/Endpoint.class"/>
<include
name="org/jboss/test/ws/jaxws/samples/handlerchain/*Handler.class"/>
- <include
name="org/jboss/test/ws/jaxws/samples/handlerchain/jaxws-handlers.xml"/>
+ <include
name="org/jboss/test/ws/jaxws/samples/handlerchain/jaxws-handlers-server.xml"/>
</classes>
</war>
<jar
destfile="${tests.output.dir}/libs/jaxws-samples-handlerchain-client.jar">
@@ -69,7 +69,7 @@
<include
name="org/jboss/test/ws/jaxws/samples/handlerchain/Endpoint.class"/>
<include
name="org/jboss/test/ws/jaxws/samples/handlerchain/*Handler.class"/>
<include
name="org/jboss/test/ws/jaxws/samples/handlerchain/HandlerChainClient.class"/>
- <include
name="org/jboss/test/ws/jaxws/samples/handlerchain/jaxws-handlers.xml"/>
+ <include
name="org/jboss/test/ws/jaxws/samples/handlerchain/jaxws-handlers-client.xml"/>
</fileset>
<metainf
dir="${tests.output.dir}/resources/jaxws/samples/handlerchain/META-INF">
<include name="application-client.xml"/>
Modified:
trunk/jbossws-tests/src/java/org/jboss/test/ws/jaxrpc/samples/handler/ClientSideHandler.java
===================================================================
---
trunk/jbossws-tests/src/java/org/jboss/test/ws/jaxrpc/samples/handler/ClientSideHandler.java 2007-03-28
19:01:26 UTC (rev 2706)
+++
trunk/jbossws-tests/src/java/org/jboss/test/ws/jaxrpc/samples/handler/ClientSideHandler.java 2007-03-28
20:45:38 UTC (rev 2707)
@@ -78,7 +78,7 @@
String rpcName = soapBodyElement.getElementName().getLocalName();
MimeHeaders mimeHeaders = soapMessage.getMimeHeaders();
- mimeHeaders.setHeader("Cookie", "username=kermit");
+ mimeHeaders.setHeader("Cookie", "client-cookie=true");
// testInHeader
if (rpcName.equals("testInHeader"))
@@ -124,14 +124,11 @@
SOAPMessage soapMessage = ((SOAPMessageContext)msgContext).getMessage();
MimeHeaders mimeHeaders = soapMessage.getMimeHeaders();
- String[] cookieValues = mimeHeaders.getHeader("Set-Cookie");
- if (cookieValues == null)
- throw new JAXRPCException("Cannot obtain cookie values");
+
+ String[] cookies = mimeHeaders.getHeader("Set-Cookie");
+ if (cookies == null || cookies.length != 1 ||
!cookies[0].equals("server-cookie=true"))
+ throw new IllegalStateException("Unexpected cookie list: " +
mimeHeaders);
- List<String> cookieList = Arrays.asList(cookieValues);
- if (!cookieList.contains("username=kermit"))
- throw new JAXRPCException("Cannot obtain expected cookie value in: " +
cookieList);
-
return true;
}
}
Modified:
trunk/jbossws-tests/src/java/org/jboss/test/ws/jaxrpc/samples/handler/ServerSideHandler.java
===================================================================
---
trunk/jbossws-tests/src/java/org/jboss/test/ws/jaxrpc/samples/handler/ServerSideHandler.java 2007-03-28
19:01:26 UTC (rev 2706)
+++
trunk/jbossws-tests/src/java/org/jboss/test/ws/jaxrpc/samples/handler/ServerSideHandler.java 2007-03-28
20:45:38 UTC (rev 2707)
@@ -1,24 +1,24 @@
/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
package org.jboss.test.ws.jaxrpc.samples.handler;
import javax.xml.namespace.QName;
@@ -27,6 +27,7 @@
import javax.xml.rpc.handler.HandlerInfo;
import javax.xml.rpc.handler.MessageContext;
import javax.xml.rpc.handler.soap.SOAPMessageContext;
+import javax.xml.soap.MimeHeaders;
import javax.xml.soap.Name;
import javax.xml.soap.SOAPBody;
import javax.xml.soap.SOAPBodyElement;
@@ -44,6 +45,8 @@
private static Logger log = Logger.getLogger(ServerSideHandler.class);
protected QName[] headers;
+
+ private boolean setCookieOnResponse;
public QName[] getHeaders()
{
@@ -63,7 +66,7 @@
QName[] headers = getHeaders();
if (headers == null || headers.length != 3)
throw new IllegalStateException("Invalid number of headers");
-
+
try
{
SOAPMessage soapMessage = ((SOAPMessageContext)msgContext).getMessage();
@@ -73,6 +76,11 @@
SOAPBodyElement soapBodyElement =
(SOAPBodyElement)soapBody.getChildElements().next();
String rpcName = soapBodyElement.getElementName().getLocalName();
+ MimeHeaders mimeHeaders = soapMessage.getMimeHeaders();
+ String[] cookies = mimeHeaders.getHeader("Cookie");
+ if (cookies != null && cookies.length == 1 &&
cookies[0].equals("client-cookie=true"))
+ setCookieOnResponse = true;
+
// testInHeader
if (rpcName.equals("testInHeader"))
{
@@ -104,7 +112,7 @@
}
catch (SOAPException e)
{
- throw new JAXRPCException(e);
+ throw new JAXRPCException(e);
}
return true;
@@ -123,6 +131,13 @@
SOAPBodyElement soapBodyElement =
(SOAPBodyElement)soapBody.getChildElements().next();
String rpcName = soapBodyElement.getElementName().getLocalName();
+ if (setCookieOnResponse)
+ {
+ MimeHeaders mimeHeaders = soapMessage.getMimeHeaders();
+ mimeHeaders.setHeader("Set-Cookie",
"server-cookie=true");
+ setCookieOnResponse = false;
+ }
+
if (rpcName.equals("testInHeaderResponse"))
{
SOAPFactory soapFactory = SOAPFactory.newInstance();
@@ -151,7 +166,7 @@
}
catch (SOAPException e)
{
- throw new JAXRPCException(e);
+ throw new JAXRPCException(e);
}
return true;
Copied:
trunk/jbossws-tests/src/java/org/jboss/test/ws/jaxws/samples/handlerchain/ClientMimeHandler.java
(from rev 2705,
branches/jbossws-1.2.1/jbossws-tests/src/java/org/jboss/test/ws/jaxws/samples/handlerchain/ClientMimeHandler.java)
===================================================================
---
trunk/jbossws-tests/src/java/org/jboss/test/ws/jaxws/samples/handlerchain/ClientMimeHandler.java
(rev 0)
+++
trunk/jbossws-tests/src/java/org/jboss/test/ws/jaxws/samples/handlerchain/ClientMimeHandler.java 2007-03-28
20:45:38 UTC (rev 2707)
@@ -0,0 +1,66 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.test.ws.jaxws.samples.handlerchain;
+
+import javax.xml.soap.MimeHeaders;
+import javax.xml.soap.SOAPMessage;
+import javax.xml.ws.handler.MessageContext;
+import javax.xml.ws.handler.soap.SOAPMessageContext;
+
+import org.jboss.logging.Logger;
+import org.jboss.ws.core.jaxws.handler.GenericSOAPHandler;
+
+/**
+ * A client side handler
+ *
+ * @author Thomas.Diesler(a)jboss.org
+ * @since 08-Oct-2005
+ */
+public class ClientMimeHandler extends GenericSOAPHandler
+{
+ // Provide logging
+ private static Logger log = Logger.getLogger(ClientMimeHandler.class);
+
+ protected boolean handleOutbound(MessageContext msgContext)
+ {
+ log.info("handleOutbound");
+
+ SOAPMessage soapMessage = ((SOAPMessageContext)msgContext).getMessage();
+ MimeHeaders mimeHeaders = soapMessage.getMimeHeaders();
+ mimeHeaders.setHeader("Cookie", "client-cookie=true");
+
+ return true;
+ }
+
+ protected boolean handleInbound(MessageContext msgContext)
+ {
+ log.info("handleInbound");
+
+ SOAPMessage soapMessage = ((SOAPMessageContext)msgContext).getMessage();
+ MimeHeaders mimeHeaders = soapMessage.getMimeHeaders();
+ String[] cookies = mimeHeaders.getHeader("Set-Cookie");
+ if (cookies == null || cookies.length != 1 ||
!cookies[0].equals("server-cookie=true"))
+ throw new IllegalStateException("Unexpected cookie list: " +
mimeHeaders);
+
+ return true;
+ }
+}
Modified:
trunk/jbossws-tests/src/java/org/jboss/test/ws/jaxws/samples/handlerchain/EndpointImpl.java
===================================================================
---
trunk/jbossws-tests/src/java/org/jboss/test/ws/jaxws/samples/handlerchain/EndpointImpl.java 2007-03-28
19:01:26 UTC (rev 2706)
+++
trunk/jbossws-tests/src/java/org/jboss/test/ws/jaxws/samples/handlerchain/EndpointImpl.java 2007-03-28
20:45:38 UTC (rev 2707)
@@ -36,7 +36,7 @@
*/
@WebService
@SOAPBinding(style = SOAPBinding.Style.RPC)
-@HandlerChain(file = "jaxws-handlers.xml") // relative path from the class
file
+@HandlerChain(file = "jaxws-handlers-server.xml") // relative path from the
class file
public class EndpointImpl
{
// Provide logging
Modified:
trunk/jbossws-tests/src/java/org/jboss/test/ws/jaxws/samples/handlerchain/EndpointWithHandlerChain.java
===================================================================
---
trunk/jbossws-tests/src/java/org/jboss/test/ws/jaxws/samples/handlerchain/EndpointWithHandlerChain.java 2007-03-28
19:01:26 UTC (rev 2706)
+++
trunk/jbossws-tests/src/java/org/jboss/test/ws/jaxws/samples/handlerchain/EndpointWithHandlerChain.java 2007-03-28
20:45:38 UTC (rev 2707)
@@ -27,7 +27,7 @@
@WebService
@SOAPBinding(style = SOAPBinding.Style.RPC)
-@HandlerChain(file = "jaxws-handlers.xml") // relative path from the class
file
+@HandlerChain(file = "jaxws-handlers-client.xml") // relative path from the
class file
public interface EndpointWithHandlerChain
{
public String echo(String input);
Modified:
trunk/jbossws-tests/src/java/org/jboss/test/ws/jaxws/samples/handlerchain/HandlerChainClient.java
===================================================================
---
trunk/jbossws-tests/src/java/org/jboss/test/ws/jaxws/samples/handlerchain/HandlerChainClient.java 2007-03-28
19:01:26 UTC (rev 2706)
+++
trunk/jbossws-tests/src/java/org/jboss/test/ws/jaxws/samples/handlerchain/HandlerChainClient.java 2007-03-28
20:45:38 UTC (rev 2707)
@@ -38,7 +38,7 @@
private static final Logger log = Logger.getLogger(HandlerChainClient.class);
@WebServiceRef(name = "Service1")
- @HandlerChain(file = "jaxws-handlers.xml")
+ @HandlerChain(file = "jaxws-handlers-client.xml")
static Service service1;
// Service2 should have no client side handler chain
Modified:
trunk/jbossws-tests/src/java/org/jboss/test/ws/jaxws/samples/handlerchain/HandlerChainTestCase.java
===================================================================
---
trunk/jbossws-tests/src/java/org/jboss/test/ws/jaxws/samples/handlerchain/HandlerChainTestCase.java 2007-03-28
19:01:26 UTC (rev 2706)
+++
trunk/jbossws-tests/src/java/org/jboss/test/ws/jaxws/samples/handlerchain/HandlerChainTestCase.java 2007-03-28
20:45:38 UTC (rev 2707)
@@ -63,7 +63,7 @@
handlerChain.add(new LogHandler());
handlerChain.add(new AuthorizationHandler());
handlerChain.add(new RoutingHandler());
- handlerChain.add(new MimeHeaderHandler());
+ handlerChain.add(new ClientMimeHandler());
bindingProvider.getBinding().setHandlerChain(handlerChain);
String resStr = port.echo("Kermit");
Deleted:
trunk/jbossws-tests/src/java/org/jboss/test/ws/jaxws/samples/handlerchain/MimeHeaderHandler.java
===================================================================
---
trunk/jbossws-tests/src/java/org/jboss/test/ws/jaxws/samples/handlerchain/MimeHeaderHandler.java 2007-03-28
19:01:26 UTC (rev 2706)
+++
trunk/jbossws-tests/src/java/org/jboss/test/ws/jaxws/samples/handlerchain/MimeHeaderHandler.java 2007-03-28
20:45:38 UTC (rev 2707)
@@ -1,75 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-package org.jboss.test.ws.jaxws.samples.handlerchain;
-
-import java.util.Arrays;
-import java.util.List;
-
-import javax.xml.rpc.JAXRPCException;
-import javax.xml.soap.MimeHeaders;
-import javax.xml.soap.SOAPMessage;
-import javax.xml.ws.handler.MessageContext;
-import javax.xml.ws.handler.soap.SOAPMessageContext;
-
-import org.jboss.logging.Logger;
-import org.jboss.ws.core.jaxws.handler.GenericSOAPHandler;
-
-/**
- * A client side handler
- *
- * @author Thomas.Diesler(a)jboss.org
- * @since 08-Oct-2005
- */
-public class MimeHeaderHandler extends GenericSOAPHandler
-{
- // Provide logging
- private static Logger log = Logger.getLogger(MimeHeaderHandler.class);
-
- protected boolean handleInbound(MessageContext msgContext)
- {
- log.info("handleInbound");
-
- SOAPMessage soapMessage = ((SOAPMessageContext)msgContext).getMessage();
- MimeHeaders mimeHeaders = soapMessage.getMimeHeaders();
- String[] cookieValues = mimeHeaders.getHeader("Set-Cookie");
- if (cookieValues == null)
- throw new JAXRPCException("Cannot obtain cookie values");
-
- List<String> cookieList = Arrays.asList(cookieValues);
- if (!cookieList.contains("username=kermit"))
- throw new JAXRPCException("Cannot obtain expected cookie value in: " +
cookieList);
-
- return true;
- }
-
- protected boolean handleOutbound(MessageContext msgContext)
- {
- log.info("handleOutbound");
-
- SOAPMessage soapMessage = ((SOAPMessageContext)msgContext).getMessage();
-
- MimeHeaders mimeHeaders = soapMessage.getMimeHeaders();
- mimeHeaders.setHeader("Cookie", "username=kermit");
-
- return true;
- }
-}
Copied:
trunk/jbossws-tests/src/java/org/jboss/test/ws/jaxws/samples/handlerchain/ServerMimeHandler.java
(from rev 2705,
branches/jbossws-1.2.1/jbossws-tests/src/java/org/jboss/test/ws/jaxws/samples/handlerchain/ServerMimeHandler.java)
===================================================================
---
trunk/jbossws-tests/src/java/org/jboss/test/ws/jaxws/samples/handlerchain/ServerMimeHandler.java
(rev 0)
+++
trunk/jbossws-tests/src/java/org/jboss/test/ws/jaxws/samples/handlerchain/ServerMimeHandler.java 2007-03-28
20:45:38 UTC (rev 2707)
@@ -0,0 +1,67 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.test.ws.jaxws.samples.handlerchain;
+
+import javax.xml.soap.MimeHeaders;
+import javax.xml.soap.SOAPMessage;
+import javax.xml.ws.handler.MessageContext;
+import javax.xml.ws.handler.soap.SOAPMessageContext;
+
+import org.jboss.logging.Logger;
+import org.jboss.ws.core.jaxws.handler.GenericSOAPHandler;
+
+/**
+ * A server side handler
+ *
+ * @author Thomas.Diesler(a)jboss.org
+ * @since 08-Oct-2005
+ */
+public class ServerMimeHandler extends GenericSOAPHandler
+{
+ // Provide logging
+ private static Logger log = Logger.getLogger(ServerMimeHandler.class);
+
+ protected boolean handleInbound(MessageContext msgContext)
+ {
+ log.info("handleInbound");
+
+ SOAPMessage soapMessage = ((SOAPMessageContext)msgContext).getMessage();
+ MimeHeaders mimeHeaders = soapMessage.getMimeHeaders();
+ String[] cookies = mimeHeaders.getHeader("Cookie");
+ if (cookies == null || cookies.length != 1 ||
!cookies[0].equals("client-cookie=true"))
+ throw new IllegalStateException("Unexpected cookie list: " +
mimeHeaders);
+
+ return true;
+ }
+
+
+ protected boolean handleOutbound(MessageContext msgContext)
+ {
+ log.info("handleOutbound");
+
+ SOAPMessage soapMessage = ((SOAPMessageContext)msgContext).getMessage();
+ MimeHeaders mimeHeaders = soapMessage.getMimeHeaders();
+ mimeHeaders.setHeader("Set-Cookie", "server-cookie=true");
+
+ return true;
+ }
+}
Copied:
trunk/jbossws-tests/src/java/org/jboss/test/ws/jaxws/samples/handlerchain/jaxws-handlers-client.xml
(from rev 2705,
branches/jbossws-1.2.1/jbossws-tests/src/java/org/jboss/test/ws/jaxws/samples/handlerchain/jaxws-handlers-client.xml)
===================================================================
---
trunk/jbossws-tests/src/java/org/jboss/test/ws/jaxws/samples/handlerchain/jaxws-handlers-client.xml
(rev 0)
+++
trunk/jbossws-tests/src/java/org/jboss/test/ws/jaxws/samples/handlerchain/jaxws-handlers-client.xml 2007-03-28
20:45:38 UTC (rev 2707)
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<handler-chains
xmlns="http://java.sun.com/xml/ns/javaee"
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
javaee_web_services_1_2.xsd">
+
+ <handler-chain>
+ <protocol-bindings>##SOAP11_HTTP</protocol-bindings>
+ <handler>
+ <handler-name> LogHandler </handler-name>
+ <handler-class> org.jboss.test.ws.jaxws.samples.handlerchain.LogHandler
</handler-class>
+ <init-param>
+ <param-name>logCategory</param-name>
+ <param-value>MyService</param-value>
+ </init-param>
+ </handler>
+ <handler>
+ <handler-name> AuthorizationHandler </handler-name>
+ <handler-class>
org.jboss.test.ws.jaxws.samples.handlerchain.AuthorizationHandler </handler-class>
+ <soap-role>SecurityProvider</soap-role>
+ </handler>
+ <handler>
+ <handler-name> RoutingHandler </handler-name>
+ <handler-class>
org.jboss.test.ws.jaxws.samples.handlerchain.RoutingHandler </handler-class>
+ </handler>
+ <handler>
+ <handler-name> MimeHandler </handler-name>
+ <handler-class>
org.jboss.test.ws.jaxws.samples.handlerchain.ClientMimeHandler </handler-class>
+ </handler>
+ </handler-chain>
+</handler-chains>
\ No newline at end of file
Copied:
trunk/jbossws-tests/src/java/org/jboss/test/ws/jaxws/samples/handlerchain/jaxws-handlers-server.xml
(from rev 2705,
branches/jbossws-1.2.1/jbossws-tests/src/java/org/jboss/test/ws/jaxws/samples/handlerchain/jaxws-handlers-server.xml)
===================================================================
---
trunk/jbossws-tests/src/java/org/jboss/test/ws/jaxws/samples/handlerchain/jaxws-handlers-server.xml
(rev 0)
+++
trunk/jbossws-tests/src/java/org/jboss/test/ws/jaxws/samples/handlerchain/jaxws-handlers-server.xml 2007-03-28
20:45:38 UTC (rev 2707)
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<handler-chains
xmlns="http://java.sun.com/xml/ns/javaee"
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
javaee_web_services_1_2.xsd">
+
+ <handler-chain>
+ <protocol-bindings>##SOAP11_HTTP</protocol-bindings>
+ <handler>
+ <handler-name> LogHandler </handler-name>
+ <handler-class> org.jboss.test.ws.jaxws.samples.handlerchain.LogHandler
</handler-class>
+ <init-param>
+ <param-name>logCategory</param-name>
+ <param-value>MyService</param-value>
+ </init-param>
+ </handler>
+ <handler>
+ <handler-name> AuthorizationHandler </handler-name>
+ <handler-class>
org.jboss.test.ws.jaxws.samples.handlerchain.AuthorizationHandler </handler-class>
+ <soap-role>SecurityProvider</soap-role>
+ </handler>
+ <handler>
+ <handler-name> RoutingHandler </handler-name>
+ <handler-class>
org.jboss.test.ws.jaxws.samples.handlerchain.RoutingHandler </handler-class>
+ </handler>
+ <handler>
+ <handler-name> MimeHandler </handler-name>
+ <handler-class>
org.jboss.test.ws.jaxws.samples.handlerchain.ServerMimeHandler </handler-class>
+ </handler>
+ </handler-chain>
+</handler-chains>
\ No newline at end of file
Deleted:
trunk/jbossws-tests/src/java/org/jboss/test/ws/jaxws/samples/handlerchain/jaxws-handlers.xml
===================================================================
---
trunk/jbossws-tests/src/java/org/jboss/test/ws/jaxws/samples/handlerchain/jaxws-handlers.xml 2007-03-28
19:01:26 UTC (rev 2706)
+++
trunk/jbossws-tests/src/java/org/jboss/test/ws/jaxws/samples/handlerchain/jaxws-handlers.xml 2007-03-28
20:45:38 UTC (rev 2707)
@@ -1,27 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<handler-chains
xmlns="http://java.sun.com/xml/ns/javaee"
-
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
javaee_web_services_1_2.xsd">
-
- <handler-chain>
- <protocol-bindings>##SOAP11_HTTP</protocol-bindings>
- <handler>
- <handler-name> LogHandler </handler-name>
- <handler-class> org.jboss.test.ws.jaxws.samples.handlerchain.LogHandler
</handler-class>
- <init-param>
- <param-name>logCategory</param-name>
- <param-value>MyService</param-value>
- </init-param>
- </handler>
- <handler>
- <handler-name> AuthorizationHandler </handler-name>
- <handler-class>
org.jboss.test.ws.jaxws.samples.handlerchain.AuthorizationHandler </handler-class>
- <soap-role>SecurityProvider</soap-role>
- </handler>
- <handler>
- <handler-name> RoutingHandler </handler-name>
- <handler-class>
org.jboss.test.ws.jaxws.samples.handlerchain.RoutingHandler </handler-class>
- </handler>
- </handler-chain>
-</handler-chains>
\ No newline at end of file