JBossWS SVN: r10320 - stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/main/java/org/jboss/ws/metadata/wsdl.
by jbossws-commits@lists.jboss.org
Author: mageshbk(a)jboss.com
Date: 2009-07-13 03:17:28 -0400 (Mon, 13 Jul 2009)
New Revision: 10320
Modified:
stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/main/java/org/jboss/ws/metadata/wsdl/WSDLDefinitions.java
Log:
[JBPAPP-2060] Allow binding objects that are defined by XmlAttribute from "http://www.w3.org/XML/1998/namespace"
Modified: stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/main/java/org/jboss/ws/metadata/wsdl/WSDLDefinitions.java
===================================================================
--- stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/main/java/org/jboss/ws/metadata/wsdl/WSDLDefinitions.java 2009-07-13 07:06:53 UTC (rev 10319)
+++ stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/main/java/org/jboss/ws/metadata/wsdl/WSDLDefinitions.java 2009-07-13 07:17:28 UTC (rev 10320)
@@ -114,11 +114,24 @@
/** Register the given namespaceURI/prefix combination */
public String registerNamespaceURI(String nsURI, String prefix)
{
+ if (Constants.NS_XML.equalsIgnoreCase(nsURI))
+ {
+ //"http://www.w3.org/XML/1998/namespace" is always bound to "xml" prefix
+ //and does not need to be registered.
+ return Constants.PREFIX_XML;
+ }
+ else if (Constants.PREFIX_XML.equalsIgnoreCase(prefix))
+ {
+ throw new IllegalArgumentException("The prefix " + Constants.PREFIX_XML +
+ " cannot be bound to any namespace other than its usual namespace (trying to bind to "
+ + nsURI + " )");
+ }
+
String pre = namespaces.getPrefix(nsURI);
- if (pre == null || pre == "")
+ if (pre == null || 0 == pre.length())
{
pre = namespaces.registerURI(nsURI, prefix);
- log.trace("registerNamespaceURI: " + pre + "=" + nsURI);
+ log.trace("registerNamespaceURI: " + pre + '=' + nsURI);
}
return pre;
}
16 years, 4 months
JBossWS SVN: r10319 - stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/main/java/org/jboss/ws/core/soap.
by jbossws-commits@lists.jboss.org
Author: mageshbk(a)jboss.com
Date: 2009-07-13 03:06:53 -0400 (Mon, 13 Jul 2009)
New Revision: 10319
Modified:
stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/main/java/org/jboss/ws/core/soap/SOAPMessageImpl.java
Log:
[JBPAPP-2098] MTOM/XOP Interoperability - cid href URLEncode/URLDecode applying user patch
Modified: stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/main/java/org/jboss/ws/core/soap/SOAPMessageImpl.java
===================================================================
--- stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/main/java/org/jboss/ws/core/soap/SOAPMessageImpl.java 2009-07-08 13:55:33 UTC (rev 10318)
+++ stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/main/java/org/jboss/ws/core/soap/SOAPMessageImpl.java 2009-07-13 07:06:53 UTC (rev 10319)
@@ -22,25 +22,42 @@
package org.jboss.ws.core.soap;
// $Id$
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.UnsupportedEncodingException;
+import java.net.URLDecoder;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+import javax.mail.MessagingException;
+import javax.xml.soap.AttachmentPart;
+import javax.xml.soap.MimeHeader;
+import javax.xml.soap.MimeHeaders;
+import javax.xml.soap.SOAPConstants;
+import javax.xml.soap.SOAPElement;
+import javax.xml.soap.SOAPEnvelope;
+import javax.xml.soap.SOAPException;
+import javax.xml.soap.SOAPFault;
+import javax.xml.soap.SOAPMessage;
+import javax.xml.soap.SOAPPart;
+
+import org.jboss.logging.Logger;
import org.jboss.ws.Constants;
import org.jboss.ws.WSException;
+import org.jboss.ws.core.CommonMessageContext;
import org.jboss.ws.core.SOAPMessageAbstraction;
-import org.jboss.ws.core.CommonMessageContext;
-import org.jboss.ws.core.soap.attachment.*;
+import org.jboss.ws.core.soap.attachment.AttachmentPartImpl;
+import org.jboss.ws.core.soap.attachment.CIDGenerator;
+import org.jboss.ws.core.soap.attachment.MimeConstants;
+import org.jboss.ws.core.soap.attachment.MultipartRelatedEncoder;
+import org.jboss.ws.core.soap.attachment.MultipartRelatedSwAEncoder;
+import org.jboss.ws.core.soap.attachment.MultipartRelatedXOPEncoder;
import org.jboss.ws.extensions.xop.XOPContext;
import org.jboss.ws.metadata.umdm.EndpointMetaData;
import org.jboss.ws.metadata.umdm.OperationMetaData;
-import javax.mail.MessagingException;
-import javax.xml.soap.*;
-import java.io.IOException;
-import java.io.OutputStream;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-
/**
* The root class for all SOAP messages. As transmitted on the "wire", a SOAP message is an XML document or a
* MIME message whose first body part is an XML/SOAP document.
@@ -50,6 +67,8 @@
*/
public class SOAPMessageImpl extends SOAPMessage implements SOAPMessageAbstraction
{
+ private static Logger log = Logger.getLogger(SOAPMessageImpl.class);
+
private boolean saveRequired = true;
private MimeHeaders mimeHeaders = new MimeHeaders();
private List<AttachmentPart> attachments = new LinkedList<AttachmentPart>();
@@ -115,26 +134,50 @@
public AttachmentPart getAttachmentByContentId(String cid) throws SOAPException
{
+ String cidDecoded = decode(cid);
+
for (AttachmentPart part : attachments)
{
- String contentId = part.getContentId();
- if (contentId.equals(cid))
+ String contentIdDecoded = decode(part.getContentId());
+ if (contentIdDecoded.equals(cidDecoded))
return part;
}
+
return null;
}
+
+ public String decode(String cid)
+ {
+ String cidDecoded = cid;
+
+ try
+ {
+ cidDecoded = URLDecoder.decode(cid, "UTF-8");
+ }
+ catch (UnsupportedEncodingException ex)
+ {
+ log.error("Cannot decode name for cid: " + ex);
+ }
+
+ return cidDecoded;
+ }
public AttachmentPart removeAttachmentByContentId(String cid)
{
- for (AttachmentPart part : attachments)
+ try
{
- String contentId = part.getContentId();
- if (contentId.equals(cid))
+ AttachmentPart part = getAttachmentByContentId(cid);
+ if (part != null)
{
attachments.remove(part);
return part;
}
}
+ catch (SOAPException ex)
+ {
+ // this used to not throw SOAPException
+ log.error("Ignore SOAPException: " + ex);
+ }
return null;
}
16 years, 4 months
JBossWS SVN: r10318 - in stack/native/branches/jbossws-native-2.0.1.SP2_CP: src/main/java/org/jboss/ws/core/soap and 5 other directories.
by jbossws-commits@lists.jboss.org
Author: darran.lofthouse(a)jboss.com
Date: 2009-07-08 09:55:33 -0400 (Wed, 08 Jul 2009)
New Revision: 10318
Added:
stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/test/java/org/jboss/test/ws/jaxws/jbws2698/
stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/test/java/org/jboss/test/ws/jaxws/jbws2698/Endpoint.java
stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/test/java/org/jboss/test/ws/jaxws/jbws2698/EndpointImpl.java
stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/test/java/org/jboss/test/ws/jaxws/jbws2698/JBWS2698TestCase.java
stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/test/java/org/jboss/test/ws/jaxws/jbws2698/SOAPHandler.java
stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/test/java/org/jboss/test/ws/jaxws/jbws2698/server-handlers.xml
stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/test/resources/jaxws/jbws2698/
stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/test/resources/jaxws/jbws2698/WEB-INF/
stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/test/resources/jaxws/jbws2698/WEB-INF/jboss-web.xml
stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/test/resources/jaxws/jbws2698/WEB-INF/web.xml
Removed:
stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/test/java/org/jboss/test/ws/jaxws/jbws2698/Endpoint.java
stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/test/java/org/jboss/test/ws/jaxws/jbws2698/EndpointImpl.java
stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/test/java/org/jboss/test/ws/jaxws/jbws2698/JBWS2698TestCase.java
stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/test/java/org/jboss/test/ws/jaxws/jbws2698/SOAPHandler.java
stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/test/java/org/jboss/test/ws/jaxws/jbws2698/server-handlers.xml
stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/test/resources/jaxws/jbws2698/WEB-INF/
stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/test/resources/jaxws/jbws2698/WEB-INF/jboss-web.xml
stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/test/resources/jaxws/jbws2698/WEB-INF/web.xml
Modified:
stack/native/branches/jbossws-native-2.0.1.SP2_CP/ant-import-tests/build-jars-jaxws.xml
stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/main/java/org/jboss/ws/core/soap/SOAPElementImpl.java
Log:
[JBPAPP-2239] Calling setPrefix(newPrefix) on any SOAPElement the prefix is not used for marshalling.
Modified: stack/native/branches/jbossws-native-2.0.1.SP2_CP/ant-import-tests/build-jars-jaxws.xml
===================================================================
--- stack/native/branches/jbossws-native-2.0.1.SP2_CP/ant-import-tests/build-jars-jaxws.xml 2009-07-08 12:35:46 UTC (rev 10317)
+++ stack/native/branches/jbossws-native-2.0.1.SP2_CP/ant-import-tests/build-jars-jaxws.xml 2009-07-08 13:55:33 UTC (rev 10318)
@@ -653,8 +653,20 @@
<include name="org/jboss/test/ws/jaxws/jbws2682/Endpoint.class"/>
<include name="org/jboss/test/ws/jaxws/jbws2682/EndpointImpl.class"/>
</classes>
- </war>
+ </war>
+ <!-- jaxws-jbws2698 -->
+ <war warfile="${tests.output.dir}/libs/jaxws-jbws2698.war" webxml="${tests.output.dir}/resources/jaxws/jbws2698/WEB-INF/web.xml">
+ <classes dir="${tests.output.dir}/classes">
+ <include name="org/jboss/test/ws/jaxws/jbws2698/*.class"/>
+ <exclude name="org/jboss/test/ws/jaxws/jbws2698/JBWS2698TestCase.class"/>
+ <include name="org/jboss/test/ws/jaxws/jbws2698/server-handlers.xml"/>
+ </classes>
+ <webinf dir="${tests.output.dir}/resources/jaxws/jbws2698/WEB-INF">
+ <include name="jboss-web.xml"/>
+ </webinf>
+ </war>
+
<!-- jaxws namespace -->
<war warfile="${tests.output.dir}/libs/jaxws-namespace.war" webxml="${tests.output.dir}/resources/jaxws/namespace/WEB-INF/web.xml">
<classes dir="${tests.output.dir}/classes">
Modified: stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/main/java/org/jboss/ws/core/soap/SOAPElementImpl.java
===================================================================
--- stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/main/java/org/jboss/ws/core/soap/SOAPElementImpl.java 2009-07-08 12:35:46 UTC (rev 10317)
+++ stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/main/java/org/jboss/ws/core/soap/SOAPElementImpl.java 2009-07-08 13:55:33 UTC (rev 10318)
@@ -793,6 +793,13 @@
{
visitor.visitSOAPElement(this);
}
+
+ @Override
+ public void setPrefix(String prefix) throws DOMException
+ {
+ super.setPrefix(prefix);
+ elementName = null;
+ }
/**
* The default implementation uses a DOMWriter.
Copied: stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/test/java/org/jboss/test/ws/jaxws/jbws2698 (from rev 10316, stack/native/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2698)
Deleted: stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/test/java/org/jboss/test/ws/jaxws/jbws2698/Endpoint.java
===================================================================
--- stack/native/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2698/Endpoint.java 2009-07-07 16:47:12 UTC (rev 10316)
+++ stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/test/java/org/jboss/test/ws/jaxws/jbws2698/Endpoint.java 2009-07-08 13:55:33 UTC (rev 10318)
@@ -1,38 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2009, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file 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.jbws2698;
-
-import javax.jws.WebService;
-
-/**
- * Test Endpoint.
- *
- * @author darran.lofthouse(a)jboss.com
- * @since 7th July 2009
- */
-@WebService(name = "Endpoint", targetNamespace = "http://ws.jboss.org/jbws2698")
-public interface Endpoint
-{
-
- public String echo(final String message);
-
-}
Copied: stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/test/java/org/jboss/test/ws/jaxws/jbws2698/Endpoint.java (from rev 10316, stack/native/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2698/Endpoint.java)
===================================================================
--- stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/test/java/org/jboss/test/ws/jaxws/jbws2698/Endpoint.java (rev 0)
+++ stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/test/java/org/jboss/test/ws/jaxws/jbws2698/Endpoint.java 2009-07-08 13:55:33 UTC (rev 10318)
@@ -0,0 +1,38 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.jbws2698;
+
+import javax.jws.WebService;
+
+/**
+ * Test Endpoint.
+ *
+ * @author darran.lofthouse(a)jboss.com
+ * @since 7th July 2009
+ */
+@WebService(name = "Endpoint", targetNamespace = "http://ws.jboss.org/jbws2698")
+public interface Endpoint
+{
+
+ public String echo(final String message);
+
+}
Deleted: stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/test/java/org/jboss/test/ws/jaxws/jbws2698/EndpointImpl.java
===================================================================
--- stack/native/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2698/EndpointImpl.java 2009-07-07 16:47:12 UTC (rev 10316)
+++ stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/test/java/org/jboss/test/ws/jaxws/jbws2698/EndpointImpl.java 2009-07-08 13:55:33 UTC (rev 10318)
@@ -1,43 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2009, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file 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.jbws2698;
-
-import javax.jws.HandlerChain;
-import javax.jws.WebService;
-
-/**
- * Test Endpoint implementation.
- *
- * @author darran.lofthouse(a)jboss.com
- * @since 7th July 2009
- */
-@WebService(name = "Endpoint", targetNamespace = "http://ws.jboss.org/jbws2698", endpointInterface = "org.jboss.test.ws.jaxws.jbws2698.Endpoint")
-@HandlerChain(file = "server-handlers.xml")
-public class EndpointImpl implements Endpoint
-{
-
- public String echo(final String message)
- {
- return message;
- }
-
-}
Copied: stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/test/java/org/jboss/test/ws/jaxws/jbws2698/EndpointImpl.java (from rev 10316, stack/native/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2698/EndpointImpl.java)
===================================================================
--- stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/test/java/org/jboss/test/ws/jaxws/jbws2698/EndpointImpl.java (rev 0)
+++ stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/test/java/org/jboss/test/ws/jaxws/jbws2698/EndpointImpl.java 2009-07-08 13:55:33 UTC (rev 10318)
@@ -0,0 +1,43 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.jbws2698;
+
+import javax.jws.HandlerChain;
+import javax.jws.WebService;
+
+/**
+ * Test Endpoint implementation.
+ *
+ * @author darran.lofthouse(a)jboss.com
+ * @since 7th July 2009
+ */
+@WebService(name = "Endpoint", targetNamespace = "http://ws.jboss.org/jbws2698", endpointInterface = "org.jboss.test.ws.jaxws.jbws2698.Endpoint")
+@HandlerChain(file = "server-handlers.xml")
+public class EndpointImpl implements Endpoint
+{
+
+ public String echo(final String message)
+ {
+ return message;
+ }
+
+}
Deleted: stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/test/java/org/jboss/test/ws/jaxws/jbws2698/JBWS2698TestCase.java
===================================================================
--- stack/native/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2698/JBWS2698TestCase.java 2009-07-07 16:47:12 UTC (rev 10316)
+++ stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/test/java/org/jboss/test/ws/jaxws/jbws2698/JBWS2698TestCase.java 2009-07-08 13:55:33 UTC (rev 10318)
@@ -1,80 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2009, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file 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.jbws2698;
-
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.xml.namespace.QName;
-import javax.xml.ws.BindingProvider;
-import javax.xml.ws.Service;
-
-import junit.framework.Test;
-import javax.xml.ws.handler.Handler;
-import org.jboss.wsf.test.JBossWSTest;
-import org.jboss.wsf.test.JBossWSTestSetup;
-
-/**
- * [JBWS-2698] Calling setPrefix(newPrefix) on any SOAPElement the
- * prefix is not used for marshalling.
- *
- * @author darran.lofthouse(a)jboss.com
- * @since 7th July 2009
- * @see https://jira.jboss.org/jira/browse/JBWS-2698
- */
-public class JBWS2698TestCase extends JBossWSTest
-{
-
- public final String TARGET_ENDPOINT_ADDRESS = "http://" + getServerHost() + ":8080/jaxws-jbws2698/";
-
- private static Endpoint port;
-
- public static Test suite() throws Exception
- {
- return new JBossWSTestSetup(JBWS2698TestCase.class, "jaxws-jbws2698.war");
- }
-
- public void setUp() throws Exception
- {
- super.setUp();
- URL wsdlURL = new URL(TARGET_ENDPOINT_ADDRESS + "?wsdl");
- QName serviceName = new QName("http://ws.jboss.org/jbws2698", "EndpointImplService");
-
- Service service = Service.create(wsdlURL, serviceName);
- port = service.getPort(Endpoint.class);
-
- BindingProvider bindingProvider = (BindingProvider)port;
- List<Handler> handlerChain = new ArrayList<Handler>();
- handlerChain.add(new SOAPHandler());
- bindingProvider.getBinding().setHandlerChain(handlerChain);
- }
-
- public void testCall() throws Exception
- {
- String message = "Howdy";
-
- String response = port.echo(message);
- assertEquals("Response", message, response);
- }
-
-}
Copied: stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/test/java/org/jboss/test/ws/jaxws/jbws2698/JBWS2698TestCase.java (from rev 10316, stack/native/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2698/JBWS2698TestCase.java)
===================================================================
--- stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/test/java/org/jboss/test/ws/jaxws/jbws2698/JBWS2698TestCase.java (rev 0)
+++ stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/test/java/org/jboss/test/ws/jaxws/jbws2698/JBWS2698TestCase.java 2009-07-08 13:55:33 UTC (rev 10318)
@@ -0,0 +1,80 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.jbws2698;
+
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.xml.namespace.QName;
+import javax.xml.ws.BindingProvider;
+import javax.xml.ws.Service;
+
+import junit.framework.Test;
+import javax.xml.ws.handler.Handler;
+import org.jboss.wsf.test.JBossWSTest;
+import org.jboss.wsf.test.JBossWSTestSetup;
+
+/**
+ * [JBWS-2698] Calling setPrefix(newPrefix) on any SOAPElement the
+ * prefix is not used for marshalling.
+ *
+ * @author darran.lofthouse(a)jboss.com
+ * @since 7th July 2009
+ * @see https://jira.jboss.org/jira/browse/JBWS-2698
+ */
+public class JBWS2698TestCase extends JBossWSTest
+{
+
+ public final String TARGET_ENDPOINT_ADDRESS = "http://" + getServerHost() + ":8080/jaxws-jbws2698/";
+
+ private static Endpoint port;
+
+ public static Test suite() throws Exception
+ {
+ return new JBossWSTestSetup(JBWS2698TestCase.class, "jaxws-jbws2698.war");
+ }
+
+ public void setUp() throws Exception
+ {
+ super.setUp();
+ URL wsdlURL = new URL(TARGET_ENDPOINT_ADDRESS + "?wsdl");
+ QName serviceName = new QName("http://ws.jboss.org/jbws2698", "EndpointImplService");
+
+ Service service = Service.create(wsdlURL, serviceName);
+ port = service.getPort(Endpoint.class);
+
+ BindingProvider bindingProvider = (BindingProvider)port;
+ List<Handler> handlerChain = new ArrayList<Handler>();
+ handlerChain.add(new SOAPHandler());
+ bindingProvider.getBinding().setHandlerChain(handlerChain);
+ }
+
+ public void testCall() throws Exception
+ {
+ String message = "Howdy";
+
+ String response = port.echo(message);
+ assertEquals("Response", message, response);
+ }
+
+}
Deleted: stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/test/java/org/jboss/test/ws/jaxws/jbws2698/SOAPHandler.java
===================================================================
--- stack/native/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2698/SOAPHandler.java 2009-07-07 16:47:12 UTC (rev 10316)
+++ stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/test/java/org/jboss/test/ws/jaxws/jbws2698/SOAPHandler.java 2009-07-08 13:55:33 UTC (rev 10318)
@@ -1,103 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2009, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file 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.jbws2698;
-
-import javax.xml.soap.SOAPBody;
-import javax.xml.soap.SOAPConstants;
-import javax.xml.soap.SOAPElement;
-import javax.xml.soap.SOAPEnvelope;
-import javax.xml.soap.SOAPException;
-import javax.xml.soap.SOAPHeader;
-import javax.xml.soap.SOAPMessage;
-import javax.xml.ws.handler.MessageContext;
-import javax.xml.ws.handler.soap.SOAPMessageContext;
-
-import org.jboss.ws.WSException;
-import org.jboss.wsf.common.handler.GenericSOAPHandler;
-
-/**
- * Handler implementation.
- *
- * @author darran.lofthouse(a)jboss.com
- * @since 7th July 2009
- */
-public class SOAPHandler extends GenericSOAPHandler
-{
- private static final String PREFIX = "JBWS2698";
-
- protected boolean handleOutbound(MessageContext msgContext)
- {
- try
- {
- SOAPMessage message = ((SOAPMessageContext)msgContext).getMessage();
- SOAPEnvelope envelope = message.getSOAPPart().getEnvelope();
- SOAPHeader header = message.getSOAPHeader();
- SOAPBody body = message.getSOAPBody();
-
- envelope.addNamespaceDeclaration(PREFIX, SOAPConstants.URI_NS_SOAP_1_1_ENVELOPE);
- envelope.setPrefix(PREFIX);
- checkPrefix(envelope);
- header.setPrefix(PREFIX);
- checkPrefix(header);
- body.setPrefix(PREFIX);
- checkPrefix(body);
-
- message.saveChanges();
- }
- catch (SOAPException se)
- {
- throw new WSException(se);
- }
- return true;
- }
-
- protected boolean handleInbound(MessageContext msgContext)
- {
- try
- {
- SOAPMessage message = ((SOAPMessageContext)msgContext).getMessage();
-
- SOAPEnvelope envelope = message.getSOAPPart().getEnvelope();
- checkPrefix(envelope);
- SOAPHeader header = message.getSOAPHeader();
- checkPrefix(header);
- SOAPBody body = message.getSOAPBody();
- checkPrefix(body);
- }
- catch (SOAPException se)
- {
- throw new WSException(se);
- }
-
- return true;
- }
-
- private void checkPrefix(final SOAPElement element)
- {
- String prefix = element.getPrefix();
- if (PREFIX.equals(prefix) == false)
- {
- throw new WSException("Expected prefix '" + PREFIX + "' found prefix '" + prefix + "' for element '" + element.getElementName());
- }
-
- }
-}
Copied: stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/test/java/org/jboss/test/ws/jaxws/jbws2698/SOAPHandler.java (from rev 10316, stack/native/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2698/SOAPHandler.java)
===================================================================
--- stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/test/java/org/jboss/test/ws/jaxws/jbws2698/SOAPHandler.java (rev 0)
+++ stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/test/java/org/jboss/test/ws/jaxws/jbws2698/SOAPHandler.java 2009-07-08 13:55:33 UTC (rev 10318)
@@ -0,0 +1,103 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.jbws2698;
+
+import javax.xml.soap.SOAPBody;
+import javax.xml.soap.SOAPConstants;
+import javax.xml.soap.SOAPElement;
+import javax.xml.soap.SOAPEnvelope;
+import javax.xml.soap.SOAPException;
+import javax.xml.soap.SOAPHeader;
+import javax.xml.soap.SOAPMessage;
+import javax.xml.ws.handler.MessageContext;
+import javax.xml.ws.handler.soap.SOAPMessageContext;
+
+import org.jboss.ws.WSException;
+import org.jboss.ws.core.jaxws.handler.GenericSOAPHandler;
+
+/**
+ * Handler implementation.
+ *
+ * @author darran.lofthouse(a)jboss.com
+ * @since 7th July 2009
+ */
+public class SOAPHandler extends GenericSOAPHandler
+{
+ private static final String PREFIX = "JBWS2698";
+
+ protected boolean handleOutbound(MessageContext msgContext)
+ {
+ try
+ {
+ SOAPMessage message = ((SOAPMessageContext)msgContext).getMessage();
+ SOAPEnvelope envelope = message.getSOAPPart().getEnvelope();
+ SOAPHeader header = message.getSOAPHeader();
+ SOAPBody body = message.getSOAPBody();
+
+ envelope.addNamespaceDeclaration(PREFIX, SOAPConstants.URI_NS_SOAP_1_1_ENVELOPE);
+ envelope.setPrefix(PREFIX);
+ checkPrefix(envelope);
+ header.setPrefix(PREFIX);
+ checkPrefix(header);
+ body.setPrefix(PREFIX);
+ checkPrefix(body);
+
+ message.saveChanges();
+ }
+ catch (SOAPException se)
+ {
+ throw new WSException(se);
+ }
+ return true;
+ }
+
+ protected boolean handleInbound(MessageContext msgContext)
+ {
+ try
+ {
+ SOAPMessage message = ((SOAPMessageContext)msgContext).getMessage();
+
+ SOAPEnvelope envelope = message.getSOAPPart().getEnvelope();
+ checkPrefix(envelope);
+ SOAPHeader header = message.getSOAPHeader();
+ checkPrefix(header);
+ SOAPBody body = message.getSOAPBody();
+ checkPrefix(body);
+ }
+ catch (SOAPException se)
+ {
+ throw new WSException(se);
+ }
+
+ return true;
+ }
+
+ private void checkPrefix(final SOAPElement element)
+ {
+ String prefix = element.getPrefix();
+ if (PREFIX.equals(prefix) == false)
+ {
+ throw new WSException("Expected prefix '" + PREFIX + "' found prefix '" + prefix + "' for element '" + element.getElementName());
+ }
+
+ }
+}
Deleted: stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/test/java/org/jboss/test/ws/jaxws/jbws2698/server-handlers.xml
===================================================================
--- stack/native/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2698/server-handlers.xml 2009-07-07 16:47:12 UTC (rev 10316)
+++ stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/test/java/org/jboss/test/ws/jaxws/jbws2698/server-handlers.xml 2009-07-08 13:55:33 UTC (rev 10318)
@@ -1,15 +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"
- xmlns:ns1="http://org.jboss.ws/jaxws/samples/logicalhandler"
- xsi:schemaLocation="http://java.sun.com/xml/ns/javaee javaee_web_services_1_2.xsd">
-
- <handler-chain>
- <handler>
- <handler-name> SOAPHandler </handler-name>
- <handler-class> org.jboss.test.ws.jaxws.jbws2698.SOAPHandler </handler-class>
- </handler>
- </handler-chain>
-
-</handler-chains>
\ No newline at end of file
Copied: stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/test/java/org/jboss/test/ws/jaxws/jbws2698/server-handlers.xml (from rev 10316, stack/native/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2698/server-handlers.xml)
===================================================================
--- stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/test/java/org/jboss/test/ws/jaxws/jbws2698/server-handlers.xml (rev 0)
+++ stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/test/java/org/jboss/test/ws/jaxws/jbws2698/server-handlers.xml 2009-07-08 13:55:33 UTC (rev 10318)
@@ -0,0 +1,15 @@
+<?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"
+ xmlns:ns1="http://org.jboss.ws/jaxws/samples/logicalhandler"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee javaee_web_services_1_2.xsd">
+
+ <handler-chain>
+ <handler>
+ <handler-name> SOAPHandler </handler-name>
+ <handler-class> org.jboss.test.ws.jaxws.jbws2698.SOAPHandler </handler-class>
+ </handler>
+ </handler-chain>
+
+</handler-chains>
\ No newline at end of file
Copied: stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/test/resources/jaxws/jbws2698 (from rev 10316, stack/native/trunk/modules/testsuite/native-tests/src/test/resources/jaxws/jbws2698)
Copied: stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/test/resources/jaxws/jbws2698/WEB-INF (from rev 10316, stack/native/trunk/modules/testsuite/native-tests/src/test/resources/jaxws/jbws2698/WEB-INF)
Deleted: stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/test/resources/jaxws/jbws2698/WEB-INF/jboss-web.xml
===================================================================
--- stack/native/trunk/modules/testsuite/native-tests/src/test/resources/jaxws/jbws2698/WEB-INF/jboss-web.xml 2009-07-07 16:47:12 UTC (rev 10316)
+++ stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/test/resources/jaxws/jbws2698/WEB-INF/jboss-web.xml 2009-07-08 13:55:33 UTC (rev 10318)
@@ -1,7 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<!DOCTYPE jboss-web PUBLIC "-//JBoss//DTD Web Application 2.4//EN" "http://www.jboss.org/j2ee/dtd/jboss-web_4_0.dtd">
-
-<jboss-web>
- <context-root>/jaxws-jbws2698</context-root>
-</jboss-web>
\ No newline at end of file
Copied: stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/test/resources/jaxws/jbws2698/WEB-INF/jboss-web.xml (from rev 10316, stack/native/trunk/modules/testsuite/native-tests/src/test/resources/jaxws/jbws2698/WEB-INF/jboss-web.xml)
===================================================================
--- stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/test/resources/jaxws/jbws2698/WEB-INF/jboss-web.xml (rev 0)
+++ stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/test/resources/jaxws/jbws2698/WEB-INF/jboss-web.xml 2009-07-08 13:55:33 UTC (rev 10318)
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!DOCTYPE jboss-web PUBLIC "-//JBoss//DTD Web Application 2.4//EN" "http://www.jboss.org/j2ee/dtd/jboss-web_4_0.dtd">
+
+<jboss-web>
+ <context-root>/jaxws-jbws2698</context-root>
+</jboss-web>
\ No newline at end of file
Deleted: stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/test/resources/jaxws/jbws2698/WEB-INF/web.xml
===================================================================
--- stack/native/trunk/modules/testsuite/native-tests/src/test/resources/jaxws/jbws2698/WEB-INF/web.xml 2009-07-07 16:47:12 UTC (rev 10316)
+++ stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/test/resources/jaxws/jbws2698/WEB-INF/web.xml 2009-07-08 13:55:33 UTC (rev 10318)
@@ -1,16 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
-
- <servlet>
- <servlet-name>Endpoint</servlet-name>
- <servlet-class>org.jboss.test.ws.jaxws.jbws2698.EndpointImpl</servlet-class>
- </servlet>
-
- <servlet-mapping>
- <servlet-name>Endpoint</servlet-name>
- <url-pattern>/*</url-pattern>
- </servlet-mapping>
-
-</web-app>
\ No newline at end of file
Copied: stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/test/resources/jaxws/jbws2698/WEB-INF/web.xml (from rev 10316, stack/native/trunk/modules/testsuite/native-tests/src/test/resources/jaxws/jbws2698/WEB-INF/web.xml)
===================================================================
--- stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/test/resources/jaxws/jbws2698/WEB-INF/web.xml (rev 0)
+++ stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/test/resources/jaxws/jbws2698/WEB-INF/web.xml 2009-07-08 13:55:33 UTC (rev 10318)
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
+
+ <servlet>
+ <servlet-name>Endpoint</servlet-name>
+ <servlet-class>org.jboss.test.ws.jaxws.jbws2698.EndpointImpl</servlet-class>
+ </servlet>
+
+ <servlet-mapping>
+ <servlet-name>Endpoint</servlet-name>
+ <url-pattern>/*</url-pattern>
+ </servlet-mapping>
+
+</web-app>
\ No newline at end of file
16 years, 4 months
JBossWS SVN: r10317 - in stack/native/branches/jbossws-native-3.1.2/modules: testsuite/native-tests/scripts and 5 other directories.
by jbossws-commits@lists.jboss.org
Author: darran.lofthouse(a)jboss.com
Date: 2009-07-08 08:35:46 -0400 (Wed, 08 Jul 2009)
New Revision: 10317
Added:
stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2698/
stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2698/Endpoint.java
stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2698/EndpointImpl.java
stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2698/JBWS2698TestCase.java
stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2698/SOAPHandler.java
stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2698/server-handlers.xml
stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/src/test/resources/jaxws/jbws2698/
stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/src/test/resources/jaxws/jbws2698/WEB-INF/
stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/src/test/resources/jaxws/jbws2698/WEB-INF/jboss-web.xml
stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/src/test/resources/jaxws/jbws2698/WEB-INF/web.xml
Removed:
stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2698/Endpoint.java
stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2698/EndpointImpl.java
stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2698/JBWS2698TestCase.java
stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2698/SOAPHandler.java
stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2698/server-handlers.xml
stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/src/test/resources/jaxws/jbws2698/WEB-INF/
stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/src/test/resources/jaxws/jbws2698/WEB-INF/jboss-web.xml
stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/src/test/resources/jaxws/jbws2698/WEB-INF/web.xml
Modified:
stack/native/branches/jbossws-native-3.1.2/modules/core/src/main/java/org/jboss/ws/core/soap/SOAPElementImpl.java
stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/scripts/build-jars-jaxws.xml
Log:
[JBPAPP-2239] Calling setPrefix(newPrefix) on any SOAPElement the prefix is not used for marshalling.
Modified: stack/native/branches/jbossws-native-3.1.2/modules/core/src/main/java/org/jboss/ws/core/soap/SOAPElementImpl.java
===================================================================
--- stack/native/branches/jbossws-native-3.1.2/modules/core/src/main/java/org/jboss/ws/core/soap/SOAPElementImpl.java 2009-07-07 16:47:12 UTC (rev 10316)
+++ stack/native/branches/jbossws-native-3.1.2/modules/core/src/main/java/org/jboss/ws/core/soap/SOAPElementImpl.java 2009-07-08 12:35:46 UTC (rev 10317)
@@ -791,6 +791,13 @@
{
visitor.visitSOAPElement(this);
}
+
+ @Override
+ public void setPrefix(String prefix) throws DOMException
+ {
+ super.setPrefix(prefix);
+ elementName = null;
+ }
/**
* The default implementation uses a DOMWriter.
Modified: stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/scripts/build-jars-jaxws.xml
===================================================================
--- stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/scripts/build-jars-jaxws.xml 2009-07-07 16:47:12 UTC (rev 10316)
+++ stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/scripts/build-jars-jaxws.xml 2009-07-08 12:35:46 UTC (rev 10317)
@@ -558,8 +558,20 @@
<include name="org/jboss/test/ws/jaxws/jbws2682/Endpoint.class"/>
<include name="org/jboss/test/ws/jaxws/jbws2682/EndpointImpl.class"/>
</classes>
- </war>
+ </war>
+ <!-- jaxws-jbws2698 -->
+ <war warfile="${tests.output.dir}/test-libs/jaxws-jbws2698.war" webxml="${tests.output.dir}/test-resources/jaxws/jbws2698/WEB-INF/web.xml">
+ <classes dir="${tests.output.dir}/test-classes">
+ <include name="org/jboss/test/ws/jaxws/jbws2698/*.class"/>
+ <exclude name="org/jboss/test/ws/jaxws/jbws2698/JBWS2698TestCase.class"/>
+ <include name="org/jboss/test/ws/jaxws/jbws2698/server-handlers.xml"/>
+ </classes>
+ <webinf dir="${tests.output.dir}/test-resources/jaxws/jbws2698/WEB-INF">
+ <include name="jboss-web.xml"/>
+ </webinf>
+ </war>
+
<!-- jaxws-webserviceref -->
<war warfile="${tests.output.dir}/test-libs/jaxws-webserviceref.war" webxml="${tests.output.dir}/test-resources/jaxws/webserviceref/WEB-INF/web.xml">
<classes dir="${tests.output.dir}/test-classes">
Copied: stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2698 (from rev 10316, stack/native/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2698)
Deleted: stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2698/Endpoint.java
===================================================================
--- stack/native/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2698/Endpoint.java 2009-07-07 16:47:12 UTC (rev 10316)
+++ stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2698/Endpoint.java 2009-07-08 12:35:46 UTC (rev 10317)
@@ -1,38 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2009, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file 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.jbws2698;
-
-import javax.jws.WebService;
-
-/**
- * Test Endpoint.
- *
- * @author darran.lofthouse(a)jboss.com
- * @since 7th July 2009
- */
-@WebService(name = "Endpoint", targetNamespace = "http://ws.jboss.org/jbws2698")
-public interface Endpoint
-{
-
- public String echo(final String message);
-
-}
Copied: stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2698/Endpoint.java (from rev 10316, stack/native/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2698/Endpoint.java)
===================================================================
--- stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2698/Endpoint.java (rev 0)
+++ stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2698/Endpoint.java 2009-07-08 12:35:46 UTC (rev 10317)
@@ -0,0 +1,38 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.jbws2698;
+
+import javax.jws.WebService;
+
+/**
+ * Test Endpoint.
+ *
+ * @author darran.lofthouse(a)jboss.com
+ * @since 7th July 2009
+ */
+@WebService(name = "Endpoint", targetNamespace = "http://ws.jboss.org/jbws2698")
+public interface Endpoint
+{
+
+ public String echo(final String message);
+
+}
Deleted: stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2698/EndpointImpl.java
===================================================================
--- stack/native/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2698/EndpointImpl.java 2009-07-07 16:47:12 UTC (rev 10316)
+++ stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2698/EndpointImpl.java 2009-07-08 12:35:46 UTC (rev 10317)
@@ -1,43 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2009, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file 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.jbws2698;
-
-import javax.jws.HandlerChain;
-import javax.jws.WebService;
-
-/**
- * Test Endpoint implementation.
- *
- * @author darran.lofthouse(a)jboss.com
- * @since 7th July 2009
- */
-@WebService(name = "Endpoint", targetNamespace = "http://ws.jboss.org/jbws2698", endpointInterface = "org.jboss.test.ws.jaxws.jbws2698.Endpoint")
-@HandlerChain(file = "server-handlers.xml")
-public class EndpointImpl implements Endpoint
-{
-
- public String echo(final String message)
- {
- return message;
- }
-
-}
Copied: stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2698/EndpointImpl.java (from rev 10316, stack/native/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2698/EndpointImpl.java)
===================================================================
--- stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2698/EndpointImpl.java (rev 0)
+++ stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2698/EndpointImpl.java 2009-07-08 12:35:46 UTC (rev 10317)
@@ -0,0 +1,43 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.jbws2698;
+
+import javax.jws.HandlerChain;
+import javax.jws.WebService;
+
+/**
+ * Test Endpoint implementation.
+ *
+ * @author darran.lofthouse(a)jboss.com
+ * @since 7th July 2009
+ */
+@WebService(name = "Endpoint", targetNamespace = "http://ws.jboss.org/jbws2698", endpointInterface = "org.jboss.test.ws.jaxws.jbws2698.Endpoint")
+@HandlerChain(file = "server-handlers.xml")
+public class EndpointImpl implements Endpoint
+{
+
+ public String echo(final String message)
+ {
+ return message;
+ }
+
+}
Deleted: stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2698/JBWS2698TestCase.java
===================================================================
--- stack/native/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2698/JBWS2698TestCase.java 2009-07-07 16:47:12 UTC (rev 10316)
+++ stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2698/JBWS2698TestCase.java 2009-07-08 12:35:46 UTC (rev 10317)
@@ -1,80 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2009, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file 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.jbws2698;
-
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.xml.namespace.QName;
-import javax.xml.ws.BindingProvider;
-import javax.xml.ws.Service;
-
-import junit.framework.Test;
-import javax.xml.ws.handler.Handler;
-import org.jboss.wsf.test.JBossWSTest;
-import org.jboss.wsf.test.JBossWSTestSetup;
-
-/**
- * [JBWS-2698] Calling setPrefix(newPrefix) on any SOAPElement the
- * prefix is not used for marshalling.
- *
- * @author darran.lofthouse(a)jboss.com
- * @since 7th July 2009
- * @see https://jira.jboss.org/jira/browse/JBWS-2698
- */
-public class JBWS2698TestCase extends JBossWSTest
-{
-
- public final String TARGET_ENDPOINT_ADDRESS = "http://" + getServerHost() + ":8080/jaxws-jbws2698/";
-
- private static Endpoint port;
-
- public static Test suite() throws Exception
- {
- return new JBossWSTestSetup(JBWS2698TestCase.class, "jaxws-jbws2698.war");
- }
-
- public void setUp() throws Exception
- {
- super.setUp();
- URL wsdlURL = new URL(TARGET_ENDPOINT_ADDRESS + "?wsdl");
- QName serviceName = new QName("http://ws.jboss.org/jbws2698", "EndpointImplService");
-
- Service service = Service.create(wsdlURL, serviceName);
- port = service.getPort(Endpoint.class);
-
- BindingProvider bindingProvider = (BindingProvider)port;
- List<Handler> handlerChain = new ArrayList<Handler>();
- handlerChain.add(new SOAPHandler());
- bindingProvider.getBinding().setHandlerChain(handlerChain);
- }
-
- public void testCall() throws Exception
- {
- String message = "Howdy";
-
- String response = port.echo(message);
- assertEquals("Response", message, response);
- }
-
-}
Copied: stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2698/JBWS2698TestCase.java (from rev 10316, stack/native/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2698/JBWS2698TestCase.java)
===================================================================
--- stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2698/JBWS2698TestCase.java (rev 0)
+++ stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2698/JBWS2698TestCase.java 2009-07-08 12:35:46 UTC (rev 10317)
@@ -0,0 +1,80 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.jbws2698;
+
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.xml.namespace.QName;
+import javax.xml.ws.BindingProvider;
+import javax.xml.ws.Service;
+
+import junit.framework.Test;
+import javax.xml.ws.handler.Handler;
+import org.jboss.wsf.test.JBossWSTest;
+import org.jboss.wsf.test.JBossWSTestSetup;
+
+/**
+ * [JBWS-2698] Calling setPrefix(newPrefix) on any SOAPElement the
+ * prefix is not used for marshalling.
+ *
+ * @author darran.lofthouse(a)jboss.com
+ * @since 7th July 2009
+ * @see https://jira.jboss.org/jira/browse/JBWS-2698
+ */
+public class JBWS2698TestCase extends JBossWSTest
+{
+
+ public final String TARGET_ENDPOINT_ADDRESS = "http://" + getServerHost() + ":8080/jaxws-jbws2698/";
+
+ private static Endpoint port;
+
+ public static Test suite() throws Exception
+ {
+ return new JBossWSTestSetup(JBWS2698TestCase.class, "jaxws-jbws2698.war");
+ }
+
+ public void setUp() throws Exception
+ {
+ super.setUp();
+ URL wsdlURL = new URL(TARGET_ENDPOINT_ADDRESS + "?wsdl");
+ QName serviceName = new QName("http://ws.jboss.org/jbws2698", "EndpointImplService");
+
+ Service service = Service.create(wsdlURL, serviceName);
+ port = service.getPort(Endpoint.class);
+
+ BindingProvider bindingProvider = (BindingProvider)port;
+ List<Handler> handlerChain = new ArrayList<Handler>();
+ handlerChain.add(new SOAPHandler());
+ bindingProvider.getBinding().setHandlerChain(handlerChain);
+ }
+
+ public void testCall() throws Exception
+ {
+ String message = "Howdy";
+
+ String response = port.echo(message);
+ assertEquals("Response", message, response);
+ }
+
+}
Deleted: stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2698/SOAPHandler.java
===================================================================
--- stack/native/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2698/SOAPHandler.java 2009-07-07 16:47:12 UTC (rev 10316)
+++ stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2698/SOAPHandler.java 2009-07-08 12:35:46 UTC (rev 10317)
@@ -1,103 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2009, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file 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.jbws2698;
-
-import javax.xml.soap.SOAPBody;
-import javax.xml.soap.SOAPConstants;
-import javax.xml.soap.SOAPElement;
-import javax.xml.soap.SOAPEnvelope;
-import javax.xml.soap.SOAPException;
-import javax.xml.soap.SOAPHeader;
-import javax.xml.soap.SOAPMessage;
-import javax.xml.ws.handler.MessageContext;
-import javax.xml.ws.handler.soap.SOAPMessageContext;
-
-import org.jboss.ws.WSException;
-import org.jboss.wsf.common.handler.GenericSOAPHandler;
-
-/**
- * Handler implementation.
- *
- * @author darran.lofthouse(a)jboss.com
- * @since 7th July 2009
- */
-public class SOAPHandler extends GenericSOAPHandler
-{
- private static final String PREFIX = "JBWS2698";
-
- protected boolean handleOutbound(MessageContext msgContext)
- {
- try
- {
- SOAPMessage message = ((SOAPMessageContext)msgContext).getMessage();
- SOAPEnvelope envelope = message.getSOAPPart().getEnvelope();
- SOAPHeader header = message.getSOAPHeader();
- SOAPBody body = message.getSOAPBody();
-
- envelope.addNamespaceDeclaration(PREFIX, SOAPConstants.URI_NS_SOAP_1_1_ENVELOPE);
- envelope.setPrefix(PREFIX);
- checkPrefix(envelope);
- header.setPrefix(PREFIX);
- checkPrefix(header);
- body.setPrefix(PREFIX);
- checkPrefix(body);
-
- message.saveChanges();
- }
- catch (SOAPException se)
- {
- throw new WSException(se);
- }
- return true;
- }
-
- protected boolean handleInbound(MessageContext msgContext)
- {
- try
- {
- SOAPMessage message = ((SOAPMessageContext)msgContext).getMessage();
-
- SOAPEnvelope envelope = message.getSOAPPart().getEnvelope();
- checkPrefix(envelope);
- SOAPHeader header = message.getSOAPHeader();
- checkPrefix(header);
- SOAPBody body = message.getSOAPBody();
- checkPrefix(body);
- }
- catch (SOAPException se)
- {
- throw new WSException(se);
- }
-
- return true;
- }
-
- private void checkPrefix(final SOAPElement element)
- {
- String prefix = element.getPrefix();
- if (PREFIX.equals(prefix) == false)
- {
- throw new WSException("Expected prefix '" + PREFIX + "' found prefix '" + prefix + "' for element '" + element.getElementName());
- }
-
- }
-}
Copied: stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2698/SOAPHandler.java (from rev 10316, stack/native/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2698/SOAPHandler.java)
===================================================================
--- stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2698/SOAPHandler.java (rev 0)
+++ stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2698/SOAPHandler.java 2009-07-08 12:35:46 UTC (rev 10317)
@@ -0,0 +1,103 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.jbws2698;
+
+import javax.xml.soap.SOAPBody;
+import javax.xml.soap.SOAPConstants;
+import javax.xml.soap.SOAPElement;
+import javax.xml.soap.SOAPEnvelope;
+import javax.xml.soap.SOAPException;
+import javax.xml.soap.SOAPHeader;
+import javax.xml.soap.SOAPMessage;
+import javax.xml.ws.handler.MessageContext;
+import javax.xml.ws.handler.soap.SOAPMessageContext;
+
+import org.jboss.ws.WSException;
+import org.jboss.wsf.common.handler.GenericSOAPHandler;
+
+/**
+ * Handler implementation.
+ *
+ * @author darran.lofthouse(a)jboss.com
+ * @since 7th July 2009
+ */
+public class SOAPHandler extends GenericSOAPHandler
+{
+ private static final String PREFIX = "JBWS2698";
+
+ protected boolean handleOutbound(MessageContext msgContext)
+ {
+ try
+ {
+ SOAPMessage message = ((SOAPMessageContext)msgContext).getMessage();
+ SOAPEnvelope envelope = message.getSOAPPart().getEnvelope();
+ SOAPHeader header = message.getSOAPHeader();
+ SOAPBody body = message.getSOAPBody();
+
+ envelope.addNamespaceDeclaration(PREFIX, SOAPConstants.URI_NS_SOAP_1_1_ENVELOPE);
+ envelope.setPrefix(PREFIX);
+ checkPrefix(envelope);
+ header.setPrefix(PREFIX);
+ checkPrefix(header);
+ body.setPrefix(PREFIX);
+ checkPrefix(body);
+
+ message.saveChanges();
+ }
+ catch (SOAPException se)
+ {
+ throw new WSException(se);
+ }
+ return true;
+ }
+
+ protected boolean handleInbound(MessageContext msgContext)
+ {
+ try
+ {
+ SOAPMessage message = ((SOAPMessageContext)msgContext).getMessage();
+
+ SOAPEnvelope envelope = message.getSOAPPart().getEnvelope();
+ checkPrefix(envelope);
+ SOAPHeader header = message.getSOAPHeader();
+ checkPrefix(header);
+ SOAPBody body = message.getSOAPBody();
+ checkPrefix(body);
+ }
+ catch (SOAPException se)
+ {
+ throw new WSException(se);
+ }
+
+ return true;
+ }
+
+ private void checkPrefix(final SOAPElement element)
+ {
+ String prefix = element.getPrefix();
+ if (PREFIX.equals(prefix) == false)
+ {
+ throw new WSException("Expected prefix '" + PREFIX + "' found prefix '" + prefix + "' for element '" + element.getElementName());
+ }
+
+ }
+}
Deleted: stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2698/server-handlers.xml
===================================================================
--- stack/native/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2698/server-handlers.xml 2009-07-07 16:47:12 UTC (rev 10316)
+++ stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2698/server-handlers.xml 2009-07-08 12:35:46 UTC (rev 10317)
@@ -1,15 +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"
- xmlns:ns1="http://org.jboss.ws/jaxws/samples/logicalhandler"
- xsi:schemaLocation="http://java.sun.com/xml/ns/javaee javaee_web_services_1_2.xsd">
-
- <handler-chain>
- <handler>
- <handler-name> SOAPHandler </handler-name>
- <handler-class> org.jboss.test.ws.jaxws.jbws2698.SOAPHandler </handler-class>
- </handler>
- </handler-chain>
-
-</handler-chains>
\ No newline at end of file
Copied: stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2698/server-handlers.xml (from rev 10316, stack/native/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2698/server-handlers.xml)
===================================================================
--- stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2698/server-handlers.xml (rev 0)
+++ stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2698/server-handlers.xml 2009-07-08 12:35:46 UTC (rev 10317)
@@ -0,0 +1,15 @@
+<?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"
+ xmlns:ns1="http://org.jboss.ws/jaxws/samples/logicalhandler"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee javaee_web_services_1_2.xsd">
+
+ <handler-chain>
+ <handler>
+ <handler-name> SOAPHandler </handler-name>
+ <handler-class> org.jboss.test.ws.jaxws.jbws2698.SOAPHandler </handler-class>
+ </handler>
+ </handler-chain>
+
+</handler-chains>
\ No newline at end of file
Copied: stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/src/test/resources/jaxws/jbws2698 (from rev 10316, stack/native/trunk/modules/testsuite/native-tests/src/test/resources/jaxws/jbws2698)
Copied: stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/src/test/resources/jaxws/jbws2698/WEB-INF (from rev 10316, stack/native/trunk/modules/testsuite/native-tests/src/test/resources/jaxws/jbws2698/WEB-INF)
Deleted: stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/src/test/resources/jaxws/jbws2698/WEB-INF/jboss-web.xml
===================================================================
--- stack/native/trunk/modules/testsuite/native-tests/src/test/resources/jaxws/jbws2698/WEB-INF/jboss-web.xml 2009-07-07 16:47:12 UTC (rev 10316)
+++ stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/src/test/resources/jaxws/jbws2698/WEB-INF/jboss-web.xml 2009-07-08 12:35:46 UTC (rev 10317)
@@ -1,7 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<!DOCTYPE jboss-web PUBLIC "-//JBoss//DTD Web Application 2.4//EN" "http://www.jboss.org/j2ee/dtd/jboss-web_4_0.dtd">
-
-<jboss-web>
- <context-root>/jaxws-jbws2698</context-root>
-</jboss-web>
\ No newline at end of file
Copied: stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/src/test/resources/jaxws/jbws2698/WEB-INF/jboss-web.xml (from rev 10316, stack/native/trunk/modules/testsuite/native-tests/src/test/resources/jaxws/jbws2698/WEB-INF/jboss-web.xml)
===================================================================
--- stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/src/test/resources/jaxws/jbws2698/WEB-INF/jboss-web.xml (rev 0)
+++ stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/src/test/resources/jaxws/jbws2698/WEB-INF/jboss-web.xml 2009-07-08 12:35:46 UTC (rev 10317)
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!DOCTYPE jboss-web PUBLIC "-//JBoss//DTD Web Application 2.4//EN" "http://www.jboss.org/j2ee/dtd/jboss-web_4_0.dtd">
+
+<jboss-web>
+ <context-root>/jaxws-jbws2698</context-root>
+</jboss-web>
\ No newline at end of file
Deleted: stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/src/test/resources/jaxws/jbws2698/WEB-INF/web.xml
===================================================================
--- stack/native/trunk/modules/testsuite/native-tests/src/test/resources/jaxws/jbws2698/WEB-INF/web.xml 2009-07-07 16:47:12 UTC (rev 10316)
+++ stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/src/test/resources/jaxws/jbws2698/WEB-INF/web.xml 2009-07-08 12:35:46 UTC (rev 10317)
@@ -1,16 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
-
- <servlet>
- <servlet-name>Endpoint</servlet-name>
- <servlet-class>org.jboss.test.ws.jaxws.jbws2698.EndpointImpl</servlet-class>
- </servlet>
-
- <servlet-mapping>
- <servlet-name>Endpoint</servlet-name>
- <url-pattern>/*</url-pattern>
- </servlet-mapping>
-
-</web-app>
\ No newline at end of file
Copied: stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/src/test/resources/jaxws/jbws2698/WEB-INF/web.xml (from rev 10316, stack/native/trunk/modules/testsuite/native-tests/src/test/resources/jaxws/jbws2698/WEB-INF/web.xml)
===================================================================
--- stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/src/test/resources/jaxws/jbws2698/WEB-INF/web.xml (rev 0)
+++ stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/src/test/resources/jaxws/jbws2698/WEB-INF/web.xml 2009-07-08 12:35:46 UTC (rev 10317)
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
+
+ <servlet>
+ <servlet-name>Endpoint</servlet-name>
+ <servlet-class>org.jboss.test.ws.jaxws.jbws2698.EndpointImpl</servlet-class>
+ </servlet>
+
+ <servlet-mapping>
+ <servlet-name>Endpoint</servlet-name>
+ <url-pattern>/*</url-pattern>
+ </servlet-mapping>
+
+</web-app>
\ No newline at end of file
16 years, 4 months
JBossWS SVN: r10316 - in stack/native/trunk/modules: testsuite/native-tests/scripts and 5 other directories.
by jbossws-commits@lists.jboss.org
Author: darran.lofthouse(a)jboss.com
Date: 2009-07-07 12:47:12 -0400 (Tue, 07 Jul 2009)
New Revision: 10316
Added:
stack/native/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2698/
stack/native/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2698/Endpoint.java
stack/native/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2698/EndpointImpl.java
stack/native/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2698/JBWS2698TestCase.java
stack/native/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2698/SOAPHandler.java
stack/native/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2698/server-handlers.xml
stack/native/trunk/modules/testsuite/native-tests/src/test/resources/jaxws/jbws2698/
stack/native/trunk/modules/testsuite/native-tests/src/test/resources/jaxws/jbws2698/WEB-INF/
stack/native/trunk/modules/testsuite/native-tests/src/test/resources/jaxws/jbws2698/WEB-INF/jboss-web.xml
stack/native/trunk/modules/testsuite/native-tests/src/test/resources/jaxws/jbws2698/WEB-INF/web.xml
Modified:
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/soap/SOAPElementImpl.java
stack/native/trunk/modules/testsuite/native-tests/scripts/build-jars-jaxws.xml
Log:
[JBWS-2698] Calling setPrefix(newPrefix) on any SOAPElement the prefix is not used for marshalling.
Modified: stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/soap/SOAPElementImpl.java
===================================================================
--- stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/soap/SOAPElementImpl.java 2009-07-04 14:44:05 UTC (rev 10315)
+++ stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/soap/SOAPElementImpl.java 2009-07-07 16:47:12 UTC (rev 10316)
@@ -791,6 +791,13 @@
{
visitor.visitSOAPElement(this);
}
+
+ @Override
+ public void setPrefix(String prefix) throws DOMException
+ {
+ super.setPrefix(prefix);
+ elementName = null;
+ }
/**
* The default implementation uses a DOMWriter.
Modified: stack/native/trunk/modules/testsuite/native-tests/scripts/build-jars-jaxws.xml
===================================================================
--- stack/native/trunk/modules/testsuite/native-tests/scripts/build-jars-jaxws.xml 2009-07-04 14:44:05 UTC (rev 10315)
+++ stack/native/trunk/modules/testsuite/native-tests/scripts/build-jars-jaxws.xml 2009-07-07 16:47:12 UTC (rev 10316)
@@ -558,8 +558,20 @@
<include name="org/jboss/test/ws/jaxws/jbws2682/Endpoint.class"/>
<include name="org/jboss/test/ws/jaxws/jbws2682/EndpointImpl.class"/>
</classes>
- </war>
+ </war>
+ <!-- jaxws-jbws2698 -->
+ <war warfile="${tests.output.dir}/test-libs/jaxws-jbws2698.war" webxml="${tests.output.dir}/test-resources/jaxws/jbws2698/WEB-INF/web.xml">
+ <classes dir="${tests.output.dir}/test-classes">
+ <include name="org/jboss/test/ws/jaxws/jbws2698/*.class"/>
+ <exclude name="org/jboss/test/ws/jaxws/jbws2698/JBWS2698TestCase.class"/>
+ <include name="org/jboss/test/ws/jaxws/jbws2698/server-handlers.xml"/>
+ </classes>
+ <webinf dir="${tests.output.dir}/test-resources/jaxws/jbws2698/WEB-INF">
+ <include name="jboss-web.xml"/>
+ </webinf>
+ </war>
+
<!-- jaxws-webserviceref -->
<war warfile="${tests.output.dir}/test-libs/jaxws-webserviceref.war" webxml="${tests.output.dir}/test-resources/jaxws/webserviceref/WEB-INF/web.xml">
<classes dir="${tests.output.dir}/test-classes">
Added: stack/native/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2698/Endpoint.java
===================================================================
--- stack/native/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2698/Endpoint.java (rev 0)
+++ stack/native/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2698/Endpoint.java 2009-07-07 16:47:12 UTC (rev 10316)
@@ -0,0 +1,38 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.jbws2698;
+
+import javax.jws.WebService;
+
+/**
+ * Test Endpoint.
+ *
+ * @author darran.lofthouse(a)jboss.com
+ * @since 7th July 2009
+ */
+@WebService(name = "Endpoint", targetNamespace = "http://ws.jboss.org/jbws2698")
+public interface Endpoint
+{
+
+ public String echo(final String message);
+
+}
Property changes on: stack/native/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2698/Endpoint.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: stack/native/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2698/EndpointImpl.java
===================================================================
--- stack/native/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2698/EndpointImpl.java (rev 0)
+++ stack/native/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2698/EndpointImpl.java 2009-07-07 16:47:12 UTC (rev 10316)
@@ -0,0 +1,43 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.jbws2698;
+
+import javax.jws.HandlerChain;
+import javax.jws.WebService;
+
+/**
+ * Test Endpoint implementation.
+ *
+ * @author darran.lofthouse(a)jboss.com
+ * @since 7th July 2009
+ */
+@WebService(name = "Endpoint", targetNamespace = "http://ws.jboss.org/jbws2698", endpointInterface = "org.jboss.test.ws.jaxws.jbws2698.Endpoint")
+@HandlerChain(file = "server-handlers.xml")
+public class EndpointImpl implements Endpoint
+{
+
+ public String echo(final String message)
+ {
+ return message;
+ }
+
+}
Property changes on: stack/native/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2698/EndpointImpl.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: stack/native/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2698/JBWS2698TestCase.java
===================================================================
--- stack/native/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2698/JBWS2698TestCase.java (rev 0)
+++ stack/native/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2698/JBWS2698TestCase.java 2009-07-07 16:47:12 UTC (rev 10316)
@@ -0,0 +1,80 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.jbws2698;
+
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.xml.namespace.QName;
+import javax.xml.ws.BindingProvider;
+import javax.xml.ws.Service;
+
+import junit.framework.Test;
+import javax.xml.ws.handler.Handler;
+import org.jboss.wsf.test.JBossWSTest;
+import org.jboss.wsf.test.JBossWSTestSetup;
+
+/**
+ * [JBWS-2698] Calling setPrefix(newPrefix) on any SOAPElement the
+ * prefix is not used for marshalling.
+ *
+ * @author darran.lofthouse(a)jboss.com
+ * @since 7th July 2009
+ * @see https://jira.jboss.org/jira/browse/JBWS-2698
+ */
+public class JBWS2698TestCase extends JBossWSTest
+{
+
+ public final String TARGET_ENDPOINT_ADDRESS = "http://" + getServerHost() + ":8080/jaxws-jbws2698/";
+
+ private static Endpoint port;
+
+ public static Test suite() throws Exception
+ {
+ return new JBossWSTestSetup(JBWS2698TestCase.class, "jaxws-jbws2698.war");
+ }
+
+ public void setUp() throws Exception
+ {
+ super.setUp();
+ URL wsdlURL = new URL(TARGET_ENDPOINT_ADDRESS + "?wsdl");
+ QName serviceName = new QName("http://ws.jboss.org/jbws2698", "EndpointImplService");
+
+ Service service = Service.create(wsdlURL, serviceName);
+ port = service.getPort(Endpoint.class);
+
+ BindingProvider bindingProvider = (BindingProvider)port;
+ List<Handler> handlerChain = new ArrayList<Handler>();
+ handlerChain.add(new SOAPHandler());
+ bindingProvider.getBinding().setHandlerChain(handlerChain);
+ }
+
+ public void testCall() throws Exception
+ {
+ String message = "Howdy";
+
+ String response = port.echo(message);
+ assertEquals("Response", message, response);
+ }
+
+}
Property changes on: stack/native/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2698/JBWS2698TestCase.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: stack/native/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2698/SOAPHandler.java
===================================================================
--- stack/native/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2698/SOAPHandler.java (rev 0)
+++ stack/native/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2698/SOAPHandler.java 2009-07-07 16:47:12 UTC (rev 10316)
@@ -0,0 +1,103 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.jbws2698;
+
+import javax.xml.soap.SOAPBody;
+import javax.xml.soap.SOAPConstants;
+import javax.xml.soap.SOAPElement;
+import javax.xml.soap.SOAPEnvelope;
+import javax.xml.soap.SOAPException;
+import javax.xml.soap.SOAPHeader;
+import javax.xml.soap.SOAPMessage;
+import javax.xml.ws.handler.MessageContext;
+import javax.xml.ws.handler.soap.SOAPMessageContext;
+
+import org.jboss.ws.WSException;
+import org.jboss.wsf.common.handler.GenericSOAPHandler;
+
+/**
+ * Handler implementation.
+ *
+ * @author darran.lofthouse(a)jboss.com
+ * @since 7th July 2009
+ */
+public class SOAPHandler extends GenericSOAPHandler
+{
+ private static final String PREFIX = "JBWS2698";
+
+ protected boolean handleOutbound(MessageContext msgContext)
+ {
+ try
+ {
+ SOAPMessage message = ((SOAPMessageContext)msgContext).getMessage();
+ SOAPEnvelope envelope = message.getSOAPPart().getEnvelope();
+ SOAPHeader header = message.getSOAPHeader();
+ SOAPBody body = message.getSOAPBody();
+
+ envelope.addNamespaceDeclaration(PREFIX, SOAPConstants.URI_NS_SOAP_1_1_ENVELOPE);
+ envelope.setPrefix(PREFIX);
+ checkPrefix(envelope);
+ header.setPrefix(PREFIX);
+ checkPrefix(header);
+ body.setPrefix(PREFIX);
+ checkPrefix(body);
+
+ message.saveChanges();
+ }
+ catch (SOAPException se)
+ {
+ throw new WSException(se);
+ }
+ return true;
+ }
+
+ protected boolean handleInbound(MessageContext msgContext)
+ {
+ try
+ {
+ SOAPMessage message = ((SOAPMessageContext)msgContext).getMessage();
+
+ SOAPEnvelope envelope = message.getSOAPPart().getEnvelope();
+ checkPrefix(envelope);
+ SOAPHeader header = message.getSOAPHeader();
+ checkPrefix(header);
+ SOAPBody body = message.getSOAPBody();
+ checkPrefix(body);
+ }
+ catch (SOAPException se)
+ {
+ throw new WSException(se);
+ }
+
+ return true;
+ }
+
+ private void checkPrefix(final SOAPElement element)
+ {
+ String prefix = element.getPrefix();
+ if (PREFIX.equals(prefix) == false)
+ {
+ throw new WSException("Expected prefix '" + PREFIX + "' found prefix '" + prefix + "' for element '" + element.getElementName());
+ }
+
+ }
+}
Property changes on: stack/native/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2698/SOAPHandler.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: stack/native/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2698/server-handlers.xml
===================================================================
--- stack/native/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2698/server-handlers.xml (rev 0)
+++ stack/native/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2698/server-handlers.xml 2009-07-07 16:47:12 UTC (rev 10316)
@@ -0,0 +1,15 @@
+<?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"
+ xmlns:ns1="http://org.jboss.ws/jaxws/samples/logicalhandler"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee javaee_web_services_1_2.xsd">
+
+ <handler-chain>
+ <handler>
+ <handler-name> SOAPHandler </handler-name>
+ <handler-class> org.jboss.test.ws.jaxws.jbws2698.SOAPHandler </handler-class>
+ </handler>
+ </handler-chain>
+
+</handler-chains>
\ No newline at end of file
Property changes on: stack/native/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2698/server-handlers.xml
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: stack/native/trunk/modules/testsuite/native-tests/src/test/resources/jaxws/jbws2698/WEB-INF/jboss-web.xml
===================================================================
--- stack/native/trunk/modules/testsuite/native-tests/src/test/resources/jaxws/jbws2698/WEB-INF/jboss-web.xml (rev 0)
+++ stack/native/trunk/modules/testsuite/native-tests/src/test/resources/jaxws/jbws2698/WEB-INF/jboss-web.xml 2009-07-07 16:47:12 UTC (rev 10316)
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!DOCTYPE jboss-web PUBLIC "-//JBoss//DTD Web Application 2.4//EN" "http://www.jboss.org/j2ee/dtd/jboss-web_4_0.dtd">
+
+<jboss-web>
+ <context-root>/jaxws-jbws2698</context-root>
+</jboss-web>
\ No newline at end of file
Property changes on: stack/native/trunk/modules/testsuite/native-tests/src/test/resources/jaxws/jbws2698/WEB-INF/jboss-web.xml
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: stack/native/trunk/modules/testsuite/native-tests/src/test/resources/jaxws/jbws2698/WEB-INF/web.xml
===================================================================
--- stack/native/trunk/modules/testsuite/native-tests/src/test/resources/jaxws/jbws2698/WEB-INF/web.xml (rev 0)
+++ stack/native/trunk/modules/testsuite/native-tests/src/test/resources/jaxws/jbws2698/WEB-INF/web.xml 2009-07-07 16:47:12 UTC (rev 10316)
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
+
+ <servlet>
+ <servlet-name>Endpoint</servlet-name>
+ <servlet-class>org.jboss.test.ws.jaxws.jbws2698.EndpointImpl</servlet-class>
+ </servlet>
+
+ <servlet-mapping>
+ <servlet-name>Endpoint</servlet-name>
+ <url-pattern>/*</url-pattern>
+ </servlet-mapping>
+
+</web-app>
\ No newline at end of file
Property changes on: stack/native/trunk/modules/testsuite/native-tests/src/test/resources/jaxws/jbws2698/WEB-INF/web.xml
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
16 years, 4 months
JBossWS SVN: r10315 - in stack/native/trunk: modules/client and 13 other directories.
by jbossws-commits@lists.jboss.org
Author: alessio.soldano(a)jboss.com
Date: 2009-07-04 10:44:05 -0400 (Sat, 04 Jul 2009)
New Revision: 10315
Added:
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/client/Marshaller.java
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/client/NettyClient.java
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/client/UnMarshaller.java
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/client/WSClientPipelineFactory.java
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/client/WSResponseHandler.java
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/client/WSServerPipelineFactory.java
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/client/ssl/
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/client/ssl/JBossWSKeyManager.java
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/client/ssl/SSLContextFactory.java
Removed:
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/client/ssl/JBossWSKeyManager.java
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/client/ssl/SSLContextFactory.java
Modified:
stack/native/trunk/modules/client/pom.xml
stack/native/trunk/modules/core/pom.xml
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/CommonClient.java
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/client/FastInfosetConnectionHTTP.java
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/client/HTTPProtocolConnection.java
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/client/HTTPRemotingConnection.java
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/client/JsonConnectionHTTP.java
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/client/RemoteConnection.java
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/client/SOAPProtocolConnectionHTTP.java
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/client/SOAPProtocolConnectionJMS.java
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxws/binding/HTTPMessageMarshaller.java
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxws/binding/HTTPMessageUnMarshaller.java
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxws/binding/JsonMessageMarshaller.java
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxws/binding/JsonMessageUnMarshaller.java
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxws/client/ClientImpl.java
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/soap/EnvelopeBuilderDOM.java
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/soap/FastInfosetMarshaller.java
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/soap/SOAPConnectionImpl.java
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/soap/SOAPMessageMarshaller.java
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/soap/SOAPMessageUnMarshaller.java
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/soap/SOAPMessageUnMarshallerHTTP.java
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/utils/ThreadLocalAssociation.java
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/extensions/wsrm/transport/RMChannelTask.java
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/extensions/wsrm/transport/RMMarshaller.java
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/extensions/wsrm/transport/RMMessageAssembler.java
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/extensions/wsrm/transport/RMMetadata.java
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/extensions/wsrm/transport/RMSender.java
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/extensions/wsrm/transport/RMUnMarshaller.java
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/extensions/wsrm/transport/backchannel/RMBackPortsInvocationHandler.java
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/extensions/wsrm/transport/backchannel/RMBackPortsServer.java
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/extensions/wsrm/transport/backchannel/RMCallbackHandler.java
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/extensions/wsrm/transport/backchannel/RMCallbackHandlerImpl.java
stack/native/trunk/modules/resources/src/main/resources/bin/wsrunclient.bat
stack/native/trunk/modules/resources/src/main/resources/bin/wsrunclient.sh
stack/native/trunk/modules/resources/src/main/resources/bin/wstools.bat
stack/native/trunk/modules/resources/src/main/resources/bin/wstools.sh
stack/native/trunk/modules/resources/src/main/resources/resources/default-deploy.conf
stack/native/trunk/modules/resources/src/main/resources/resources/jbossws-deploy-macros.xml
stack/native/trunk/pom.xml
stack/native/trunk/src/main/scripts/assembly-deploy-artifacts.xml
Log:
[JBWS-2554] Removing dependency on Remoting 2 and using Netty (svn merge -r10240:HEAD https://svn.jboss.org/repos/jbossws/stack/native/branches/netty .)
Modified: stack/native/trunk/modules/client/pom.xml
===================================================================
--- stack/native/trunk/modules/client/pom.xml 2009-07-04 14:37:52 UTC (rev 10314)
+++ stack/native/trunk/modules/client/pom.xml 2009-07-04 14:44:05 UTC (rev 10315)
@@ -49,7 +49,7 @@
<configuration>
<archive>
<manifestEntries>
- <Class-Path>jbossws-spi.jar jbossws-common.jar jbossws-framework.jar jbossws-native-core.jar jbossws-native-jaxrpc.jar jbossws-native-jaxws.jar jbossws-native-jaxws-ext.jar jbossws-native-saaj.jar activation.jar commons-logging.jar concurrent.jar javassist.jar jaxb-api.jar jaxb-impl.jar mail.jar jboss-remoting.jar jboss-xml-binding.jar policy.jar stax-api.jar wsdl4j.jar</Class-Path>
+ <Class-Path>jbossws-spi.jar jbossws-common.jar jbossws-framework.jar jbossws-native-core.jar jbossws-native-jaxrpc.jar jbossws-native-jaxws.jar jbossws-native-jaxws-ext.jar jbossws-native-saaj.jar activation.jar commons-logging.jar concurrent.jar javassist.jar jaxb-api.jar jaxb-impl.jar mail.jar jboss-xml-binding.jar netty.jar policy.jar stax-api.jar wsdl4j.jar</Class-Path>
</manifestEntries>
</archive>
</configuration>
Modified: stack/native/trunk/modules/core/pom.xml
===================================================================
--- stack/native/trunk/modules/core/pom.xml 2009-07-04 14:37:52 UTC (rev 10314)
+++ stack/native/trunk/modules/core/pom.xml 2009-07-04 14:44:05 UTC (rev 10315)
@@ -145,8 +145,8 @@
<artifactId>jboss-jaxb-intros</artifactId>
</dependency>
<dependency>
- <groupId>org.jboss.remoting</groupId>
- <artifactId>jboss-remoting</artifactId>
+ <groupId>org.jboss.netty</groupId>
+ <artifactId>netty</artifactId>
</dependency>
<dependency>
<groupId>wscommons-policy</groupId>
Modified: stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/CommonClient.java
===================================================================
--- stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/CommonClient.java 2009-07-04 14:37:52 UTC (rev 10314)
+++ stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/CommonClient.java 2009-07-04 14:44:05 UTC (rev 10315)
@@ -333,11 +333,12 @@
Map<String, Object> callProps = new HashMap<String, Object>(getRequestContext());
EndpointInfo epInfo = new EndpointInfo(epMetaData, targetAddress, callProps);
- if (shouldMaintainSession())
+ boolean maintainSession = shouldMaintainSession();
+ if (maintainSession)
addSessionInfo(reqMessage, callProps);
RemoteConnection remoteConnection = new RemoteConnectionFactory().getRemoteConnection(epInfo);
- MessageAbstraction resMessage = remoteConnection.invoke(reqMessage, epInfo, oneway);
+ MessageAbstraction resMessage = remoteConnection.invoke(reqMessage, epInfo, oneway, maintainSession);
if (shouldMaintainSession())
saveSessionInfo(callProps, getRequestContext());
Modified: stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/client/FastInfosetConnectionHTTP.java
===================================================================
--- stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/client/FastInfosetConnectionHTTP.java 2009-07-04 14:37:52 UTC (rev 10314)
+++ stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/client/FastInfosetConnectionHTTP.java 2009-07-04 14:44:05 UTC (rev 10315)
@@ -25,8 +25,6 @@
import javax.xml.soap.MimeHeaders;
-import org.jboss.remoting.marshal.Marshaller;
-import org.jboss.remoting.marshal.UnMarshaller;
import org.jboss.ws.core.MessageAbstraction;
import org.jboss.ws.core.soap.FastInfosetMarshaller;
import org.jboss.ws.core.soap.FastInfosetUnMarshaller;
@@ -53,10 +51,12 @@
@Override
protected void populateHeaders(MessageAbstraction reqMessage, Map<String, Object> metadata)
{
- MimeHeaders mimeHeaders = reqMessage.getMimeHeaders();
- mimeHeaders.setHeader(MimeConstants.CONTENT_TYPE, MimeConstants.TYPE_FASTINFOSET);
- mimeHeaders.addHeader(MimeConstants.ACCEPT, MimeConstants.TYPE_FASTINFOSET);
-
+ if (reqMessage != null)
+ {
+ MimeHeaders mimeHeaders = reqMessage.getMimeHeaders();
+ mimeHeaders.setHeader(MimeConstants.CONTENT_TYPE, MimeConstants.TYPE_FASTINFOSET);
+ mimeHeaders.addHeader(MimeConstants.ACCEPT, MimeConstants.TYPE_FASTINFOSET);
+ }
super.populateHeaders(reqMessage, metadata);
}
}
Modified: stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/client/HTTPProtocolConnection.java
===================================================================
--- stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/client/HTTPProtocolConnection.java 2009-07-04 14:37:52 UTC (rev 10314)
+++ stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/client/HTTPProtocolConnection.java 2009-07-04 14:44:05 UTC (rev 10315)
@@ -21,8 +21,6 @@
*/
package org.jboss.ws.core.client;
-import org.jboss.remoting.marshal.Marshaller;
-import org.jboss.remoting.marshal.UnMarshaller;
import org.jboss.ws.core.jaxws.binding.HTTPMessageMarshaller;
import org.jboss.ws.core.jaxws.binding.HTTPMessageUnMarshaller;
Modified: stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/client/HTTPRemotingConnection.java
===================================================================
--- stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/client/HTTPRemotingConnection.java 2009-07-04 14:37:52 UTC (rev 10314)
+++ stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/client/HTTPRemotingConnection.java 2009-07-04 14:44:05 UTC (rev 10315)
@@ -22,42 +22,20 @@
package org.jboss.ws.core.client;
import java.io.IOException;
-import java.lang.reflect.Field;
-import java.net.MalformedURLException;
-import java.net.SocketTimeoutException;
-import java.net.URL;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
-import java.util.Properties;
-import javax.xml.rpc.Stub;
import javax.xml.soap.MimeHeader;
import javax.xml.soap.MimeHeaders;
-import javax.xml.ws.BindingProvider;
import javax.xml.ws.addressing.EndpointReference;
import org.jboss.logging.Logger;
-import org.jboss.remoting.Client;
-import org.jboss.remoting.InvokerLocator;
-import org.jboss.remoting.Version;
-import org.jboss.remoting.marshal.MarshalFactory;
-import org.jboss.remoting.marshal.Marshaller;
-import org.jboss.remoting.marshal.UnMarshaller;
-import org.jboss.remoting.transport.http.HTTPClientInvoker;
-import org.jboss.ws.core.CommonMessageContext;
import org.jboss.ws.core.MessageAbstraction;
import org.jboss.ws.core.MessageTrace;
-import org.jboss.ws.core.StubExt;
-import org.jboss.ws.core.WSTimeoutException;
-import org.jboss.ws.core.soap.MessageContextAssociation;
import org.jboss.ws.extensions.wsrm.transport.RMChannel;
import org.jboss.ws.extensions.wsrm.transport.RMMetadata;
import org.jboss.ws.extensions.wsrm.transport.RMTransportHelper;
-import org.jboss.ws.feature.FastInfosetFeature;
-import org.jboss.ws.metadata.config.CommonConfig;
-import org.jboss.ws.metadata.config.EndpointProperty;
-import org.jboss.ws.metadata.umdm.EndpointMetaData;
/**
* SOAPConnection implementation.
@@ -69,6 +47,7 @@
*
* @author Thomas.Diesler(a)jboss.org
* @author <a href="mailto:jason@stacksmash.com">Jason T. Greene</a>
+ * @author alessio.soldano(a)jboss.com
*
* @since 02-Feb-2005
*/
@@ -76,45 +55,15 @@
{
// provide logging
private static Logger log = Logger.getLogger(HTTPRemotingConnection.class);
-
- private Map<String, Object> clientConfig = new HashMap<String, Object>();
-
- private static Map<String, String> metadataMap = new HashMap<String, String>();
- static
- {
- metadataMap.put(Stub.USERNAME_PROPERTY, "http.basic.username");
- metadataMap.put(Stub.PASSWORD_PROPERTY, "http.basic.password");
- metadataMap.put(BindingProvider.USERNAME_PROPERTY, "http.basic.username");
- metadataMap.put(BindingProvider.PASSWORD_PROPERTY, "http.basic.password");
- }
- private static Map<String, String> configMap = new HashMap<String, String>();
- static
- {
- configMap.put(StubExt.PROPERTY_KEY_ALIAS, "org.jboss.remoting.keyAlias");
- configMap.put(StubExt.PROPERTY_KEY_STORE, "org.jboss.remoting.keyStore");
- configMap.put(StubExt.PROPERTY_KEY_STORE_ALGORITHM, "org.jboss.remoting.keyStoreAlgorithm");
- configMap.put(StubExt.PROPERTY_KEY_STORE_PASSWORD, "org.jboss.remoting.keyStorePassword");
- configMap.put(StubExt.PROPERTY_KEY_STORE_TYPE, "org.jboss.remoting.keyStoreType");
- configMap.put(StubExt.PROPERTY_SOCKET_FACTORY, "socketFactoryClassName");
- configMap.put(StubExt.PROPERTY_SSL_PROTOCOL, "org.jboss.remoting.sslProtocol");
- configMap.put(StubExt.PROPERTY_SSL_PROVIDER_NAME, "org.jboss.remoting.sslProviderName");
- configMap.put(StubExt.PROPERTY_TRUST_STORE, "org.jboss.remoting.trustStore");
- configMap.put(StubExt.PROPERTY_TRUST_STORE_ALGORITHM, "org.jboss.remoting.truststoreAlgorithm");
- configMap.put(StubExt.PROPERTY_TRUST_STORE_PASSWORD, "org.jboss.remoting.trustStorePassword");
- configMap.put(StubExt.PROPERTY_TRUST_STORE_TYPE, "org.jboss.remoting.trustStoreType");
- }
-
+
private boolean closed;
- private Integer chunkedLength;
+ private Integer chunkSize;
private static final RMChannel RM_CHANNEL = RMChannel.getInstance();
public HTTPRemotingConnection()
{
- // HTTPClientInvoker connect sends gratuitous POST
- // http://jira.jboss.com/jira/browse/JBWS-711
- clientConfig.put(Client.ENABLE_LEASE, false);
- clientConfig.put(HTTPClientInvoker.UNMARSHAL_NULL_STREAM, "true");
+
}
public boolean isClosed()
@@ -127,22 +76,27 @@
this.closed = closed;
}
- public Integer getChunkedLength()
+ public Integer getChunkSize()
{
- return chunkedLength;
+ return chunkSize;
}
- public void setChunkedLength(Integer chunkedLength)
+ public void setChunkSize(Integer chunkSize)
{
- this.chunkedLength = chunkedLength;
+ this.chunkSize = chunkSize;
}
+ public MessageAbstraction invoke(MessageAbstraction reqMessage, Object endpoint, boolean oneway) throws IOException
+ {
+ return this.invoke(reqMessage, endpoint, oneway, true);
+ }
+
/**
* Sends the given message to the specified endpoint.
*
* A null reqMessage signifies a HTTP GET request.
*/
- public MessageAbstraction invoke(MessageAbstraction reqMessage, Object endpoint, boolean oneway) throws IOException
+ public MessageAbstraction invoke(MessageAbstraction reqMessage, Object endpoint, boolean oneway, boolean maintainSession) throws IOException
{
if (endpoint == null)
throw new IllegalArgumentException("Given endpoint cannot be null");
@@ -150,7 +104,6 @@
if (closed)
throw new IOException("Connection is already closed");
- Object timeout = null;
String targetAddress;
Map<String, Object> callProps = new HashMap<String, Object>();
@@ -159,13 +112,6 @@
EndpointInfo epInfo = (EndpointInfo)endpoint;
targetAddress = epInfo.getTargetAddress();
callProps = epInfo.getProperties();
-
- if (callProps.containsKey(StubExt.PROPERTY_CLIENT_TIMEOUT))
- {
- timeout = callProps.get(StubExt.PROPERTY_CLIENT_TIMEOUT);
- targetAddress = addURLParameter(targetAddress, "timeout", timeout.toString());
- }
-
}
else if (endpoint instanceof EndpointReference)
{
@@ -177,254 +123,77 @@
targetAddress = endpoint.toString();
}
- // setup remoting client
- Map<String, Object> metadata = createRemotingMetaData(reqMessage, callProps);
- Marshaller marshaller = getMarshaller();
- UnMarshaller unmarshaller = getUnmarshaller();
- InvokerLocator locator = null;
- try
+ if (RMTransportHelper.isRMMessage(callProps))
{
- // Get the invoker from Remoting for a given endpoint address
- log.debug("Get locator for: " + endpoint);
-
- /**
- * [JBWS-1704] The Use Of Remoting Causes An Additional 'datatype' Parameter To Be Sent On All Requests
- *
- * An HTTPClientInvoker may disconnect from the server and recreated by the remoting layer.
- * In that case the new invoker does not inherit the marshaller/unmarshaller from the disconnected invoker.
- * We therefore explicitly specify the invoker locator datatype and register the SOAP marshaller/unmarshaller
- * with the MarshalFactory.
- *
- * This applies to remoting-1.4.5 and less
- */
- String version = getRemotingVersion();
- if (version.startsWith("1.4"))
+ try
{
- targetAddress = addURLParameter(targetAddress, InvokerLocator.DATATYPE, "JBossWSMessage");
- MarshalFactory.addMarshaller("JBossWSMessage", marshaller, unmarshaller);
- }
-
- locator = new InvokerLocator(targetAddress);
- }
- catch (MalformedURLException e)
- {
- throw new IllegalArgumentException("Malformed endpoint address", e);
- }
-
- try
- {
- if (RMTransportHelper.isRMMessage(callProps))
- {
- RMMetadata rmMetadata = new RMMetadata(getRemotingVersion(), targetAddress, marshaller, unmarshaller, callProps, metadata, clientConfig);
+ Map<String, Object> additionalHeaders = new HashMap<String, Object>();
+ populateHeaders(reqMessage, additionalHeaders);
+ RMMetadata rmMetadata = new RMMetadata(targetAddress, getMarshaller(), getUnmarshaller(), callProps, additionalHeaders);
return RM_CHANNEL.send(reqMessage, rmMetadata);
}
- else
+ catch (Throwable t)
{
- Client client = new Client(locator, "jbossws", clientConfig);
- client.connect();
-
- client.setMarshaller(marshaller);
-
- client.setUnMarshaller(unmarshaller);
-
- if (log.isDebugEnabled())
- log.debug("Remoting metadata: " + metadata);
-
- // debug the outgoing message
- MessageTrace.traceMessage("Outgoing Request Message", reqMessage);
-
- MessageAbstraction resMessage = null;
-
- if (oneway == true)
- {
- client.invokeOneway(reqMessage, metadata, false);
- }
- else
- {
- resMessage = (MessageAbstraction)client.invoke(reqMessage, metadata);
- }
-
- // Disconnect the remoting client
- client.disconnect();
-
- callProps.clear();
- callProps.putAll(metadata);
-
- // trace the incomming response message
- MessageTrace.traceMessage("Incoming Response Message", resMessage);
-
- return resMessage;
+ IOException io = new IOException();
+ io.initCause(t);
+ throw io;
}
}
- catch (Throwable th)
+ else
{
- if (timeout != null && (th.getCause() instanceof SocketTimeoutException))
+ NettyClient client = new NettyClient(getMarshaller(), getUnmarshaller());
+ if (chunkSize != null)
{
- throw new WSTimeoutException("Timeout after: " + timeout + "ms", new Long(timeout.toString()));
+ client.setChunkSize(chunkSize);
}
-
- IOException io = new IOException("Could not transmit message");
- io.initCause(th);
- throw io;
+
+ Map<String, Object> additionalHeaders = new HashMap<String, Object>();
+ populateHeaders(reqMessage, additionalHeaders);
+ //Trace the outgoing message
+ MessageTrace.traceMessage("Outgoing Request Message", reqMessage);
+ MessageAbstraction resMessage = (MessageAbstraction)client.invoke(reqMessage, targetAddress, !oneway || maintainSession, additionalHeaders, callProps);
+ //Trace the incoming response message
+ MessageTrace.traceMessage("Incoming Response Message", resMessage);
+ return resMessage;
}
}
+
+
- private String addURLParameter(String urlStr, String key, String value) throws MalformedURLException
+ protected void populateHeaders(MessageAbstraction reqMessage, Map<String, Object> metadata)
{
- URL url = new URL(urlStr);
- urlStr += (url.getQuery() == null ? "?" : "&") + key + "=" + value;
- return urlStr;
- }
-
- private String getRemotingVersion()
- {
- String version = null;
- try
- {
- // Access the constant dynamically, otherwise it will be the compile time value
- Field field = Version.class.getDeclaredField("VERSION");
- version = (String)field.get(null);
- }
- catch (Exception ex)
- {
- throw new RuntimeException("Cannot obtain remoting version", ex);
- }
-
- if (version == null)
- {
- URL codeURL = Version.class.getProtectionDomain().getCodeSource().getLocation();
- throw new RuntimeException("Cannot obtain remoting version from: " + codeURL);
- }
- return version;
- }
-
- private Map<String, Object> createRemotingMetaData(MessageAbstraction reqMessage, Map callProps)
- {
- CommonMessageContext msgContext = MessageContextAssociation.peekMessageContext();
-
- Map<String, Object> metadata = new HashMap<String, Object>();
-
- // We need to unmarshall faults (HTTP 500)
- // metadata.put(HTTPMetadataConstants.NO_THROW_ON_ERROR, "true"); // since 2.0.0.GA
- metadata.put("NoThrowOnError", "true");
-
if (reqMessage != null)
{
- populateHeaders(reqMessage, metadata);
+ MimeHeaders mimeHeaders = reqMessage.getMimeHeaders();
- // Enable chunked encoding. This is the default size.
- int chunkSizeValue = (chunkedLength != null ? chunkedLength : 1024);
-
- // Overwrite, through endpoint config
- if (msgContext != null)
+ Iterator i = mimeHeaders.getAllHeaders();
+ while (i.hasNext())
{
- EndpointMetaData epMetaData = msgContext.getEndpointMetaData();
- CommonConfig config = epMetaData.getConfig();
+ MimeHeader header = (MimeHeader)i.next();
+ Object currentValue = metadata.get(header.getName());
- String sizeValue = config.getProperty(EndpointProperty.CHUNKED_ENCODING_SIZE);
- if (sizeValue != null)
- chunkSizeValue = Integer.valueOf(sizeValue);
-
- if (epMetaData.isFeatureEnabled(FastInfosetFeature.class))
- chunkSizeValue = 0;
- }
-
- if (chunkSizeValue > 0)
- {
- clientConfig.put("chunkedLength", String.valueOf(chunkSizeValue));
- }
- else
- {
- clientConfig.remove("chunkedLength");
- }
- }
- else
- {
- metadata.put("TYPE", "GET");
- }
-
- if (callProps != null)
- {
- Iterator it = callProps.entrySet().iterator();
-
- // Get authentication type, default to BASIC authetication
- String authType = (String)callProps.get(StubExt.PROPERTY_AUTH_TYPE);
- if (authType == null)
- authType = StubExt.PROPERTY_AUTH_TYPE_BASIC;
-
- while (it.hasNext())
- {
- Map.Entry entry = (Map.Entry)it.next();
- String key = (String)entry.getKey();
- Object val = entry.getValue();
-
- // pass properties to remoting meta data
- if (metadataMap.containsKey(key))
+ /*
+ * Coalesce multiple headers into one
+ *
+ * From HTTP/1.1 RFC 2616:
+ *
+ * Multiple message-header fields with the same field-name MAY be
+ * present in a message if and only if the entire field-value for that
+ * header field is defined as a comma-separated list [i.e., #(values)].
+ * It MUST be possible to combine the multiple header fields into one
+ * "field-name: field-value" pair, without changing the semantics of
+ * the message, by appending each subsequent field-value to the first,
+ * each separated by a comma.
+ */
+ if (currentValue != null)
{
- String remotingKey = metadataMap.get(key);
- if ("http.basic.username".equals(remotingKey) || "http.basic.password".equals(remotingKey))
- {
- if (authType.equals(StubExt.PROPERTY_AUTH_TYPE_BASIC))
- {
- metadata.put(remotingKey, val);
- }
- else
- {
- log.warn("Ignore '" + key + "' with auth typy: " + authType);
- }
- }
- else
- {
- metadata.put(remotingKey, val);
- }
+ metadata.put(header.getName(), currentValue + "," + header.getValue());
}
-
- // pass properties to remoting client config
- if (configMap.containsKey(key))
+ else
{
- String remotingKey = configMap.get(key);
- clientConfig.put(remotingKey, val);
+ metadata.put(header.getName(), header.getValue());
}
}
}
-
- return metadata;
}
-
- protected void populateHeaders(MessageAbstraction reqMessage, Map<String, Object> metadata)
- {
- MimeHeaders mimeHeaders = reqMessage.getMimeHeaders();
-
- Properties props = new Properties();
- metadata.put("HEADER", props);
-
- Iterator i = mimeHeaders.getAllHeaders();
- while (i.hasNext())
- {
- MimeHeader header = (MimeHeader)i.next();
- String currentValue = props.getProperty(header.getName());
-
- /*
- * Coalesce multiple headers into one
- *
- * From HTTP/1.1 RFC 2616:
- *
- * Multiple message-header fields with the same field-name MAY be
- * present in a message if and only if the entire field-value for that
- * header field is defined as a comma-separated list [i.e., #(values)].
- * It MUST be possible to combine the multiple header fields into one
- * "field-name: field-value" pair, without changing the semantics of
- * the message, by appending each subsequent field-value to the first,
- * each separated by a comma.
- */
- if (currentValue != null)
- {
- props.put(header.getName(), currentValue + "," + header.getValue());
- }
- else
- {
- props.put(header.getName(), header.getValue());
- }
- }
- }
}
Modified: stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/client/JsonConnectionHTTP.java
===================================================================
--- stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/client/JsonConnectionHTTP.java 2009-07-04 14:37:52 UTC (rev 10314)
+++ stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/client/JsonConnectionHTTP.java 2009-07-04 14:44:05 UTC (rev 10315)
@@ -26,8 +26,6 @@
import javax.xml.soap.MimeHeaders;
import javax.xml.soap.SOAPConstants;
-import org.jboss.remoting.marshal.Marshaller;
-import org.jboss.remoting.marshal.UnMarshaller;
import org.jboss.ws.core.MessageAbstraction;
import org.jboss.ws.core.jaxws.binding.JsonMessageMarshaller;
import org.jboss.ws.core.jaxws.binding.JsonMessageUnMarshaller;
@@ -55,9 +53,11 @@
protected void populateHeaders(MessageAbstraction reqMessage, Map<String, Object> metadata)
{
// TODO: fix the content-type
- MimeHeaders mimeHeaders = reqMessage.getMimeHeaders();
- mimeHeaders.setHeader(MimeConstants.CONTENT_TYPE, SOAPConstants.SOAP_1_1_CONTENT_TYPE);
-
+ if (reqMessage != null)
+ {
+ MimeHeaders mimeHeaders = reqMessage.getMimeHeaders();
+ mimeHeaders.setHeader(MimeConstants.CONTENT_TYPE, SOAPConstants.SOAP_1_1_CONTENT_TYPE);
+ }
super.populateHeaders(reqMessage, metadata);
}
}
Copied: stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/client/Marshaller.java (from rev 10312, stack/native/branches/netty/modules/core/src/main/java/org/jboss/ws/core/client/Marshaller.java)
===================================================================
--- stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/client/Marshaller.java (rev 0)
+++ stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/client/Marshaller.java 2009-07-04 14:44:05 UTC (rev 10315)
@@ -0,0 +1,49 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.ws.core.client;
+
+import java.io.IOException;
+import java.io.OutputStream;
+
+/**
+ * Interface that all data marshallers must implements.
+ * Requires them to take Java data objects and convert
+ * primitive java data types (i.e. byte[]) and write
+ * to output provided.
+ *
+ * @author alessio.soldano(a)jboss.com
+ * @since 24-Jun-2009
+ *
+ */
+public interface Marshaller
+{
+ /**
+ * Marshaller will need to take the dataObject and convert
+ * into primitive java data types and write to the
+ * given output.
+ *
+ * @param dataObject Object to be writen to output
+ * @param output The data output to write the object
+ * data to.
+ */
+ public void write(Object dataObject, OutputStream output) throws IOException;
+}
Copied: stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/client/NettyClient.java (from rev 10312, stack/native/branches/netty/modules/core/src/main/java/org/jboss/ws/core/client/NettyClient.java)
===================================================================
--- stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/client/NettyClient.java (rev 0)
+++ stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/client/NettyClient.java 2009-07-04 14:44:05 UTC (rev 10315)
@@ -0,0 +1,457 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.ws.core.client;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.net.InetSocketAddress;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.Map;
+import java.util.concurrent.Executor;
+import java.util.concurrent.Executors;
+
+import javax.net.ssl.SSLEngine;
+import javax.xml.rpc.Stub;
+import javax.xml.ws.BindingProvider;
+
+import org.jboss.netty.bootstrap.ClientBootstrap;
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.jboss.netty.buffer.ChannelBufferOutputStream;
+import org.jboss.netty.buffer.ChannelBuffers;
+import org.jboss.netty.channel.Channel;
+import org.jboss.netty.channel.ChannelFactory;
+import org.jboss.netty.channel.ChannelFuture;
+import org.jboss.netty.channel.socket.nio.NioClientSocketChannelFactory;
+import org.jboss.netty.handler.codec.http.DefaultHttpChunk;
+import org.jboss.netty.handler.codec.http.DefaultHttpRequest;
+import org.jboss.netty.handler.codec.http.HttpChunk;
+import org.jboss.netty.handler.codec.http.HttpHeaders;
+import org.jboss.netty.handler.codec.http.HttpMessage;
+import org.jboss.netty.handler.codec.http.HttpMethod;
+import org.jboss.netty.handler.codec.http.HttpRequest;
+import org.jboss.netty.handler.codec.http.HttpVersion;
+import org.jboss.netty.handler.ssl.SslHandler;
+import org.jboss.security.Base64Encoder;
+import org.jboss.ws.core.CommonMessageContext;
+import org.jboss.ws.core.StubExt;
+import org.jboss.ws.core.WSTimeoutException;
+import org.jboss.ws.core.client.ssl.SSLContextFactory;
+import org.jboss.ws.core.soap.MessageContextAssociation;
+import org.jboss.ws.feature.FastInfosetFeature;
+import org.jboss.ws.metadata.config.CommonConfig;
+import org.jboss.ws.metadata.config.EndpointProperty;
+import org.jboss.ws.metadata.umdm.EndpointMetaData;
+
+/**
+ * A http client using Netty
+ *
+ * @author alessio.soldano(a)jboss.com
+ * @since 29-Jun-2009
+ *
+ */
+public class NettyClient
+{
+ public static final String RESPONSE_CODE = "ResponseCode";
+ public static final String RESPONSE_CODE_MESSAGE = "ResponseCodeMessage";
+
+ private Marshaller marshaller;
+ private UnMarshaller unmarshaller;
+ private Long timeout;
+ private static final int DEFAULT_CHUNK_SIZE = 1024;
+ //We always use chunked transfer encoding unless explicitely disabled by user
+ private Integer chunkSize = new Integer(DEFAULT_CHUNK_SIZE);
+ private Executor bossExecutor;
+ private Executor workerExecutor;
+
+ /**
+ * Construct a Netty client with the provided marshaller/unmarshaller.
+ *
+ * @param marshaller
+ * @param unmarshaller
+ */
+ public NettyClient(Marshaller marshaller, UnMarshaller unmarshaller)
+ {
+ this.marshaller = marshaller;
+ this.unmarshaller = unmarshaller;
+ this.bossExecutor = Executors.newCachedThreadPool();
+ this.workerExecutor = Executors.newCachedThreadPool();
+ }
+
+ /**
+ * Construct a Netty client with the provided marshaller/unmarshaller and executors.
+ *
+ * @param marshaller
+ * @param unmarshaller
+ * @param bossExecutor
+ * @param workerExecutor
+ */
+ public NettyClient(Marshaller marshaller, UnMarshaller unmarshaller, Executor bossExecutor, Executor workerExecutor)
+ {
+ this.marshaller = marshaller;
+ this.unmarshaller = unmarshaller;
+ this.bossExecutor = bossExecutor;
+ this.workerExecutor = workerExecutor;
+ }
+
+ /**
+ * Performs the invocation; a HTTP GET is performed when the reqMessage is null, otherwise a HTTP POST is performed.
+ *
+ * @param reqMessage The request message
+ * @param targetAddress The target address
+ * @param waitForResponse A boolean saying if the method should wait for the results before returning. Waiting is required for two-ways invocations
+ * and when maintaining sessions using cookies.
+ * @param additionalHeaders Additional http headers to be added to the request
+ * @param callProps
+ * @return
+ * @throws IOException
+ */
+ public Object invoke(Object reqMessage, String targetAddress, boolean waitForResponse, Map<String, Object> additionalHeaders, Map<String, Object> callProps)
+ throws IOException
+ {
+ URL target;
+ try
+ {
+ target = new URL(targetAddress);
+ }
+ catch (MalformedURLException e)
+ {
+ throw new RuntimeException("Invalid address: " + targetAddress, e);
+ }
+
+ ChannelFactory factory = new NioClientSocketChannelFactory(bossExecutor, workerExecutor);
+
+ ClientBootstrap bootstrap = new ClientBootstrap(factory);
+ WSClientPipelineFactory channelPipelineFactory = new WSClientPipelineFactory();
+ WSResponseHandler responseHandler = null;
+ if (waitForResponse)
+ {
+ responseHandler = new WSResponseHandler(unmarshaller);
+ channelPipelineFactory.setResponseHandler(responseHandler);
+ }
+ if ("https".equalsIgnoreCase(target.getProtocol()))
+ {
+ SSLContextFactory sslContextFactory = new SSLContextFactory(callProps);
+ SSLEngine engine = sslContextFactory.getSSLContext().createSSLEngine();
+ engine.setUseClientMode(true);
+ channelPipelineFactory.setSslHandler(new SslHandler(engine));
+ }
+
+ bootstrap.setPipelineFactory(channelPipelineFactory);
+
+ Channel channel = null;
+ try
+ {
+ setActualTimeout(callProps);
+ //Start the connection attempt
+ ChannelFuture future = bootstrap.connect(getSocketAddress(target));
+
+ //Wait until the connection attempt succeeds or fails
+ awaitUninterruptibly(future, timeout);
+ if (!future.isSuccess())
+ {
+ IOException io = new IOException("Could not connect to " + target.getHost());
+ io.initCause(future.getCause());
+ factory.releaseExternalResources();
+ throw io;
+ }
+ channel = future.getChannel();
+
+ //Send the HTTP request
+ HttpRequest request = new DefaultHttpRequest(HttpVersion.HTTP_1_1, reqMessage != null ? HttpMethod.POST : HttpMethod.GET, targetAddress);
+ request.addHeader(HttpHeaders.Names.HOST, target.getHost());
+ request.addHeader(HttpHeaders.Names.CONNECTION, HttpHeaders.Values.KEEP_ALIVE);
+ setAdditionalHeaders(request, additionalHeaders);
+ setActualChunkedLength(request);
+ setAuthorization(request, callProps);
+
+ writeRequest(channel, request, reqMessage);
+
+ if (!waitForResponse)
+ {
+ //No need to wait for the connection to be closed
+ return null;
+ }
+ //Wait for the server to close the connection
+ ChannelFuture closeFuture = channel.getCloseFuture();
+ awaitUninterruptibly(closeFuture, timeout);
+ if (responseHandler.getError() != null)
+ {
+ throw responseHandler.getError();
+ }
+ Object resMessage = null;
+ Map<String, Object> resHeaders = null;
+ //Get the response
+ resMessage = responseHandler.getResponseMessage();
+ resHeaders = responseHandler.getResponseHeaders();
+ //Update props with response headers (required to maintain session using cookies)
+ callProps.clear();
+ if (resHeaders != null)
+ {
+ callProps.putAll(resHeaders);
+ }
+
+ return resMessage;
+ }
+ catch (IOException ioe)
+ {
+ throw ioe;
+ }
+ catch (WSTimeoutException toe)
+ {
+ throw toe;
+ }
+ catch (Throwable t)
+ {
+ IOException io = new IOException("Could not transmit message");
+ io.initCause(t);
+ throw io;
+ }
+ finally
+ {
+ if (channel != null)
+ {
+ channel.close();
+ }
+ //Shut down executor threads to exit
+ factory.releaseExternalResources();
+ }
+ }
+
+ private InetSocketAddress getSocketAddress(URL target)
+ {
+ int port = target.getPort();
+ if (port < 0)
+ {
+ //use default port
+ String protocol = target.getProtocol();
+ if ("http".equalsIgnoreCase(protocol))
+ {
+ port = 80;
+ }
+ else if ("https".equalsIgnoreCase(protocol))
+ {
+ port = 443;
+ }
+ }
+ return new InetSocketAddress(target.getHost(), port);
+ }
+
+ private void writeRequest(Channel channel, HttpRequest request, Object reqMessage) throws IOException
+ {
+ if (reqMessage == null)
+ {
+ channel.write(request);
+ }
+ else
+ {
+ ChannelBuffer content = ChannelBuffers.dynamicBuffer();
+ OutputStream os = new ChannelBufferOutputStream(content);
+ marshaller.write(reqMessage, os);
+
+ int cs = chunkSize;
+ if (cs > 0) //chunked encoding
+ {
+ os.flush();
+ request.addHeader(HttpHeaders.Names.TRANSFER_ENCODING, HttpHeaders.Values.CHUNKED);
+ //write headers
+ channel.write(request);
+ //write content chunks
+ int size = content.readableBytes();
+ int cur = 0;
+ while (cur < size)
+ {
+ int to = Math.min(cur + cs, size);
+ HttpChunk chunk = new DefaultHttpChunk(content.slice(cur, to - cur));
+ channel.write(chunk);
+ cur = to;
+ }
+ //write last chunk
+ channel.write(HttpChunk.LAST_CHUNK);
+ }
+ else
+ {
+ request.setHeader(HttpHeaders.Names.CONTENT_LENGTH, String.valueOf(content.readableBytes()));
+ request.setContent(content);
+ channel.write(request);
+ }
+ }
+ }
+
+ /**
+ * Utility method for awaiting with or without timeout (timeout == null or <=0 implies not timeout)
+ *
+ * @param future
+ * @param timeout
+ * @throws WSTimeoutException
+ */
+ private static void awaitUninterruptibly(ChannelFuture future, Long timeout) throws WSTimeoutException
+ {
+ if (timeout != null && timeout.longValue() > 0)
+ {
+ boolean bool = future.awaitUninterruptibly(timeout);
+ if (!bool)
+ {
+ throw new WSTimeoutException("Timeout after: " + timeout + "ms", timeout);
+ }
+ }
+ else
+ {
+ future.awaitUninterruptibly();
+ }
+ }
+
+ /**
+ * Set the actual chunk size according to the endpoint config overwrite and/or configured features.
+ *
+ * @param message
+ */
+ protected void setActualChunkedLength(HttpRequest message)
+ {
+ if (HttpMethod.POST.equals(message.getMethod()))
+ {
+ CommonMessageContext msgContext = MessageContextAssociation.peekMessageContext();
+ //Overwrite, through endpoint config
+ if (msgContext != null)
+ {
+ EndpointMetaData epMetaData = msgContext.getEndpointMetaData();
+ CommonConfig config = epMetaData.getConfig();
+
+ String sizeValue = config.getProperty(EndpointProperty.CHUNKED_ENCODING_SIZE);
+ if (sizeValue != null)
+ chunkSize = Integer.valueOf(sizeValue);
+ if (epMetaData.isFeatureEnabled(FastInfosetFeature.class))
+ chunkSize = 0;
+ }
+ }
+ }
+
+ /**
+ * Set the actual timeout according to specified caller properties
+ *
+ * @param callProps
+ */
+ protected void setActualTimeout(Map<String, Object> callProps)
+ {
+ if (callProps.containsKey(StubExt.PROPERTY_CLIENT_TIMEOUT))
+ {
+ timeout = new Long(callProps.get(StubExt.PROPERTY_CLIENT_TIMEOUT).toString());
+ }
+ }
+
+ /**
+ * Set the required headers in the Netty's HttpMessage to allow for proper authorization.
+ *
+ * @param message
+ * @param callProps
+ * @throws IOException
+ */
+ protected void setAuthorization(HttpMessage message, Map<String, Object> callProps) throws IOException
+ {
+ //Get authentication type, default to BASIC authetication
+ String authType = (String)callProps.get(StubExt.PROPERTY_AUTH_TYPE);
+ if (authType == null)
+ authType = StubExt.PROPERTY_AUTH_TYPE_BASIC;
+ String username = (String)callProps.get(Stub.USERNAME_PROPERTY);
+ String password = (String)callProps.get(Stub.PASSWORD_PROPERTY);
+ if (username == null || password == null)
+ {
+ username = (String)callProps.get(BindingProvider.USERNAME_PROPERTY);
+ password = (String)callProps.get(BindingProvider.PASSWORD_PROPERTY);
+ }
+ if (username != null && password != null)
+ {
+ if (authType.equals(StubExt.PROPERTY_AUTH_TYPE_BASIC))
+ {
+ message.addHeader(HttpHeaders.Names.AUTHORIZATION, getBasicAuthHeader(username, password));
+ }
+ }
+ }
+
+ private static String getBasicAuthHeader(String username, String password) throws IOException
+ {
+ return "Basic " + Base64Encoder.encode(username + ":" + password);
+ }
+
+ /**
+ * Copy the provided additional headers to the Netty's HttpMessage.
+ *
+ * @param message
+ * @param headers
+ */
+ protected void setAdditionalHeaders(HttpMessage message, Map<String, Object> headers)
+ {
+ for (String key : headers.keySet())
+ {
+ try
+ {
+ String header = (String)headers.get(key);
+ message.addHeader(key, header.replaceAll("[\r\n\f]", " "));
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ throw new RuntimeException(e);
+ }
+ }
+ }
+
+ /**
+ * Set the Netty boss executor
+ *
+ * @param bossExecutor
+ */
+ public void setBossExecutor(Executor bossExecutor)
+ {
+ this.bossExecutor = bossExecutor;
+ }
+
+ /**
+ * Set the Netty worker executor
+ *
+ * @param workerExecutor
+ */
+ public void setWorkerExecutor(Executor workerExecutor)
+ {
+ this.workerExecutor = workerExecutor;
+ }
+
+ /**
+ *
+ * @return The current chunk size
+ */
+ public Integer getChunkSize()
+ {
+ return chunkSize;
+ }
+
+ /**
+ * Set the chunk size for chunked transfer encoding.
+ * The default chunk size is 1024 bytes.
+ *
+ * @param chunkSize
+ */
+ public void setChunkSize(Integer chunkSize)
+ {
+ this.chunkSize = chunkSize;
+ }
+}
Modified: stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/client/RemoteConnection.java
===================================================================
--- stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/client/RemoteConnection.java 2009-07-04 14:37:52 UTC (rev 10314)
+++ stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/client/RemoteConnection.java 2009-07-04 14:44:05 UTC (rev 10315)
@@ -23,8 +23,6 @@
import java.io.IOException;
-import org.jboss.remoting.marshal.Marshaller;
-import org.jboss.remoting.marshal.UnMarshaller;
import org.jboss.ws.core.MessageAbstraction;
@@ -39,6 +37,8 @@
Marshaller getMarshaller();
UnMarshaller getUnmarshaller();
+
+ MessageAbstraction invoke(MessageAbstraction reqMessage, Object endpoint, boolean oneway) throws IOException;
- MessageAbstraction invoke(MessageAbstraction reqMessage, Object endpoint, boolean oneway) throws IOException;
+ MessageAbstraction invoke(MessageAbstraction reqMessage, Object endpoint, boolean oneway, boolean maintainSession) throws IOException;
}
Modified: stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/client/SOAPProtocolConnectionHTTP.java
===================================================================
--- stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/client/SOAPProtocolConnectionHTTP.java 2009-07-04 14:37:52 UTC (rev 10314)
+++ stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/client/SOAPProtocolConnectionHTTP.java 2009-07-04 14:44:05 UTC (rev 10315)
@@ -23,14 +23,11 @@
import java.io.IOException;
import java.util.Map;
-import java.util.Properties;
import javax.xml.soap.MimeHeaders;
import javax.xml.soap.SOAPException;
import javax.xml.soap.SOAPMessage;
-import org.jboss.remoting.marshal.Marshaller;
-import org.jboss.remoting.marshal.UnMarshaller;
import org.jboss.ws.core.MessageAbstraction;
import org.jboss.ws.core.soap.SOAPMessageMarshaller;
import org.jboss.ws.core.soap.SOAPMessageUnMarshallerHTTP;
@@ -55,7 +52,8 @@
return new SOAPMessageMarshaller();
}
- public MessageAbstraction invoke(MessageAbstraction reqMessage, Object endpoint, boolean oneway) throws IOException
+ @Override
+ public MessageAbstraction invoke(MessageAbstraction reqMessage, Object endpoint, boolean oneway, boolean maintainSession) throws IOException
{
try
{
@@ -68,7 +66,7 @@
if (reqMessage != null && soapMessage.saveRequired())
soapMessage.saveChanges();
- return super.invoke(reqMessage, endpoint, oneway);
+ return super.invoke(reqMessage, endpoint, oneway, maintainSession);
}
catch (SOAPException ex)
{
@@ -82,33 +80,33 @@
{
super.populateHeaders(reqMessage, metadata);
- Properties props = (Properties)metadata.get("HEADER");
+ if (reqMessage != null)
+ {
+ // R2744 A HTTP request MESSAGE MUST contain a SOAPAction HTTP header field
+ // with a quoted value equal to the value of the soapAction attribute of
+ // soapbind:operation, if present in the corresponding WSDL description.
- // R2744 A HTTP request MESSAGE MUST contain a SOAPAction HTTP header field
- // with a quoted value equal to the value of the soapAction attribute of
- // soapbind:operation, if present in the corresponding WSDL description.
+ // R2745 A HTTP request MESSAGE MUST contain a SOAPAction HTTP header field
+ // with a quoted empty string value, if in the corresponding WSDL description,
+ // the soapAction attribute of soapbind:operation is either not present, or
+ // present with an empty string as its value.
- // R2745 A HTTP request MESSAGE MUST contain a SOAPAction HTTP header field
- // with a quoted empty string value, if in the corresponding WSDL description,
- // the soapAction attribute of soapbind:operation is either not present, or
- // present with an empty string as its value.
+ MimeHeaders mimeHeaders = reqMessage.getMimeHeaders();
+ String[] action = mimeHeaders.getHeader("SOAPAction");
+ if (action != null && action.length > 0)
+ {
+ String soapAction = action[0];
- MimeHeaders mimeHeaders = reqMessage.getMimeHeaders();
- String[] action = mimeHeaders.getHeader("SOAPAction");
- if (action != null && action.length > 0)
- {
- String soapAction = action[0];
+ // R1109 The value of the SOAPAction HTTP header field in a HTTP request MESSAGE MUST be a quoted string.
+ if (soapAction.startsWith("\"") == false || soapAction.endsWith("\"") == false)
+ soapAction = "\"" + soapAction + "\"";
- // R1109 The value of the SOAPAction HTTP header field in a HTTP request MESSAGE MUST be a quoted string.
- if (soapAction.startsWith("\"") == false || soapAction.endsWith("\"") == false)
- soapAction = "\"" + soapAction + "\"";
-
- props.put("SOAPAction", soapAction);
+ metadata.put("SOAPAction", soapAction);
+ }
+ else
+ {
+ metadata.put("SOAPAction", "\"\"");
+ }
}
- else
- {
- props.put("SOAPAction", "\"\"");
- }
-
}
}
Modified: stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/client/SOAPProtocolConnectionJMS.java
===================================================================
--- stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/client/SOAPProtocolConnectionJMS.java 2009-07-04 14:37:52 UTC (rev 10314)
+++ stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/client/SOAPProtocolConnectionJMS.java 2009-07-04 14:44:05 UTC (rev 10315)
@@ -41,8 +41,6 @@
import javax.naming.InitialContext;
import javax.xml.ws.addressing.EndpointReference;
-import org.jboss.remoting.marshal.Marshaller;
-import org.jboss.remoting.marshal.UnMarshaller;
import org.jboss.ws.core.MessageAbstraction;
import org.jboss.ws.core.soap.SOAPMessageMarshaller;
import org.jboss.ws.core.soap.SOAPMessageUnMarshaller;
@@ -66,9 +64,14 @@
{
return new SOAPMessageMarshaller();
}
-
+
public MessageAbstraction invoke(MessageAbstraction reqMessage, Object endpoint, boolean oneway) throws IOException
{
+ return this.invoke(reqMessage, endpoint, oneway, true);
+ }
+
+ public MessageAbstraction invoke(MessageAbstraction reqMessage, Object endpoint, boolean oneway, boolean maintainSession) throws IOException
+ {
if (endpoint == null)
throw new IllegalArgumentException("Given endpoint cannot be null");
Copied: stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/client/UnMarshaller.java (from rev 10312, stack/native/branches/netty/modules/core/src/main/java/org/jboss/ws/core/client/UnMarshaller.java)
===================================================================
--- stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/client/UnMarshaller.java (rev 0)
+++ stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/client/UnMarshaller.java 2009-07-04 14:44:05 UTC (rev 10315)
@@ -0,0 +1,48 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.ws.core.client;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Map;
+
+/**
+ * Takes a marshalled byte array and converts to a Java data object.
+ *
+ * @author alessio.soldano(a)jboss.com
+ * @since 24-Jun-2009
+ *
+ */
+public interface UnMarshaller
+{
+ /**
+ * Will read from the inputstream and convert contents to java Object.
+ *
+ * @param inputStream stream to read data from to do conversion.
+ * @param metadata can be any transport specific metadata (such as headers from http transport).
+ * This can be null, depending on if transport supports metadata.
+ *
+ * @return
+ * @throws IOException all specific i/o exceptions need to be thrown as this.
+ */
+ Object read(InputStream inputStream, Map<String, Object> metadata) throws IOException;
+}
Copied: stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/client/WSClientPipelineFactory.java (from rev 10312, stack/native/branches/netty/modules/core/src/main/java/org/jboss/ws/core/client/WSClientPipelineFactory.java)
===================================================================
--- stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/client/WSClientPipelineFactory.java (rev 0)
+++ stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/client/WSClientPipelineFactory.java 2009-07-04 14:44:05 UTC (rev 10315)
@@ -0,0 +1,86 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.ws.core.client;
+
+import static org.jboss.netty.channel.Channels.pipeline;
+
+import org.jboss.netty.channel.ChannelHandler;
+import org.jboss.netty.channel.ChannelPipeline;
+import org.jboss.netty.channel.ChannelPipelineFactory;
+import org.jboss.netty.handler.codec.http.HttpChunkAggregator;
+import org.jboss.netty.handler.codec.http.HttpRequestEncoder;
+import org.jboss.netty.handler.codec.http.HttpResponseDecoder;
+
+/**
+ *
+ * @author alessio.soldano(a)jboss.com
+ * @since 24-Jun-2009
+ *
+ */
+public class WSClientPipelineFactory implements ChannelPipelineFactory
+{
+ private static final int MAX_CONTENT_SIZE = 1073741824;
+ private ChannelHandler responseHandler;
+ private ChannelHandler sslHandler;
+
+ public ChannelPipeline getPipeline() throws Exception
+ {
+ // Create a default pipeline implementation.
+ ChannelPipeline pipeline = pipeline();
+
+ if (sslHandler != null)
+ {
+ pipeline.addLast("ssl", sslHandler);
+ }
+ pipeline.addLast("decoder", new HttpResponseDecoder());
+ // Uncomment the following line if you don't want to handle HttpChunks.
+ pipeline.addLast("aggregator", new HttpChunkAggregator(MAX_CONTENT_SIZE));
+ pipeline.addLast("encoder", new HttpRequestEncoder());
+ if (responseHandler != null)
+ {
+ pipeline.addLast("handler", responseHandler);
+ }
+ return pipeline;
+ }
+
+ public ChannelHandler getResponseHandler()
+ {
+ return responseHandler;
+ }
+
+ public void setResponseHandler(ChannelHandler responseHandler)
+ {
+ this.responseHandler = responseHandler;
+ }
+
+ public ChannelHandler getSslHandler()
+ {
+ return sslHandler;
+ }
+
+ public void setSslHandler(ChannelHandler sslHandler)
+ {
+ this.sslHandler = sslHandler;
+ }
+
+
+}
Copied: stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/client/WSResponseHandler.java (from rev 10312, stack/native/branches/netty/modules/core/src/main/java/org/jboss/ws/core/client/WSResponseHandler.java)
===================================================================
--- stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/client/WSResponseHandler.java (rev 0)
+++ stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/client/WSResponseHandler.java 2009-07-04 14:44:05 UTC (rev 10315)
@@ -0,0 +1,106 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.ws.core.client;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.jboss.netty.buffer.ChannelBufferInputStream;
+import org.jboss.netty.channel.ChannelHandlerContext;
+import org.jboss.netty.channel.ChannelPipelineCoverage;
+import org.jboss.netty.channel.MessageEvent;
+import org.jboss.netty.channel.SimpleChannelUpstreamHandler;
+import org.jboss.netty.handler.codec.http.HttpResponse;
+
+/**
+ * A Netty channel upstream handler that receives MessageEvent
+ * and extract the JBossWS message using the provided unmarshaller.
+ *
+ * @author alessio.soldano(a)jboss.com
+ * @since 24-Jun-2009
+ *
+ */
+@ChannelPipelineCoverage("one")
+public class WSResponseHandler extends SimpleChannelUpstreamHandler
+{
+ private UnMarshaller unmarshaller;
+ private Object responseMessage;
+ private Map<String, Object> responseHeaders;
+ private Throwable error;
+
+ public WSResponseHandler(UnMarshaller unmarshaller)
+ {
+ super();
+ this.unmarshaller = unmarshaller;
+ }
+
+ @Override
+ public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) throws Exception
+ {
+ try
+ {
+ reset();
+ HttpResponse response = (HttpResponse)e.getMessage();
+
+ responseHeaders.put(NettyClient.RESPONSE_CODE, response.getStatus().getCode());
+ responseHeaders.put(NettyClient.RESPONSE_CODE_MESSAGE, response.getStatus().getReasonPhrase());
+ for (String headerName : response.getHeaderNames())
+ {
+ responseHeaders.put(headerName, response.getHeaders(headerName));
+ }
+
+ ChannelBuffer content = response.getContent();
+ this.responseMessage = unmarshaller.read(content.readable() ? new ChannelBufferInputStream(content) : null, responseHeaders);
+ }
+ catch (Throwable t)
+ {
+ this.error = t;
+ }
+ finally
+ {
+ e.getChannel().close();
+ }
+ }
+
+ private void reset()
+ {
+ this.error = null;
+ this.responseMessage = null;
+ this.responseHeaders = new HashMap<String, Object>();
+ }
+
+ public Object getResponseMessage()
+ {
+ return this.responseMessage;
+ }
+
+ public Map<String, Object> getResponseHeaders()
+ {
+ return responseHeaders;
+ }
+
+ public Throwable getError()
+ {
+ return error;
+ }
+}
\ No newline at end of file
Copied: stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/client/WSServerPipelineFactory.java (from rev 10312, stack/native/branches/netty/modules/core/src/main/java/org/jboss/ws/core/client/WSServerPipelineFactory.java)
===================================================================
--- stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/client/WSServerPipelineFactory.java (rev 0)
+++ stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/client/WSServerPipelineFactory.java 2009-07-04 14:44:05 UTC (rev 10315)
@@ -0,0 +1,82 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.ws.core.client;
+
+import static org.jboss.netty.channel.Channels.pipeline;
+
+import org.jboss.netty.channel.ChannelHandler;
+import org.jboss.netty.channel.ChannelPipeline;
+import org.jboss.netty.channel.ChannelPipelineFactory;
+import org.jboss.netty.handler.codec.http.HttpChunkAggregator;
+import org.jboss.netty.handler.codec.http.HttpRequestDecoder;
+import org.jboss.netty.handler.codec.http.HttpResponseEncoder;
+
+/**
+ *
+ * @author alessio.soldano(a)jboss.com
+ * @since 01-Jul-2009
+ *
+ */
+public class WSServerPipelineFactory implements ChannelPipelineFactory
+{
+ private static final int MAX_CONTENT_SIZE = 1073741824;
+ private ChannelHandler requestHandler;
+ private ChannelHandler sshHandler;
+
+ public ChannelPipeline getPipeline() throws Exception
+ {
+ // Create a default pipeline implementation.
+ ChannelPipeline pipeline = pipeline();
+ // Uncomment the following line if you want HTTPS
+ //SSLEngine engine = SecureChatSslContextFactory.getServerContext().createSSLEngine();
+ //engine.setUseClientMode(false);
+ //pipeline.addLast("ssl", new SslHandler(engine));
+
+ pipeline.addLast("decoder", new HttpRequestDecoder());
+ // Uncomment the following line if you don't want to handle HttpChunks.
+ pipeline.addLast("aggregator", new HttpChunkAggregator(MAX_CONTENT_SIZE));
+ pipeline.addLast("encoder", new HttpResponseEncoder());
+ pipeline.addLast("handler", requestHandler);
+ return pipeline;
+ }
+
+ public ChannelHandler getRequestHandler()
+ {
+ return requestHandler;
+ }
+
+ public void setRequestHandler(ChannelHandler requestHandler)
+ {
+ this.requestHandler = requestHandler;
+ }
+
+ public ChannelHandler getSshHandler()
+ {
+ return sshHandler;
+ }
+
+ public void setSshHandler(ChannelHandler sshHandler)
+ {
+ this.sshHandler = sshHandler;
+ }
+
+}
Copied: stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/client/ssl (from rev 10312, stack/native/branches/netty/modules/core/src/main/java/org/jboss/ws/core/client/ssl)
Deleted: stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/client/ssl/JBossWSKeyManager.java
===================================================================
--- stack/native/branches/netty/modules/core/src/main/java/org/jboss/ws/core/client/ssl/JBossWSKeyManager.java 2009-07-04 08:05:00 UTC (rev 10312)
+++ stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/client/ssl/JBossWSKeyManager.java 2009-07-04 14:44:05 UTC (rev 10315)
@@ -1,78 +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.ws.core.client.ssl;
-
-import java.net.Socket;
-import java.security.Principal;
-import java.security.PrivateKey;
-import java.security.cert.X509Certificate;
-
-import javax.net.ssl.X509KeyManager;
-
-/**
- *
- * @author alessio.soldano(a)jboss.com
- * @since 03-July-2009
- *
- */
-public class JBossWSKeyManager implements X509KeyManager
-{
- private X509KeyManager targetManager = null;
- private String alias = null;
-
- public JBossWSKeyManager(X509KeyManager x509KeyManager, String alias)
- {
- this.targetManager = x509KeyManager;
- this.alias = alias;
- }
-
- public PrivateKey getPrivateKey(String string)
- {
- return targetManager.getPrivateKey(string);
- }
-
- public X509Certificate[] getCertificateChain(String string)
- {
- return targetManager.getCertificateChain(string);
- }
-
- public String[] getClientAliases(String string, Principal[] principals)
- {
- return targetManager.getClientAliases(string, principals);
- }
-
- public String[] getServerAliases(String string, Principal[] principals)
- {
- return targetManager.getServerAliases(string, principals);
- }
-
- public String chooseServerAlias(String string, Principal[] principals, Socket socket)
- {
- return targetManager.chooseServerAlias(string, principals, socket);
- }
-
- public String chooseClientAlias(String[] strings, Principal[] principals, Socket socket)
- {
- // just returning supplied alias instead of searching
- return alias;
- }
-}
Copied: stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/client/ssl/JBossWSKeyManager.java (from rev 10312, stack/native/branches/netty/modules/core/src/main/java/org/jboss/ws/core/client/ssl/JBossWSKeyManager.java)
===================================================================
--- stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/client/ssl/JBossWSKeyManager.java (rev 0)
+++ stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/client/ssl/JBossWSKeyManager.java 2009-07-04 14:44:05 UTC (rev 10315)
@@ -0,0 +1,78 @@
+/*
+* 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.ws.core.client.ssl;
+
+import java.net.Socket;
+import java.security.Principal;
+import java.security.PrivateKey;
+import java.security.cert.X509Certificate;
+
+import javax.net.ssl.X509KeyManager;
+
+/**
+ *
+ * @author alessio.soldano(a)jboss.com
+ * @since 03-July-2009
+ *
+ */
+public class JBossWSKeyManager implements X509KeyManager
+{
+ private X509KeyManager targetManager = null;
+ private String alias = null;
+
+ public JBossWSKeyManager(X509KeyManager x509KeyManager, String alias)
+ {
+ this.targetManager = x509KeyManager;
+ this.alias = alias;
+ }
+
+ public PrivateKey getPrivateKey(String string)
+ {
+ return targetManager.getPrivateKey(string);
+ }
+
+ public X509Certificate[] getCertificateChain(String string)
+ {
+ return targetManager.getCertificateChain(string);
+ }
+
+ public String[] getClientAliases(String string, Principal[] principals)
+ {
+ return targetManager.getClientAliases(string, principals);
+ }
+
+ public String[] getServerAliases(String string, Principal[] principals)
+ {
+ return targetManager.getServerAliases(string, principals);
+ }
+
+ public String chooseServerAlias(String string, Principal[] principals, Socket socket)
+ {
+ return targetManager.chooseServerAlias(string, principals, socket);
+ }
+
+ public String chooseClientAlias(String[] strings, Principal[] principals, Socket socket)
+ {
+ // just returning supplied alias instead of searching
+ return alias;
+ }
+}
Deleted: stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/client/ssl/SSLContextFactory.java
===================================================================
--- stack/native/branches/netty/modules/core/src/main/java/org/jboss/ws/core/client/ssl/SSLContextFactory.java 2009-07-04 08:05:00 UTC (rev 10312)
+++ stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/client/ssl/SSLContextFactory.java 2009-07-04 14:44:05 UTC (rev 10315)
@@ -1,1303 +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.ws.core.client.ssl;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.security.KeyStore;
-import java.security.KeyStoreException;
-import java.security.NoSuchAlgorithmException;
-import java.security.NoSuchProviderException;
-import java.security.Provider;
-import java.security.SecureRandom;
-import java.security.UnrecoverableKeyException;
-import java.security.cert.CertificateException;
-import java.security.cert.X509Certificate;
-import java.util.Map;
-
-import javax.net.ssl.KeyManager;
-import javax.net.ssl.KeyManagerFactory;
-import javax.net.ssl.SSLContext;
-import javax.net.ssl.TrustManager;
-import javax.net.ssl.TrustManagerFactory;
-import javax.net.ssl.X509KeyManager;
-import javax.net.ssl.X509TrustManager;
-
-import org.jboss.logging.Logger;
-import org.jboss.ws.core.StubExt;
-
-/**
- * This builds SSLContext instances. It's a modified version of org.jboss.remoting.security.SSLSocketBuilder
- *
- * @author <a href="mailto:mazz@jboss.com">John Mazzitelli</a>
- * @author <a href="mailto:telrod@jboss.com">Tom Elrod</a>
- * @author <a href="mailto:alessio.soldano@jboss.com">Alessio Soldano</a>
- *
- */
-public class SSLContextFactory
-{
- /**
- * If the protocol isn't specified, this will be the default.
- * Value is "TLS".
- */
- public static final String DEFAULT_SSL_PROTOCOL = "TLS";
-
- /**
- * Constant defining the config property used to define if the sockets will be in
- * client or server mode.
- */
- public static final String SSL_USE_CLIENT_MODE = "org.jboss.ws.sslUseClientMode";
-
- /**
- * Constant defining the config property used to define if the server sockets will be in
- * client or server mode.
- */
- public static final String SERVER_SSL_USE_CLIENT_MODE = "org.jboss.ws.serverSslUseClientMode";
-
- /**
- * Constant defining the config property used to define if a client should attempt to
- * authenticate a server certificate as one it trusts. The value of such a property is
- * a boolean.
- */
- public static final String SSL_SERVER_AUTH_MODE = "org.jboss.ws.sslServerAuthMode";
-
- /**
- * Constant defining the config property that indicates the key password for the keys in the key store.
- */
- public static final String KEY_PASSWORD = "org.jboss.ws.keyPassword";
-
- /**
- * Constant that defines the standard system property that the javax.net.ssl
- * classes look for when locating the keystore file.
- */
- public static final String STANDARD_KEY_STORE_FILE_PATH = "javax.net.ssl.keyStore";
-
- /**
- * Constant that defines the standard system property that the javax.net.ssl
- * classes look for when needing to know what type the keystore file is.
- */
- public static final String STANDARD_KEY_STORE_TYPE = "javax.net.ssl.keyStoreType";
-
- /**
- * Constant that defines the standard system property that the javax.net.ssl
- * classes look for when needing the keystore password.
- */
- public static final String STANDARD_KEY_STORE_PASSWORD = "javax.net.ssl.keyStorePassword";
-
- /**
- * Default key/trust store type if one not set as bean property, via config, or via system property.
- * Value is 'JKS'.
- */
- public static final String DEFAULT_KEY_STORE_TYPE = "JKS";
-
- /**
- * Default key/trust store algorithm if one net set as bean property or via config.
- * Value is 'SunX509'.
- */
- public static final String DEFAULT_KEY_STORE_ALGORITHM = "SunX509";
-
- /**
- * Constant that defines the standard system property that the javax.net.ssl
- * classes look for when locating the truststore file.
- */
- public static final String STANDARD_TRUST_STORE_FILE_PATH = "javax.net.ssl.trustStore";
-
- /**
- * Constant that defines the standard system property that the javax.net.ssl
- * classes look for when needing to know what type the truststore file is.
- */
- public static final String STANDARD_TRUST_STORE_TYPE = "javax.net.ssl.trustStoreType";
-
- /**
- * Constant that defines the standard system property that the javax.net.ssl
- * classes look for when needing the truststore password.
- */
- public static final String STANDARD_TRUST_STORE_PASSWORD = "javax.net.ssl.trustStorePassword";
-
- private SSLContext sslContextServerSocketFactory = null; // context that builds the server socket factories
- private SSLContext sslContextSocketFactory = null; // context that builds the socket factories
- private Provider provider = null;
- private String providerName = null;
- private String secureSocketProtocol = null;
-
- private KeyManager[] keyManagers = null;
- private TrustManager[] trustManagers = null;
- private SecureRandom secureRandom = null;
-
- private URL keyStoreFilePath = null;
- private String keyStoreType = null;
- private String keyStoreAlgorithm = null;
- private String keyStorePassword = null;
- private String keyAlias = null;
- private String keyPassword = null;
-
- private URL trustStoreFilePath = null;
- private String trustStoreType = null;
- private String trustStoreAlgorithm = null;
- private String trustStorePassword = null;
-
- private Map<String, Object> config = null;
- private Boolean socketUseClientMode = null;
- private Boolean serverSocketUseClientMode = null;
- private Boolean serverAuthMode = null;
-
- private static final Logger log = Logger.getLogger(SSLContextFactory.class);
-
- /**
- * Constructor for {@link SSLContextFactory} that does not have
- * any configuration so it falls back to all defaults.
- */
- public SSLContextFactory()
- {
- this(null);
- }
-
- /**
- * Constructor for {@link SSLContextFactory} that allows the caller to
- * override the default settings for the various SSL configuration
- * properties.
- *
- * @param config configuration with properties defining things like where the
- * keystore and truststore files are, their types, etc.
- */
- public SSLContextFactory(Map<String, Object> config)
- {
- this.config = config;
- }
-
- public SSLContext getSSLContext() throws IOException
- {
- if (sslContextSocketFactory == null)
- {
- initializeSocketFactorySSLContext();
- }
- return sslContextSocketFactory;
- }
-
- public SSLContext getServerSSLContext() throws IOException
- {
- if (sslContextServerSocketFactory == null)
- {
- initializeServerSocketFactorySSLContext();
- }
- return sslContextServerSocketFactory;
- }
-
- /**
- * @see org.jboss.remoting.security.SSLSocketBuilderMBean#getSecureSocketProtocol()
- */
- public String getSecureSocketProtocol()
- {
- if (secureSocketProtocol == null)
- {
- if(config != null)
- {
- secureSocketProtocol = (String) config.get(StubExt.PROPERTY_SSL_PROTOCOL);
- }
- if (secureSocketProtocol == null)
- {
- secureSocketProtocol = DEFAULT_SSL_PROTOCOL;
- }
- }
-
- return secureSocketProtocol;
- }
-
- /**
- * @see org.jboss.remoting.security.SSLSocketBuilderMBean#setSecureSocketProtocol(String)
- */
- public void setSecureSocketProtocol(String protocol)
- {
- if(protocol != null && protocol.length() > 0)
- {
- this.secureSocketProtocol = protocol;
- }
- else
- {
- throw new IllegalArgumentException("Can not set remoting socket factory with null protocol");
- }
- }
-
- /**
- * @see org.jboss.remoting.security.SSLSocketBuilderMBean#getProvider()
- */
- public Provider getProvider()
- {
- return provider;
- }
-
- /**
- * @see org.jboss.remoting.security.SSLSocketBuilderMBean#setProvider(java.security.Provider)
- */
- public void setProvider(Provider provider)
- {
- this.provider = provider;
- }
-
- /**
- * @see org.jboss.remoting.security.SSLSocketBuilderMBean#getProviderName()
- */
- public String getProviderName()
- {
- if (providerName == null)
- {
- if(config != null)
- {
- providerName = (String) config.get(StubExt.PROPERTY_SSL_PROVIDER_NAME);
- }
- }
- return providerName;
- }
-
- /**
- * @see org.jboss.remoting.security.SSLSocketBuilderMBean#setProviderName(java.lang.String)
- */
- public void setProviderName(String providerName)
- {
- this.providerName = providerName;
- }
-
- /**
- * @see org.jboss.remoting.security.SSLSocketBuilderMBean#getSecureRandom()
- */
- public SecureRandom getSecureRandom()
- {
- if(secureRandom != null)
- {
- return secureRandom;
- }
-
- secureRandom = new SecureRandom();
-
- return secureRandom;
- }
-
- /**
- * @see org.jboss.remoting.security.SSLSocketBuilderMBean#setSecureRandom(java.security.SecureRandom)
- */
- public void setSecureRandom(SecureRandom secureRandom)
- {
- this.secureRandom = secureRandom;
- }
-
- /**
- * @see org.jboss.remoting.security.SSLSocketBuilderMBean#getKeyStoreURL()
- */
- public String getKeyStoreURL()
- {
- URL keyStore = getKeyStore();
- if(keyStore != null)
- {
- return keyStore.toString();
- }
- else
- {
- return null;
- }
- }
-
- /**
- * @see org.jboss.remoting.security.SSLSocketBuilderMBean#getKeyStore()
- */
- public URL getKeyStore()
- {
- if(keyStoreFilePath != null)
- {
- return keyStoreFilePath;
- }
-
- if(config != null)
- {
- String path = (String) config.get(StubExt.PROPERTY_KEY_STORE);
- if(path != null && path.length() > 0)
- {
- setKeyStoreURL( path );
- }
- }
-
- if(keyStoreFilePath == null)
- {
- String path = System.getProperty(STANDARD_KEY_STORE_FILE_PATH);
- if(path != null && path.length() > 0)
- {
- setKeyStoreURL( path );
- }
- }
-
- return keyStoreFilePath;
- }
-
- /**
- * @see org.jboss.remoting.security.SSLSocketBuilderMBean#setKeyStoreURL(java.lang.String)
- */
- public void setKeyStoreURL(String keyStoreFilePath)
- {
- try
- {
- this.keyStoreFilePath = validateStoreURL(keyStoreFilePath);
- }
- catch (IOException e)
- {
- throw new RuntimeException( "Cannot validate the store URL: " + keyStoreFilePath , e );
- }
- }
-
- /**
- * @see org.jboss.remoting.security.SSLSocketBuilderMBean#setKeyStore(java.net.URL)
- */
- public void setKeyStore(URL keyStore)
- {
- this.keyStoreFilePath = keyStore;
- }
-
- /**
- * @see org.jboss.remoting.security.SSLSocketBuilderMBean#getKeyStoreType()
- */
- public String getKeyStoreType()
- {
- if(keyStoreType != null)
- {
- return keyStoreType;
- }
-
- if(config != null)
- {
- String type = (String)config.get(StubExt.PROPERTY_KEY_STORE_TYPE);
- if(type != null && type.length() > 0)
- {
- keyStoreType = type;
- }
- }
-
- if(keyStoreType == null)
- {
- keyStoreType = System.getProperty(STANDARD_KEY_STORE_TYPE);
-
- if(keyStoreType == null)
- {
- keyStoreType = DEFAULT_KEY_STORE_TYPE;
- }
- }
-
- return keyStoreType;
- }
-
- /**
- * @see org.jboss.remoting.security.SSLSocketBuilderMBean#setKeyStoreType(java.lang.String)
- */
- public void setKeyStoreType(String keyStoreType)
- {
- this.keyStoreType = keyStoreType;
- }
-
- /**
- * @see org.jboss.remoting.security.SSLSocketBuilderMBean#getKeyStoreAlgorithm()
- */
- public String getKeyStoreAlgorithm()
- {
- if(keyStoreAlgorithm != null)
- {
- return keyStoreAlgorithm;
- }
-
- if(config != null)
- {
- String alg = (String)config.get(StubExt.PROPERTY_KEY_STORE_ALGORITHM);
- if(alg != null && alg.length() > 0)
- {
- keyStoreAlgorithm = alg;
- }
- }
-
- if(keyStoreAlgorithm == null)
- {
- keyStoreAlgorithm = DEFAULT_KEY_STORE_ALGORITHM;
- }
-
- return keyStoreAlgorithm;
- }
-
- /**
- * @see org.jboss.remoting.security.SSLSocketBuilderMBean#setKeyStoreAlgorithm(java.lang.String)
- */
- public void setKeyStoreAlgorithm(String algorithm)
- {
- this.keyStoreAlgorithm = algorithm;
- }
-
- /**
- * Returns the password used to gain access to the keystore.
- *
- * @return keystore password
- */
- public String getKeyStorePassword()
- {
- if(keyStorePassword != null)
- {
- return keyStorePassword;
- }
-
- if(config != null)
- {
- String passwd = (String)config.get(StubExt.PROPERTY_KEY_STORE_PASSWORD);
- if(passwd != null && passwd.length() > 0)
- {
- keyStorePassword = passwd;
- }
- }
-
- if(keyStorePassword == null)
- {
- keyStorePassword = System.getProperty(STANDARD_KEY_STORE_PASSWORD);
- }
-
- return keyStorePassword;
- }
-
- /**
- * @see org.jboss.remoting.security.SSLSocketBuilderMBean#setKeyStorePassword(java.lang.String)
- */
- public void setKeyStorePassword(String keyStorePassword)
- {
- this.keyStorePassword = keyStorePassword;
- }
-
- /**
- * @see org.jboss.remoting.security.SSLSocketBuilderMBean#getTrustStoreURL()
- */
- public String getTrustStoreURL()
- {
- URL trustStore = getTrustStore();
- if(trustStore != null)
- {
- return trustStore.toString();
- }
- else
- {
- return null;
- }
- }
-
- /**
- * @see org.jboss.remoting.security.SSLSocketBuilderMBean#getTrustStore()
- */
- public URL getTrustStore()
- {
- if(trustStoreFilePath != null)
- {
- return trustStoreFilePath;
- }
-
- if(config != null)
- {
- String path = (String)config.get(StubExt.PROPERTY_TRUST_STORE);
- if(path != null && path.length() > 0)
- {
- setTrustStoreURL( path );
- }
- }
-
- if(trustStoreFilePath == null)
- {
- String path = System.getProperty(STANDARD_TRUST_STORE_FILE_PATH);
- if(path != null && path.length() > 0)
- {
- setTrustStoreURL( path );
- }
- }
-
- return trustStoreFilePath;
- }
-
- /**
- * @see org.jboss.remoting.security.SSLSocketBuilderMBean#setTrustStore(java.net.URL)
- */
- public void setTrustStore(URL trustStore)
- {
- this.trustStoreFilePath = trustStore;
- }
-
- /**
- * @see org.jboss.remoting.security.SSLSocketBuilderMBean#setTrustStoreURL(java.lang.String)
- */
- public void setTrustStoreURL(String trustStoreFilePath)
- {
- try
- {
- this.trustStoreFilePath = validateStoreURL(trustStoreFilePath);
- }
- catch (IOException e)
- {
- throw new RuntimeException( "Cannot validate the store URL: " + trustStoreFilePath , e );
- }
- }
-
- /**
- * @see org.jboss.remoting.security.SSLSocketBuilderMBean#getTrustStoreType()
- */
- public String getTrustStoreType()
- {
- if(trustStoreType != null)
- {
- return trustStoreType;
- }
-
- if(config != null)
- {
- String type = (String)config.get(StubExt.PROPERTY_TRUST_STORE_TYPE);
- if(type != null && type.length() > 0)
- {
- trustStoreType = type;
- }
- }
-
- if(trustStoreType == null)
- {
- trustStoreType = System.getProperty(STANDARD_TRUST_STORE_TYPE);
-
- if(trustStoreType == null)
- {
- trustStoreType = getKeyStoreType();
- }
- }
-
- return trustStoreType;
- }
-
- /**
- * @see org.jboss.remoting.security.SSLSocketBuilderMBean#setTrustStoreType(java.lang.String)
- */
- public void setTrustStoreType(String trustStoreType)
- {
- this.trustStoreType = trustStoreType;
- }
-
- /**
- * @see org.jboss.remoting.security.SSLSocketBuilderMBean#getTrustStoreAlgorithm()
- */
- public String getTrustStoreAlgorithm()
- {
- if(trustStoreAlgorithm != null)
- {
- return trustStoreAlgorithm;
- }
-
- if(config != null)
- {
- String alg = (String)config.get(StubExt.PROPERTY_TRUST_STORE_ALGORITHM);
- if(alg != null && alg.length() > 0)
- {
- trustStoreAlgorithm = alg;
- }
- }
-
- if(trustStoreAlgorithm == null)
- {
- trustStoreAlgorithm = getKeyStoreAlgorithm();
- }
-
- return trustStoreAlgorithm;
- }
-
- /**
- * @see org.jboss.remoting.security.SSLSocketBuilderMBean#setTrustStoreAlgorithm(java.lang.String)
- */
- public void setTrustStoreAlgorithm(String algorithm)
- {
- this.trustStoreAlgorithm = algorithm;
- }
-
- /**
- * Returns the password used to gain access to the truststore.
- *
- * @return truststore password
- */
- public String getTrustStorePassword()
- {
- if(trustStorePassword != null)
- {
- return trustStorePassword;
- }
-
- if(config != null)
- {
- String passwd = (String)config.get(StubExt.PROPERTY_TRUST_STORE_PASSWORD);
- if(passwd != null && passwd.length() > 0)
- {
- trustStorePassword = passwd;
- }
- }
-
- if(trustStorePassword == null)
- {
- trustStorePassword = System.getProperty(STANDARD_TRUST_STORE_PASSWORD);
- if(trustStorePassword == null)
- {
- trustStorePassword = getKeyStorePassword();
- }
- }
-
- return trustStorePassword;
- }
-
- /**
- * @see org.jboss.remoting.security.SSLSocketBuilderMBean#setTrustStorePassword(java.lang.String)
- */
- public void setTrustStorePassword(String trustStorePassword)
- {
- this.trustStorePassword = trustStorePassword;
- }
-
- /**
- * @see org.jboss.remoting.security.SSLSocketBuilderMBean#getKeyAlias()
- */
- public String getKeyAlias()
- {
- if(keyAlias != null)
- {
- return keyAlias;
- }
- if(config != null)
- {
- keyAlias = (String)config.get(StubExt.PROPERTY_KEY_ALIAS);
- }
- return keyAlias;
- }
-
- /**
- * @see org.jboss.remoting.security.SSLSocketBuilderMBean#setKeyAlias(java.lang.String)
- */
- public void setKeyAlias(String alias)
- {
- this.keyAlias = alias;
- }
-
- /**
- * Returns the password to use for the keys within the key store.
- * If this value is not set, this will return <code>null</code> but
- * when this value is needed by this class, the value for the key store
- * password will be used instead.
- *
- * @return key password
- */
- public String getKeyPassword()
- {
- if(keyPassword != null)
- {
- return keyPassword;
- }
-
- if(config != null)
- {
- String passwd = (String)config.get(KEY_PASSWORD);
- if(passwd != null && passwd.length() > 0)
- {
- keyPassword = passwd;
- }
- }
-
- return keyPassword;
- }
-
- /**
- * @see org.jboss.remoting.security.SSLSocketBuilderMBean#setKeyPassword(java.lang.String)
- */
- public void setKeyPassword(String keyPassword)
- {
- this.keyPassword = keyPassword;
- }
-
- /**
- * @see org.jboss.remoting.security.SSLSocketBuilderMBean#isSocketUseClientMode()
- */
- public boolean isSocketUseClientMode( )
- {
- if (socketUseClientMode == null)
- {
- if (config != null && config.containsKey(SSL_USE_CLIENT_MODE))
- {
- socketUseClientMode = Boolean.valueOf((String) config.get(SSL_USE_CLIENT_MODE));
- }
- else
- {
- socketUseClientMode = Boolean.TRUE;
- }
- }
-
- return socketUseClientMode.booleanValue();
- }
-
- /**
- * @see org.jboss.remoting.security.SSLSocketBuilderMBean#isServerSocketUseClientMode()
- */
- public boolean isServerSocketUseClientMode( )
- {
- if (serverSocketUseClientMode == null)
- {
- if (config != null && config.containsKey(SERVER_SSL_USE_CLIENT_MODE))
- {
- serverSocketUseClientMode = Boolean.valueOf((String) config.get(SERVER_SSL_USE_CLIENT_MODE));
- }
- else
- {
- serverSocketUseClientMode = Boolean.FALSE;
- }
- }
-
- return serverSocketUseClientMode.booleanValue();
- }
-
- /**
- * @see org.jboss.remoting.security.SSLSocketBuilderMBean#setSocketUseClientMode(boolean)
- */
- public void setSocketUseClientMode( boolean useClientMode )
- {
- this.socketUseClientMode = Boolean.valueOf(useClientMode);
- }
-
- /**
- * @see org.jboss.remoting.security.SSLSocketBuilderMBean#setServerSocketUseClientMode(boolean)
- */
- public void setServerSocketUseClientMode( boolean useClientMode )
- {
- this.serverSocketUseClientMode = Boolean.valueOf(useClientMode);
- }
-
- /**
- * @see org.jboss.remoting.security.SSLSocketBuilderMBean#isServerAuthMode()
- */
- public boolean isServerAuthMode()
- {
- if (serverAuthMode == null)
- {
- if (config != null && config.containsKey(SSL_SERVER_AUTH_MODE))
- {
- serverAuthMode = Boolean.valueOf( (String) config.get(SSL_SERVER_AUTH_MODE) );
- }
- else
- {
- serverAuthMode = Boolean.TRUE;
- }
- }
-
- return serverAuthMode.booleanValue();
- }
-
- /**
- * @see org.jboss.remoting.security.SSLSocketBuilderMBean#setServerAuthMode(boolean)
- */
- public void setServerAuthMode(boolean mode)
- {
- serverAuthMode = Boolean.valueOf(mode);
- }
-
- /**
- * Creates (but does not initialize) the SSL context used by this object
- * to create server socket factories.
- * The provider/protocol is used to determine what SSL context to use.
- * Call {@link #initializeServerSocketFactorySSLContext()} if you want
- * to create and initialize in one method call.
- * If the server socket factory SSL context was already created, this will create
- * a new one and remove the old one.
- *
- * @throws IOException
- */
- protected void createServerSocketFactorySSLContext()
- throws IOException
- {
- try
- {
- if(getProvider() != null)
- {
- sslContextServerSocketFactory = SSLContext.getInstance(getSecureSocketProtocol(), getProvider());
- }
- else if(getProviderName() != null)
- {
- sslContextServerSocketFactory = SSLContext.getInstance(getSecureSocketProtocol(), getProviderName());
- }
- else
- {
- sslContextServerSocketFactory = SSLContext.getInstance(getSecureSocketProtocol());
- }
- }
- catch(Exception e)
- {
- IOException ioe = new IOException("Error creating server socket factory SSL context: " + e.getMessage());
- ioe.setStackTrace(e.getStackTrace());
- throw ioe;
- }
-
- return;
- }
-
- /**
- * Creates (but does not initialize) the SSL context used by this object
- * to create socket factories.
- * The provider/protocol is used to determine what SSL context to use.
- * Call {@link #initializeSocketFactorySSLContext()} if you want
- * to create and initialize in one method call.
- * If the socket factory SSL context was already created, this will create
- * a new one and remove the old one.
- *
- * @throws IOException
- */
- protected void createSocketFactorySSLContext()
- throws IOException
- {
- try
- {
- if(getProvider() != null)
- {
- sslContextSocketFactory = SSLContext.getInstance(getSecureSocketProtocol(), getProvider());
- }
- else if(getProviderName() != null)
- {
- sslContextSocketFactory = SSLContext.getInstance(getSecureSocketProtocol(), getProviderName());
- }
- else
- {
- sslContextSocketFactory = SSLContext.getInstance(getSecureSocketProtocol());
- }
- }
- catch(Exception e)
- {
- IOException ioe = new IOException("Error creating socket factory SSL context: " + e.getMessage());
- ioe.setStackTrace(e.getStackTrace());
- throw ioe;
- }
-
- return;
- }
-
- /**
- * Initializes the SSL context used by this object that will create the server socket factories.
- * If the SSL context is not yet created, this method will also create it.
- * The provider/protocol is used to determine what SSL context to use. Key and trust managers
- * are loaded and a secure random object is created and the SSL context for the
- * protocol/provider is initialized with them.
- *
- * @throws IOException
- */
- protected void initializeServerSocketFactorySSLContext()
- throws IOException
- {
- try
- {
- if (sslContextServerSocketFactory == null)
- {
- createServerSocketFactorySSLContext();
- }
-
- try
- {
- keyManagers = loadKeyManagers();
- }
- catch (NullStoreURLException e)
- {
- if (isServerSocketUseClientMode())
- {
- keyManagers = null;
- log.debug("Could not find keytore url. " + e.getMessage());
- }
- else
- {
- // because this ssl context will create server socket factories, will throw if can not find keystore
- IOException ioe = new IOException("Can not find keystore url.");
- ioe.initCause(e);
- throw ioe;
- }
- }
-
- try
- {
- boolean isClientMode = isServerSocketUseClientMode();
- trustManagers = loadTrustManagers(isClientMode);
- }
- catch (NullStoreURLException e)
- {
- trustManagers = null;
- log.debug("Could not find truststore url. " + e.getMessage());
- }
-
- secureRandom = getSecureRandom();
-
- sslContextServerSocketFactory.init(keyManagers, trustManagers, secureRandom);
- }
- catch(Exception e)
- {
- IOException ioe = new IOException("Error initializing server socket factory SSL context: " + e.getMessage());
- ioe.setStackTrace(e.getStackTrace());
- throw ioe;
- }
-
- return;
- }
-
- /**
- * Initializes the SSL context used by this object that will create the socket factories.
- * If the SSL context is not yet created, this method will also create it.
- * The provider/protocol is used to determine what SSL context to use. Key and trust managers
- * are loaded and a secure random object is created and the SSL context for the
- * protocol/provider is initialized with them.
- *
- * @throws IOException
- */
- protected void initializeSocketFactorySSLContext()
- throws IOException
- {
- try
- {
- if (sslContextSocketFactory == null)
- {
- createSocketFactorySSLContext();
- }
-
- try
- {
- keyManagers = loadKeyManagers();
- }
- catch (NullStoreURLException e)
- {
- // this is allowable since would be the normal scenario
- keyManagers = null;
- log.debug("Could not find keystore url. " + e.getMessage());
- }
-
- try
- {
- boolean isClientMode = isSocketUseClientMode();
- trustManagers = loadTrustManagers(isClientMode);
- }
- catch (NullStoreURLException e)
- {
- // If the keyManagers is not null, could possibly be using in client mode
- // so want to allow it. Otherwise, need to throw exception as will not be able
- // to use in client mode or not
- if(keyManagers != null)
- {
- trustManagers = null;
- log.debug("Could not find truststore url. " + e.getMessage());
- }
- else
- {
- IOException ioe = new IOException("Can not find truststore url.");
- ioe.initCause(e);
- throw ioe;
- }
- }
-
- secureRandom = getSecureRandom();
-
- sslContextSocketFactory.init(keyManagers, trustManagers, secureRandom);
- }
- catch(Exception e)
- {
- IOException ioe = new IOException("Error initializing socket factory SSL context: " + e.getMessage());
- ioe.setStackTrace(e.getStackTrace());
- throw ioe;
- }
-
- return;
- }
-
- /**
- * Loads the trust managers based on this object's truststore.
- *
- * @return array of trust managers that should be loaded in this object's SSL context
- *
- * @throws NoSuchProviderException
- * @throws NoSuchAlgorithmException
- * @throws IOException
- * @throws CertificateException
- * @throws KeyStoreException
- * @throws NullStoreURLException
- */
- protected TrustManager[] loadTrustManagers(boolean isClientMode)
- throws NoSuchProviderException, NoSuchAlgorithmException, IOException, CertificateException, KeyStoreException, NullStoreURLException
- {
- if(isClientMode && !isServerAuthMode())
- {
- // we are in client mode and do not want to perform server cert authentication
- // return a trust manager that trusts all certs
- trustManagers = new TrustManager[] {
- new X509TrustManager() {
- public void checkClientTrusted( X509Certificate[] chain, String authType ) {}
- public void checkServerTrusted( X509Certificate[] chain, String authType ) {}
- public X509Certificate[] getAcceptedIssuers() { return null; }
- }};
- }
- else
- {
- String tsType = getTrustStoreType();
- String tsPasswd = getTrustStorePassword();
- URL tsPathURL = getTrustStore();
-
- String tsAlg = getTrustStoreAlgorithm();
-
- TrustManagerFactory trustMgrFactory;
- KeyStore trustStore = loadKeyStore(tsType, tsPathURL, tsPasswd);
-
- if (getProvider() != null)
- {
- trustMgrFactory = TrustManagerFactory.getInstance(tsAlg, getProvider());
- }
- else if (getProviderName() != null)
- {
- trustMgrFactory = TrustManagerFactory.getInstance(tsAlg, getProviderName());
- }
- else
- {
- trustMgrFactory = TrustManagerFactory.getInstance(tsAlg);
- }
-
- if (trustStore != null)
- {
- trustMgrFactory.init(trustStore);
-
- trustManagers = trustMgrFactory.getTrustManagers();
- }
- }
-
- return trustManagers;
- }
-
- /**
- * Loads the key managers based on this object's truststore.
- *
- * @return array of key managers that should be loaded in this object's SSL context
- *
- * @throws NoSuchProviderException
- * @throws NoSuchAlgorithmException
- * @throws IOException
- * @throws CertificateException
- * @throws KeyStoreException
- * @throws UnrecoverableKeyException
- * @throws NullStoreURLException
- */
- protected KeyManager[] loadKeyManagers()
- throws NoSuchProviderException, NoSuchAlgorithmException, IOException, CertificateException,
- KeyStoreException, UnrecoverableKeyException, NullStoreURLException
- {
- String ksPasswd = getKeyStorePassword();
- String ksType = getKeyStoreType();
- URL ksPathURL = getKeyStore();
-
- KeyStore keyStore = loadKeyStore(ksType, ksPathURL, ksPasswd);
-
- if(keyStore != null)
- {
- String alias = getKeyAlias();
-
- // check that keystore contains supplied alias (if there is one)
- if(alias != null)
- {
- boolean containsAlias = keyStore.isKeyEntry(alias);
- if(!containsAlias)
- {
- // can not continue as supplied alias does not exist as key entry
- throw new IOException("Can not find key entry for key store (" + ksPathURL + ") with given alias (" + alias + ")");
- }
- }
-
- KeyManagerFactory keyMgrFactory = null;
- String alg = getKeyStoreAlgorithm();
-
- if(getProvider() != null)
- {
- keyMgrFactory = KeyManagerFactory.getInstance(alg, getProvider());
- }
- else if(getProviderName() != null)
- {
- keyMgrFactory = KeyManagerFactory.getInstance(alg, getProviderName());
- }
- else
- {
- keyMgrFactory = KeyManagerFactory.getInstance(alg);
- }
-
- // get they key password, if it isn't defined, use the key store password
- String keyPasswd = getKeyPassword();
- if (keyPasswd == null || keyPasswd.length() == 0)
- {
- keyPasswd = ksPasswd;
- }
-
- keyMgrFactory.init(keyStore, keyPasswd.toCharArray());
- keyManagers = keyMgrFactory.getKeyManagers();
-
- // if alias provided, use helper impl to hard wire alias name to be used
- if(alias != null)
- {
- //TODO: -TME Need careful review of if this is really needed or not.
- for(int x = 0; x < keyManagers.length; x++)
- {
- keyManagers[x] = new JBossWSKeyManager((X509KeyManager)keyManagers[x], alias);
- }
- }
-
- }
- return keyManagers;
- }
-
- /**
- * Loads a key store file and returns it.
- *
- * @param storeType the type of store file
- * @param storePathURL the URL to the file - may be relative to the current thread's classloader
- * or may be absolute path to a file on the file system.
- * @param storePassword password to gain access to the store file
- *
- * @return the key store
- *
- * @throws KeyStoreException
- * @throws NoSuchProviderException
- * @throws IOException
- * @throws NoSuchAlgorithmException
- * @throws CertificateException
- * @throws NullStoreURLException
- */
- protected KeyStore loadKeyStore(String storeType, URL storePathURL, String storePassword)
- throws KeyStoreException, NoSuchProviderException, IOException, NoSuchAlgorithmException, CertificateException, NullStoreURLException
- {
- KeyStore keyStore = null;
-
- if(getProvider() != null)
- {
- keyStore = KeyStore.getInstance(storeType, getProvider());
- }
- else if(getProviderName() != null)
- {
- keyStore = KeyStore.getInstance(storeType, getProviderName());
- }
- else
- {
- keyStore = KeyStore.getInstance(storeType);
- }
-
- if ( storePathURL == null )
- {
- throw new NullStoreURLException("Can not find store file for url because store url is null.");
- }
-
- // now that keystore instance created, need to load data from file
- InputStream keyStoreInputStream = null;
-
- try
- {
- keyStoreInputStream = storePathURL.openStream();
-
- // is ok for password to be null, as will just be used to check integrity of store
- char[] password = storePassword != null ? storePassword.toCharArray() : null;
- keyStore.load(keyStoreInputStream, password);
- }
- finally
- {
- if(keyStoreInputStream != null)
- {
- try
- {
- keyStoreInputStream.close();
- }
- catch(IOException e)
- {
- // no op
- }
- keyStoreInputStream = null;
- }
- }
-
- return keyStore;
- }
-
- /**
- * Given a store file path, this will verify that the store actually exists.
- * First, it checks to see if its a valid URL, then it checks to see if the
- * file path is found in the file system and finally will be checked to see
- * if it can be found as a resource within the current thread's classloader.
- * An exception is thrown if the store cannot be found.
- *
- * @param storePath the path which can be a URL, path to a resource in classloader
- * or a file path on the file system.
- *
- * @return the URL of the file that was found
- *
- * @throws IOException if the store could not be found
- */
- protected URL validateStoreURL(String storePath) throws IOException
- {
- URL url = null;
-
- // First see if this is a URL
- try
- {
- url = new URL(storePath);
- }
- catch(MalformedURLException e)
- {
- // Not a URL or a protocol without a handler so...
- // next try to locate this as file path
- File tst = new File(storePath);
-
- if(tst.exists() == true)
- {
- url = tst.toURL();
- }
- else
- {
- // not a file either, lastly try to locate this as a classpath resource
- if(url == null)
- {
- ClassLoader loader = Thread.currentThread().getContextClassLoader();
- url = loader.getResource(storePath);
- }
- }
- }
-
- // Fail if no valid key store was located
- if(url == null)
- {
- String msg = "Failed to find url=" + storePath + " as a URL, file or resource";
- throw new MalformedURLException(msg);
- }
-
- return url;
- }
-
- /**
- * Used to indicate a store URL was not specified and thus the store is not available.
- */
- protected class NullStoreURLException extends Exception
- {
- private static final long serialVersionUID = 1L;
-
- /**
- * @see Exception#Exception(String)
- */
- public NullStoreURLException(String message)
- {
- super(message);
- }
- }
-}
\ No newline at end of file
Copied: stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/client/ssl/SSLContextFactory.java (from rev 10312, stack/native/branches/netty/modules/core/src/main/java/org/jboss/ws/core/client/ssl/SSLContextFactory.java)
===================================================================
--- stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/client/ssl/SSLContextFactory.java (rev 0)
+++ stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/client/ssl/SSLContextFactory.java 2009-07-04 14:44:05 UTC (rev 10315)
@@ -0,0 +1,1303 @@
+/*
+* 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.ws.core.client.ssl;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.security.KeyStore;
+import java.security.KeyStoreException;
+import java.security.NoSuchAlgorithmException;
+import java.security.NoSuchProviderException;
+import java.security.Provider;
+import java.security.SecureRandom;
+import java.security.UnrecoverableKeyException;
+import java.security.cert.CertificateException;
+import java.security.cert.X509Certificate;
+import java.util.Map;
+
+import javax.net.ssl.KeyManager;
+import javax.net.ssl.KeyManagerFactory;
+import javax.net.ssl.SSLContext;
+import javax.net.ssl.TrustManager;
+import javax.net.ssl.TrustManagerFactory;
+import javax.net.ssl.X509KeyManager;
+import javax.net.ssl.X509TrustManager;
+
+import org.jboss.logging.Logger;
+import org.jboss.ws.core.StubExt;
+
+/**
+ * This builds SSLContext instances. It's a modified version of org.jboss.remoting.security.SSLSocketBuilder
+ *
+ * @author <a href="mailto:mazz@jboss.com">John Mazzitelli</a>
+ * @author <a href="mailto:telrod@jboss.com">Tom Elrod</a>
+ * @author <a href="mailto:alessio.soldano@jboss.com">Alessio Soldano</a>
+ *
+ */
+public class SSLContextFactory
+{
+ /**
+ * If the protocol isn't specified, this will be the default.
+ * Value is "TLS".
+ */
+ public static final String DEFAULT_SSL_PROTOCOL = "TLS";
+
+ /**
+ * Constant defining the config property used to define if the sockets will be in
+ * client or server mode.
+ */
+ public static final String SSL_USE_CLIENT_MODE = "org.jboss.ws.sslUseClientMode";
+
+ /**
+ * Constant defining the config property used to define if the server sockets will be in
+ * client or server mode.
+ */
+ public static final String SERVER_SSL_USE_CLIENT_MODE = "org.jboss.ws.serverSslUseClientMode";
+
+ /**
+ * Constant defining the config property used to define if a client should attempt to
+ * authenticate a server certificate as one it trusts. The value of such a property is
+ * a boolean.
+ */
+ public static final String SSL_SERVER_AUTH_MODE = "org.jboss.ws.sslServerAuthMode";
+
+ /**
+ * Constant defining the config property that indicates the key password for the keys in the key store.
+ */
+ public static final String KEY_PASSWORD = "org.jboss.ws.keyPassword";
+
+ /**
+ * Constant that defines the standard system property that the javax.net.ssl
+ * classes look for when locating the keystore file.
+ */
+ public static final String STANDARD_KEY_STORE_FILE_PATH = "javax.net.ssl.keyStore";
+
+ /**
+ * Constant that defines the standard system property that the javax.net.ssl
+ * classes look for when needing to know what type the keystore file is.
+ */
+ public static final String STANDARD_KEY_STORE_TYPE = "javax.net.ssl.keyStoreType";
+
+ /**
+ * Constant that defines the standard system property that the javax.net.ssl
+ * classes look for when needing the keystore password.
+ */
+ public static final String STANDARD_KEY_STORE_PASSWORD = "javax.net.ssl.keyStorePassword";
+
+ /**
+ * Default key/trust store type if one not set as bean property, via config, or via system property.
+ * Value is 'JKS'.
+ */
+ public static final String DEFAULT_KEY_STORE_TYPE = "JKS";
+
+ /**
+ * Default key/trust store algorithm if one net set as bean property or via config.
+ * Value is 'SunX509'.
+ */
+ public static final String DEFAULT_KEY_STORE_ALGORITHM = "SunX509";
+
+ /**
+ * Constant that defines the standard system property that the javax.net.ssl
+ * classes look for when locating the truststore file.
+ */
+ public static final String STANDARD_TRUST_STORE_FILE_PATH = "javax.net.ssl.trustStore";
+
+ /**
+ * Constant that defines the standard system property that the javax.net.ssl
+ * classes look for when needing to know what type the truststore file is.
+ */
+ public static final String STANDARD_TRUST_STORE_TYPE = "javax.net.ssl.trustStoreType";
+
+ /**
+ * Constant that defines the standard system property that the javax.net.ssl
+ * classes look for when needing the truststore password.
+ */
+ public static final String STANDARD_TRUST_STORE_PASSWORD = "javax.net.ssl.trustStorePassword";
+
+ private SSLContext sslContextServerSocketFactory = null; // context that builds the server socket factories
+ private SSLContext sslContextSocketFactory = null; // context that builds the socket factories
+ private Provider provider = null;
+ private String providerName = null;
+ private String secureSocketProtocol = null;
+
+ private KeyManager[] keyManagers = null;
+ private TrustManager[] trustManagers = null;
+ private SecureRandom secureRandom = null;
+
+ private URL keyStoreFilePath = null;
+ private String keyStoreType = null;
+ private String keyStoreAlgorithm = null;
+ private String keyStorePassword = null;
+ private String keyAlias = null;
+ private String keyPassword = null;
+
+ private URL trustStoreFilePath = null;
+ private String trustStoreType = null;
+ private String trustStoreAlgorithm = null;
+ private String trustStorePassword = null;
+
+ private Map<String, Object> config = null;
+ private Boolean socketUseClientMode = null;
+ private Boolean serverSocketUseClientMode = null;
+ private Boolean serverAuthMode = null;
+
+ private static final Logger log = Logger.getLogger(SSLContextFactory.class);
+
+ /**
+ * Constructor for {@link SSLContextFactory} that does not have
+ * any configuration so it falls back to all defaults.
+ */
+ public SSLContextFactory()
+ {
+ this(null);
+ }
+
+ /**
+ * Constructor for {@link SSLContextFactory} that allows the caller to
+ * override the default settings for the various SSL configuration
+ * properties.
+ *
+ * @param config configuration with properties defining things like where the
+ * keystore and truststore files are, their types, etc.
+ */
+ public SSLContextFactory(Map<String, Object> config)
+ {
+ this.config = config;
+ }
+
+ public SSLContext getSSLContext() throws IOException
+ {
+ if (sslContextSocketFactory == null)
+ {
+ initializeSocketFactorySSLContext();
+ }
+ return sslContextSocketFactory;
+ }
+
+ public SSLContext getServerSSLContext() throws IOException
+ {
+ if (sslContextServerSocketFactory == null)
+ {
+ initializeServerSocketFactorySSLContext();
+ }
+ return sslContextServerSocketFactory;
+ }
+
+ /**
+ * @see org.jboss.remoting.security.SSLSocketBuilderMBean#getSecureSocketProtocol()
+ */
+ public String getSecureSocketProtocol()
+ {
+ if (secureSocketProtocol == null)
+ {
+ if(config != null)
+ {
+ secureSocketProtocol = (String) config.get(StubExt.PROPERTY_SSL_PROTOCOL);
+ }
+ if (secureSocketProtocol == null)
+ {
+ secureSocketProtocol = DEFAULT_SSL_PROTOCOL;
+ }
+ }
+
+ return secureSocketProtocol;
+ }
+
+ /**
+ * @see org.jboss.remoting.security.SSLSocketBuilderMBean#setSecureSocketProtocol(String)
+ */
+ public void setSecureSocketProtocol(String protocol)
+ {
+ if(protocol != null && protocol.length() > 0)
+ {
+ this.secureSocketProtocol = protocol;
+ }
+ else
+ {
+ throw new IllegalArgumentException("Can not set remoting socket factory with null protocol");
+ }
+ }
+
+ /**
+ * @see org.jboss.remoting.security.SSLSocketBuilderMBean#getProvider()
+ */
+ public Provider getProvider()
+ {
+ return provider;
+ }
+
+ /**
+ * @see org.jboss.remoting.security.SSLSocketBuilderMBean#setProvider(java.security.Provider)
+ */
+ public void setProvider(Provider provider)
+ {
+ this.provider = provider;
+ }
+
+ /**
+ * @see org.jboss.remoting.security.SSLSocketBuilderMBean#getProviderName()
+ */
+ public String getProviderName()
+ {
+ if (providerName == null)
+ {
+ if(config != null)
+ {
+ providerName = (String) config.get(StubExt.PROPERTY_SSL_PROVIDER_NAME);
+ }
+ }
+ return providerName;
+ }
+
+ /**
+ * @see org.jboss.remoting.security.SSLSocketBuilderMBean#setProviderName(java.lang.String)
+ */
+ public void setProviderName(String providerName)
+ {
+ this.providerName = providerName;
+ }
+
+ /**
+ * @see org.jboss.remoting.security.SSLSocketBuilderMBean#getSecureRandom()
+ */
+ public SecureRandom getSecureRandom()
+ {
+ if(secureRandom != null)
+ {
+ return secureRandom;
+ }
+
+ secureRandom = new SecureRandom();
+
+ return secureRandom;
+ }
+
+ /**
+ * @see org.jboss.remoting.security.SSLSocketBuilderMBean#setSecureRandom(java.security.SecureRandom)
+ */
+ public void setSecureRandom(SecureRandom secureRandom)
+ {
+ this.secureRandom = secureRandom;
+ }
+
+ /**
+ * @see org.jboss.remoting.security.SSLSocketBuilderMBean#getKeyStoreURL()
+ */
+ public String getKeyStoreURL()
+ {
+ URL keyStore = getKeyStore();
+ if(keyStore != null)
+ {
+ return keyStore.toString();
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ /**
+ * @see org.jboss.remoting.security.SSLSocketBuilderMBean#getKeyStore()
+ */
+ public URL getKeyStore()
+ {
+ if(keyStoreFilePath != null)
+ {
+ return keyStoreFilePath;
+ }
+
+ if(config != null)
+ {
+ String path = (String) config.get(StubExt.PROPERTY_KEY_STORE);
+ if(path != null && path.length() > 0)
+ {
+ setKeyStoreURL( path );
+ }
+ }
+
+ if(keyStoreFilePath == null)
+ {
+ String path = System.getProperty(STANDARD_KEY_STORE_FILE_PATH);
+ if(path != null && path.length() > 0)
+ {
+ setKeyStoreURL( path );
+ }
+ }
+
+ return keyStoreFilePath;
+ }
+
+ /**
+ * @see org.jboss.remoting.security.SSLSocketBuilderMBean#setKeyStoreURL(java.lang.String)
+ */
+ public void setKeyStoreURL(String keyStoreFilePath)
+ {
+ try
+ {
+ this.keyStoreFilePath = validateStoreURL(keyStoreFilePath);
+ }
+ catch (IOException e)
+ {
+ throw new RuntimeException( "Cannot validate the store URL: " + keyStoreFilePath , e );
+ }
+ }
+
+ /**
+ * @see org.jboss.remoting.security.SSLSocketBuilderMBean#setKeyStore(java.net.URL)
+ */
+ public void setKeyStore(URL keyStore)
+ {
+ this.keyStoreFilePath = keyStore;
+ }
+
+ /**
+ * @see org.jboss.remoting.security.SSLSocketBuilderMBean#getKeyStoreType()
+ */
+ public String getKeyStoreType()
+ {
+ if(keyStoreType != null)
+ {
+ return keyStoreType;
+ }
+
+ if(config != null)
+ {
+ String type = (String)config.get(StubExt.PROPERTY_KEY_STORE_TYPE);
+ if(type != null && type.length() > 0)
+ {
+ keyStoreType = type;
+ }
+ }
+
+ if(keyStoreType == null)
+ {
+ keyStoreType = System.getProperty(STANDARD_KEY_STORE_TYPE);
+
+ if(keyStoreType == null)
+ {
+ keyStoreType = DEFAULT_KEY_STORE_TYPE;
+ }
+ }
+
+ return keyStoreType;
+ }
+
+ /**
+ * @see org.jboss.remoting.security.SSLSocketBuilderMBean#setKeyStoreType(java.lang.String)
+ */
+ public void setKeyStoreType(String keyStoreType)
+ {
+ this.keyStoreType = keyStoreType;
+ }
+
+ /**
+ * @see org.jboss.remoting.security.SSLSocketBuilderMBean#getKeyStoreAlgorithm()
+ */
+ public String getKeyStoreAlgorithm()
+ {
+ if(keyStoreAlgorithm != null)
+ {
+ return keyStoreAlgorithm;
+ }
+
+ if(config != null)
+ {
+ String alg = (String)config.get(StubExt.PROPERTY_KEY_STORE_ALGORITHM);
+ if(alg != null && alg.length() > 0)
+ {
+ keyStoreAlgorithm = alg;
+ }
+ }
+
+ if(keyStoreAlgorithm == null)
+ {
+ keyStoreAlgorithm = DEFAULT_KEY_STORE_ALGORITHM;
+ }
+
+ return keyStoreAlgorithm;
+ }
+
+ /**
+ * @see org.jboss.remoting.security.SSLSocketBuilderMBean#setKeyStoreAlgorithm(java.lang.String)
+ */
+ public void setKeyStoreAlgorithm(String algorithm)
+ {
+ this.keyStoreAlgorithm = algorithm;
+ }
+
+ /**
+ * Returns the password used to gain access to the keystore.
+ *
+ * @return keystore password
+ */
+ public String getKeyStorePassword()
+ {
+ if(keyStorePassword != null)
+ {
+ return keyStorePassword;
+ }
+
+ if(config != null)
+ {
+ String passwd = (String)config.get(StubExt.PROPERTY_KEY_STORE_PASSWORD);
+ if(passwd != null && passwd.length() > 0)
+ {
+ keyStorePassword = passwd;
+ }
+ }
+
+ if(keyStorePassword == null)
+ {
+ keyStorePassword = System.getProperty(STANDARD_KEY_STORE_PASSWORD);
+ }
+
+ return keyStorePassword;
+ }
+
+ /**
+ * @see org.jboss.remoting.security.SSLSocketBuilderMBean#setKeyStorePassword(java.lang.String)
+ */
+ public void setKeyStorePassword(String keyStorePassword)
+ {
+ this.keyStorePassword = keyStorePassword;
+ }
+
+ /**
+ * @see org.jboss.remoting.security.SSLSocketBuilderMBean#getTrustStoreURL()
+ */
+ public String getTrustStoreURL()
+ {
+ URL trustStore = getTrustStore();
+ if(trustStore != null)
+ {
+ return trustStore.toString();
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ /**
+ * @see org.jboss.remoting.security.SSLSocketBuilderMBean#getTrustStore()
+ */
+ public URL getTrustStore()
+ {
+ if(trustStoreFilePath != null)
+ {
+ return trustStoreFilePath;
+ }
+
+ if(config != null)
+ {
+ String path = (String)config.get(StubExt.PROPERTY_TRUST_STORE);
+ if(path != null && path.length() > 0)
+ {
+ setTrustStoreURL( path );
+ }
+ }
+
+ if(trustStoreFilePath == null)
+ {
+ String path = System.getProperty(STANDARD_TRUST_STORE_FILE_PATH);
+ if(path != null && path.length() > 0)
+ {
+ setTrustStoreURL( path );
+ }
+ }
+
+ return trustStoreFilePath;
+ }
+
+ /**
+ * @see org.jboss.remoting.security.SSLSocketBuilderMBean#setTrustStore(java.net.URL)
+ */
+ public void setTrustStore(URL trustStore)
+ {
+ this.trustStoreFilePath = trustStore;
+ }
+
+ /**
+ * @see org.jboss.remoting.security.SSLSocketBuilderMBean#setTrustStoreURL(java.lang.String)
+ */
+ public void setTrustStoreURL(String trustStoreFilePath)
+ {
+ try
+ {
+ this.trustStoreFilePath = validateStoreURL(trustStoreFilePath);
+ }
+ catch (IOException e)
+ {
+ throw new RuntimeException( "Cannot validate the store URL: " + trustStoreFilePath , e );
+ }
+ }
+
+ /**
+ * @see org.jboss.remoting.security.SSLSocketBuilderMBean#getTrustStoreType()
+ */
+ public String getTrustStoreType()
+ {
+ if(trustStoreType != null)
+ {
+ return trustStoreType;
+ }
+
+ if(config != null)
+ {
+ String type = (String)config.get(StubExt.PROPERTY_TRUST_STORE_TYPE);
+ if(type != null && type.length() > 0)
+ {
+ trustStoreType = type;
+ }
+ }
+
+ if(trustStoreType == null)
+ {
+ trustStoreType = System.getProperty(STANDARD_TRUST_STORE_TYPE);
+
+ if(trustStoreType == null)
+ {
+ trustStoreType = getKeyStoreType();
+ }
+ }
+
+ return trustStoreType;
+ }
+
+ /**
+ * @see org.jboss.remoting.security.SSLSocketBuilderMBean#setTrustStoreType(java.lang.String)
+ */
+ public void setTrustStoreType(String trustStoreType)
+ {
+ this.trustStoreType = trustStoreType;
+ }
+
+ /**
+ * @see org.jboss.remoting.security.SSLSocketBuilderMBean#getTrustStoreAlgorithm()
+ */
+ public String getTrustStoreAlgorithm()
+ {
+ if(trustStoreAlgorithm != null)
+ {
+ return trustStoreAlgorithm;
+ }
+
+ if(config != null)
+ {
+ String alg = (String)config.get(StubExt.PROPERTY_TRUST_STORE_ALGORITHM);
+ if(alg != null && alg.length() > 0)
+ {
+ trustStoreAlgorithm = alg;
+ }
+ }
+
+ if(trustStoreAlgorithm == null)
+ {
+ trustStoreAlgorithm = getKeyStoreAlgorithm();
+ }
+
+ return trustStoreAlgorithm;
+ }
+
+ /**
+ * @see org.jboss.remoting.security.SSLSocketBuilderMBean#setTrustStoreAlgorithm(java.lang.String)
+ */
+ public void setTrustStoreAlgorithm(String algorithm)
+ {
+ this.trustStoreAlgorithm = algorithm;
+ }
+
+ /**
+ * Returns the password used to gain access to the truststore.
+ *
+ * @return truststore password
+ */
+ public String getTrustStorePassword()
+ {
+ if(trustStorePassword != null)
+ {
+ return trustStorePassword;
+ }
+
+ if(config != null)
+ {
+ String passwd = (String)config.get(StubExt.PROPERTY_TRUST_STORE_PASSWORD);
+ if(passwd != null && passwd.length() > 0)
+ {
+ trustStorePassword = passwd;
+ }
+ }
+
+ if(trustStorePassword == null)
+ {
+ trustStorePassword = System.getProperty(STANDARD_TRUST_STORE_PASSWORD);
+ if(trustStorePassword == null)
+ {
+ trustStorePassword = getKeyStorePassword();
+ }
+ }
+
+ return trustStorePassword;
+ }
+
+ /**
+ * @see org.jboss.remoting.security.SSLSocketBuilderMBean#setTrustStorePassword(java.lang.String)
+ */
+ public void setTrustStorePassword(String trustStorePassword)
+ {
+ this.trustStorePassword = trustStorePassword;
+ }
+
+ /**
+ * @see org.jboss.remoting.security.SSLSocketBuilderMBean#getKeyAlias()
+ */
+ public String getKeyAlias()
+ {
+ if(keyAlias != null)
+ {
+ return keyAlias;
+ }
+ if(config != null)
+ {
+ keyAlias = (String)config.get(StubExt.PROPERTY_KEY_ALIAS);
+ }
+ return keyAlias;
+ }
+
+ /**
+ * @see org.jboss.remoting.security.SSLSocketBuilderMBean#setKeyAlias(java.lang.String)
+ */
+ public void setKeyAlias(String alias)
+ {
+ this.keyAlias = alias;
+ }
+
+ /**
+ * Returns the password to use for the keys within the key store.
+ * If this value is not set, this will return <code>null</code> but
+ * when this value is needed by this class, the value for the key store
+ * password will be used instead.
+ *
+ * @return key password
+ */
+ public String getKeyPassword()
+ {
+ if(keyPassword != null)
+ {
+ return keyPassword;
+ }
+
+ if(config != null)
+ {
+ String passwd = (String)config.get(KEY_PASSWORD);
+ if(passwd != null && passwd.length() > 0)
+ {
+ keyPassword = passwd;
+ }
+ }
+
+ return keyPassword;
+ }
+
+ /**
+ * @see org.jboss.remoting.security.SSLSocketBuilderMBean#setKeyPassword(java.lang.String)
+ */
+ public void setKeyPassword(String keyPassword)
+ {
+ this.keyPassword = keyPassword;
+ }
+
+ /**
+ * @see org.jboss.remoting.security.SSLSocketBuilderMBean#isSocketUseClientMode()
+ */
+ public boolean isSocketUseClientMode( )
+ {
+ if (socketUseClientMode == null)
+ {
+ if (config != null && config.containsKey(SSL_USE_CLIENT_MODE))
+ {
+ socketUseClientMode = Boolean.valueOf((String) config.get(SSL_USE_CLIENT_MODE));
+ }
+ else
+ {
+ socketUseClientMode = Boolean.TRUE;
+ }
+ }
+
+ return socketUseClientMode.booleanValue();
+ }
+
+ /**
+ * @see org.jboss.remoting.security.SSLSocketBuilderMBean#isServerSocketUseClientMode()
+ */
+ public boolean isServerSocketUseClientMode( )
+ {
+ if (serverSocketUseClientMode == null)
+ {
+ if (config != null && config.containsKey(SERVER_SSL_USE_CLIENT_MODE))
+ {
+ serverSocketUseClientMode = Boolean.valueOf((String) config.get(SERVER_SSL_USE_CLIENT_MODE));
+ }
+ else
+ {
+ serverSocketUseClientMode = Boolean.FALSE;
+ }
+ }
+
+ return serverSocketUseClientMode.booleanValue();
+ }
+
+ /**
+ * @see org.jboss.remoting.security.SSLSocketBuilderMBean#setSocketUseClientMode(boolean)
+ */
+ public void setSocketUseClientMode( boolean useClientMode )
+ {
+ this.socketUseClientMode = Boolean.valueOf(useClientMode);
+ }
+
+ /**
+ * @see org.jboss.remoting.security.SSLSocketBuilderMBean#setServerSocketUseClientMode(boolean)
+ */
+ public void setServerSocketUseClientMode( boolean useClientMode )
+ {
+ this.serverSocketUseClientMode = Boolean.valueOf(useClientMode);
+ }
+
+ /**
+ * @see org.jboss.remoting.security.SSLSocketBuilderMBean#isServerAuthMode()
+ */
+ public boolean isServerAuthMode()
+ {
+ if (serverAuthMode == null)
+ {
+ if (config != null && config.containsKey(SSL_SERVER_AUTH_MODE))
+ {
+ serverAuthMode = Boolean.valueOf( (String) config.get(SSL_SERVER_AUTH_MODE) );
+ }
+ else
+ {
+ serverAuthMode = Boolean.TRUE;
+ }
+ }
+
+ return serverAuthMode.booleanValue();
+ }
+
+ /**
+ * @see org.jboss.remoting.security.SSLSocketBuilderMBean#setServerAuthMode(boolean)
+ */
+ public void setServerAuthMode(boolean mode)
+ {
+ serverAuthMode = Boolean.valueOf(mode);
+ }
+
+ /**
+ * Creates (but does not initialize) the SSL context used by this object
+ * to create server socket factories.
+ * The provider/protocol is used to determine what SSL context to use.
+ * Call {@link #initializeServerSocketFactorySSLContext()} if you want
+ * to create and initialize in one method call.
+ * If the server socket factory SSL context was already created, this will create
+ * a new one and remove the old one.
+ *
+ * @throws IOException
+ */
+ protected void createServerSocketFactorySSLContext()
+ throws IOException
+ {
+ try
+ {
+ if(getProvider() != null)
+ {
+ sslContextServerSocketFactory = SSLContext.getInstance(getSecureSocketProtocol(), getProvider());
+ }
+ else if(getProviderName() != null)
+ {
+ sslContextServerSocketFactory = SSLContext.getInstance(getSecureSocketProtocol(), getProviderName());
+ }
+ else
+ {
+ sslContextServerSocketFactory = SSLContext.getInstance(getSecureSocketProtocol());
+ }
+ }
+ catch(Exception e)
+ {
+ IOException ioe = new IOException("Error creating server socket factory SSL context: " + e.getMessage());
+ ioe.setStackTrace(e.getStackTrace());
+ throw ioe;
+ }
+
+ return;
+ }
+
+ /**
+ * Creates (but does not initialize) the SSL context used by this object
+ * to create socket factories.
+ * The provider/protocol is used to determine what SSL context to use.
+ * Call {@link #initializeSocketFactorySSLContext()} if you want
+ * to create and initialize in one method call.
+ * If the socket factory SSL context was already created, this will create
+ * a new one and remove the old one.
+ *
+ * @throws IOException
+ */
+ protected void createSocketFactorySSLContext()
+ throws IOException
+ {
+ try
+ {
+ if(getProvider() != null)
+ {
+ sslContextSocketFactory = SSLContext.getInstance(getSecureSocketProtocol(), getProvider());
+ }
+ else if(getProviderName() != null)
+ {
+ sslContextSocketFactory = SSLContext.getInstance(getSecureSocketProtocol(), getProviderName());
+ }
+ else
+ {
+ sslContextSocketFactory = SSLContext.getInstance(getSecureSocketProtocol());
+ }
+ }
+ catch(Exception e)
+ {
+ IOException ioe = new IOException("Error creating socket factory SSL context: " + e.getMessage());
+ ioe.setStackTrace(e.getStackTrace());
+ throw ioe;
+ }
+
+ return;
+ }
+
+ /**
+ * Initializes the SSL context used by this object that will create the server socket factories.
+ * If the SSL context is not yet created, this method will also create it.
+ * The provider/protocol is used to determine what SSL context to use. Key and trust managers
+ * are loaded and a secure random object is created and the SSL context for the
+ * protocol/provider is initialized with them.
+ *
+ * @throws IOException
+ */
+ protected void initializeServerSocketFactorySSLContext()
+ throws IOException
+ {
+ try
+ {
+ if (sslContextServerSocketFactory == null)
+ {
+ createServerSocketFactorySSLContext();
+ }
+
+ try
+ {
+ keyManagers = loadKeyManagers();
+ }
+ catch (NullStoreURLException e)
+ {
+ if (isServerSocketUseClientMode())
+ {
+ keyManagers = null;
+ log.debug("Could not find keytore url. " + e.getMessage());
+ }
+ else
+ {
+ // because this ssl context will create server socket factories, will throw if can not find keystore
+ IOException ioe = new IOException("Can not find keystore url.");
+ ioe.initCause(e);
+ throw ioe;
+ }
+ }
+
+ try
+ {
+ boolean isClientMode = isServerSocketUseClientMode();
+ trustManagers = loadTrustManagers(isClientMode);
+ }
+ catch (NullStoreURLException e)
+ {
+ trustManagers = null;
+ log.debug("Could not find truststore url. " + e.getMessage());
+ }
+
+ secureRandom = getSecureRandom();
+
+ sslContextServerSocketFactory.init(keyManagers, trustManagers, secureRandom);
+ }
+ catch(Exception e)
+ {
+ IOException ioe = new IOException("Error initializing server socket factory SSL context: " + e.getMessage());
+ ioe.setStackTrace(e.getStackTrace());
+ throw ioe;
+ }
+
+ return;
+ }
+
+ /**
+ * Initializes the SSL context used by this object that will create the socket factories.
+ * If the SSL context is not yet created, this method will also create it.
+ * The provider/protocol is used to determine what SSL context to use. Key and trust managers
+ * are loaded and a secure random object is created and the SSL context for the
+ * protocol/provider is initialized with them.
+ *
+ * @throws IOException
+ */
+ protected void initializeSocketFactorySSLContext()
+ throws IOException
+ {
+ try
+ {
+ if (sslContextSocketFactory == null)
+ {
+ createSocketFactorySSLContext();
+ }
+
+ try
+ {
+ keyManagers = loadKeyManagers();
+ }
+ catch (NullStoreURLException e)
+ {
+ // this is allowable since would be the normal scenario
+ keyManagers = null;
+ log.debug("Could not find keystore url. " + e.getMessage());
+ }
+
+ try
+ {
+ boolean isClientMode = isSocketUseClientMode();
+ trustManagers = loadTrustManagers(isClientMode);
+ }
+ catch (NullStoreURLException e)
+ {
+ // If the keyManagers is not null, could possibly be using in client mode
+ // so want to allow it. Otherwise, need to throw exception as will not be able
+ // to use in client mode or not
+ if(keyManagers != null)
+ {
+ trustManagers = null;
+ log.debug("Could not find truststore url. " + e.getMessage());
+ }
+ else
+ {
+ IOException ioe = new IOException("Can not find truststore url.");
+ ioe.initCause(e);
+ throw ioe;
+ }
+ }
+
+ secureRandom = getSecureRandom();
+
+ sslContextSocketFactory.init(keyManagers, trustManagers, secureRandom);
+ }
+ catch(Exception e)
+ {
+ IOException ioe = new IOException("Error initializing socket factory SSL context: " + e.getMessage());
+ ioe.setStackTrace(e.getStackTrace());
+ throw ioe;
+ }
+
+ return;
+ }
+
+ /**
+ * Loads the trust managers based on this object's truststore.
+ *
+ * @return array of trust managers that should be loaded in this object's SSL context
+ *
+ * @throws NoSuchProviderException
+ * @throws NoSuchAlgorithmException
+ * @throws IOException
+ * @throws CertificateException
+ * @throws KeyStoreException
+ * @throws NullStoreURLException
+ */
+ protected TrustManager[] loadTrustManagers(boolean isClientMode)
+ throws NoSuchProviderException, NoSuchAlgorithmException, IOException, CertificateException, KeyStoreException, NullStoreURLException
+ {
+ if(isClientMode && !isServerAuthMode())
+ {
+ // we are in client mode and do not want to perform server cert authentication
+ // return a trust manager that trusts all certs
+ trustManagers = new TrustManager[] {
+ new X509TrustManager() {
+ public void checkClientTrusted( X509Certificate[] chain, String authType ) {}
+ public void checkServerTrusted( X509Certificate[] chain, String authType ) {}
+ public X509Certificate[] getAcceptedIssuers() { return null; }
+ }};
+ }
+ else
+ {
+ String tsType = getTrustStoreType();
+ String tsPasswd = getTrustStorePassword();
+ URL tsPathURL = getTrustStore();
+
+ String tsAlg = getTrustStoreAlgorithm();
+
+ TrustManagerFactory trustMgrFactory;
+ KeyStore trustStore = loadKeyStore(tsType, tsPathURL, tsPasswd);
+
+ if (getProvider() != null)
+ {
+ trustMgrFactory = TrustManagerFactory.getInstance(tsAlg, getProvider());
+ }
+ else if (getProviderName() != null)
+ {
+ trustMgrFactory = TrustManagerFactory.getInstance(tsAlg, getProviderName());
+ }
+ else
+ {
+ trustMgrFactory = TrustManagerFactory.getInstance(tsAlg);
+ }
+
+ if (trustStore != null)
+ {
+ trustMgrFactory.init(trustStore);
+
+ trustManagers = trustMgrFactory.getTrustManagers();
+ }
+ }
+
+ return trustManagers;
+ }
+
+ /**
+ * Loads the key managers based on this object's truststore.
+ *
+ * @return array of key managers that should be loaded in this object's SSL context
+ *
+ * @throws NoSuchProviderException
+ * @throws NoSuchAlgorithmException
+ * @throws IOException
+ * @throws CertificateException
+ * @throws KeyStoreException
+ * @throws UnrecoverableKeyException
+ * @throws NullStoreURLException
+ */
+ protected KeyManager[] loadKeyManagers()
+ throws NoSuchProviderException, NoSuchAlgorithmException, IOException, CertificateException,
+ KeyStoreException, UnrecoverableKeyException, NullStoreURLException
+ {
+ String ksPasswd = getKeyStorePassword();
+ String ksType = getKeyStoreType();
+ URL ksPathURL = getKeyStore();
+
+ KeyStore keyStore = loadKeyStore(ksType, ksPathURL, ksPasswd);
+
+ if(keyStore != null)
+ {
+ String alias = getKeyAlias();
+
+ // check that keystore contains supplied alias (if there is one)
+ if(alias != null)
+ {
+ boolean containsAlias = keyStore.isKeyEntry(alias);
+ if(!containsAlias)
+ {
+ // can not continue as supplied alias does not exist as key entry
+ throw new IOException("Can not find key entry for key store (" + ksPathURL + ") with given alias (" + alias + ")");
+ }
+ }
+
+ KeyManagerFactory keyMgrFactory = null;
+ String alg = getKeyStoreAlgorithm();
+
+ if(getProvider() != null)
+ {
+ keyMgrFactory = KeyManagerFactory.getInstance(alg, getProvider());
+ }
+ else if(getProviderName() != null)
+ {
+ keyMgrFactory = KeyManagerFactory.getInstance(alg, getProviderName());
+ }
+ else
+ {
+ keyMgrFactory = KeyManagerFactory.getInstance(alg);
+ }
+
+ // get they key password, if it isn't defined, use the key store password
+ String keyPasswd = getKeyPassword();
+ if (keyPasswd == null || keyPasswd.length() == 0)
+ {
+ keyPasswd = ksPasswd;
+ }
+
+ keyMgrFactory.init(keyStore, keyPasswd.toCharArray());
+ keyManagers = keyMgrFactory.getKeyManagers();
+
+ // if alias provided, use helper impl to hard wire alias name to be used
+ if(alias != null)
+ {
+ //TODO: -TME Need careful review of if this is really needed or not.
+ for(int x = 0; x < keyManagers.length; x++)
+ {
+ keyManagers[x] = new JBossWSKeyManager((X509KeyManager)keyManagers[x], alias);
+ }
+ }
+
+ }
+ return keyManagers;
+ }
+
+ /**
+ * Loads a key store file and returns it.
+ *
+ * @param storeType the type of store file
+ * @param storePathURL the URL to the file - may be relative to the current thread's classloader
+ * or may be absolute path to a file on the file system.
+ * @param storePassword password to gain access to the store file
+ *
+ * @return the key store
+ *
+ * @throws KeyStoreException
+ * @throws NoSuchProviderException
+ * @throws IOException
+ * @throws NoSuchAlgorithmException
+ * @throws CertificateException
+ * @throws NullStoreURLException
+ */
+ protected KeyStore loadKeyStore(String storeType, URL storePathURL, String storePassword)
+ throws KeyStoreException, NoSuchProviderException, IOException, NoSuchAlgorithmException, CertificateException, NullStoreURLException
+ {
+ KeyStore keyStore = null;
+
+ if(getProvider() != null)
+ {
+ keyStore = KeyStore.getInstance(storeType, getProvider());
+ }
+ else if(getProviderName() != null)
+ {
+ keyStore = KeyStore.getInstance(storeType, getProviderName());
+ }
+ else
+ {
+ keyStore = KeyStore.getInstance(storeType);
+ }
+
+ if ( storePathURL == null )
+ {
+ throw new NullStoreURLException("Can not find store file for url because store url is null.");
+ }
+
+ // now that keystore instance created, need to load data from file
+ InputStream keyStoreInputStream = null;
+
+ try
+ {
+ keyStoreInputStream = storePathURL.openStream();
+
+ // is ok for password to be null, as will just be used to check integrity of store
+ char[] password = storePassword != null ? storePassword.toCharArray() : null;
+ keyStore.load(keyStoreInputStream, password);
+ }
+ finally
+ {
+ if(keyStoreInputStream != null)
+ {
+ try
+ {
+ keyStoreInputStream.close();
+ }
+ catch(IOException e)
+ {
+ // no op
+ }
+ keyStoreInputStream = null;
+ }
+ }
+
+ return keyStore;
+ }
+
+ /**
+ * Given a store file path, this will verify that the store actually exists.
+ * First, it checks to see if its a valid URL, then it checks to see if the
+ * file path is found in the file system and finally will be checked to see
+ * if it can be found as a resource within the current thread's classloader.
+ * An exception is thrown if the store cannot be found.
+ *
+ * @param storePath the path which can be a URL, path to a resource in classloader
+ * or a file path on the file system.
+ *
+ * @return the URL of the file that was found
+ *
+ * @throws IOException if the store could not be found
+ */
+ protected URL validateStoreURL(String storePath) throws IOException
+ {
+ URL url = null;
+
+ // First see if this is a URL
+ try
+ {
+ url = new URL(storePath);
+ }
+ catch(MalformedURLException e)
+ {
+ // Not a URL or a protocol without a handler so...
+ // next try to locate this as file path
+ File tst = new File(storePath);
+
+ if(tst.exists() == true)
+ {
+ url = tst.toURL();
+ }
+ else
+ {
+ // not a file either, lastly try to locate this as a classpath resource
+ if(url == null)
+ {
+ ClassLoader loader = Thread.currentThread().getContextClassLoader();
+ url = loader.getResource(storePath);
+ }
+ }
+ }
+
+ // Fail if no valid key store was located
+ if(url == null)
+ {
+ String msg = "Failed to find url=" + storePath + " as a URL, file or resource";
+ throw new MalformedURLException(msg);
+ }
+
+ return url;
+ }
+
+ /**
+ * Used to indicate a store URL was not specified and thus the store is not available.
+ */
+ protected class NullStoreURLException extends Exception
+ {
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * @see Exception#Exception(String)
+ */
+ public NullStoreURLException(String message)
+ {
+ super(message);
+ }
+ }
+}
\ No newline at end of file
Modified: stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxws/binding/HTTPMessageMarshaller.java
===================================================================
--- stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxws/binding/HTTPMessageMarshaller.java 2009-07-04 14:37:52 UTC (rev 10314)
+++ stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxws/binding/HTTPMessageMarshaller.java 2009-07-04 14:44:05 UTC (rev 10315)
@@ -25,15 +25,14 @@
import java.io.OutputStream;
import org.jboss.logging.Logger;
-import org.jboss.remoting.InvocationRequest;
-import org.jboss.remoting.invocation.OnewayInvocation;
-import org.jboss.remoting.marshal.Marshaller;
import org.jboss.ws.core.HTTPMessageImpl;
+import org.jboss.ws.core.client.Marshaller;
import org.jboss.wsf.common.DOMWriter;
import org.w3c.dom.Element;
/**
* @author Thomas.Diesler(a)jboss.org
+ * @author alessio.soldano(a)jboss.com
* @since 25-Nov-2004
*/
public class HTTPMessageMarshaller implements Marshaller
@@ -52,12 +51,6 @@
*/
public void write(Object dataObject, OutputStream output) throws IOException
{
- if (dataObject instanceof InvocationRequest)
- dataObject = ((InvocationRequest)dataObject).getParameter();
-
- if (dataObject instanceof OnewayInvocation)
- dataObject = ((OnewayInvocation)dataObject).getParameters()[0];
-
if ((dataObject instanceof HTTPMessageImpl) == false)
throw new IllegalArgumentException("Not a HTTPMessage: " + dataObject);
@@ -72,9 +65,4 @@
new DOMWriter(output).print(root);
}
-
- public Marshaller cloneMarshaller() throws CloneNotSupportedException
- {
- return new HTTPMessageMarshaller();
- }
}
Modified: stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxws/binding/HTTPMessageUnMarshaller.java
===================================================================
--- stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxws/binding/HTTPMessageUnMarshaller.java 2009-07-04 14:37:52 UTC (rev 10314)
+++ stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxws/binding/HTTPMessageUnMarshaller.java 2009-07-04 14:44:05 UTC (rev 10315)
@@ -24,7 +24,6 @@
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
-import java.util.Iterator;
import java.util.List;
import java.util.Map;
@@ -32,10 +31,10 @@
import javax.xml.soap.MimeHeaders;
import org.jboss.logging.Logger;
-import org.jboss.remoting.marshal.UnMarshaller;
-import org.jboss.remoting.transport.http.HTTPMetadataConstants;
import org.jboss.ws.WSException;
import org.jboss.ws.core.HTTPMessageImpl;
+import org.jboss.ws.core.client.NettyClient;
+import org.jboss.ws.core.client.UnMarshaller;
/**
* @author Thomas.Diesler(a)jboss.org
@@ -46,7 +45,7 @@
// Provide logging
private static Logger log = Logger.getLogger(HTTPMessageUnMarshaller.class);
- private static List validResponseCodes = new ArrayList();
+ private static List<Integer> validResponseCodes = new ArrayList<Integer>();
static
{
validResponseCodes.add(HttpServletResponse.SC_OK);
@@ -54,15 +53,15 @@
validResponseCodes.add(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
}
- public Object read(InputStream inputStream, Map metadata) throws IOException, ClassNotFoundException
+ public Object read(InputStream inputStream, Map<String, Object> metadata) throws IOException
{
if (log.isTraceEnabled())
{
log.trace("Read input stream with metadata=" + metadata);
}
- Integer resCode = (Integer)metadata.get(HTTPMetadataConstants.RESPONSE_CODE);
- String resMessage = (String)metadata.get(HTTPMetadataConstants.RESPONSE_CODE_MESSAGE);
+ Integer resCode = (Integer)metadata.get(NettyClient.RESPONSE_CODE);
+ String resMessage = (String)metadata.get(NettyClient.RESPONSE_CODE_MESSAGE);
if (resCode != null && validResponseCodes.contains(resCode) == false)
throw new WSException("Invalid HTTP server response [" + resCode + "] - " + resMessage);
@@ -71,37 +70,17 @@
return soapMsg;
}
- /**
- * Set the class loader to use for unmarhsalling. This may
- * be needed when need to have access to class definitions that
- * are not part of this unmarshaller's parent classloader (especially
- * when doing remote classloading).
- *
- * @param classloader
- */
- public void setClassLoader(ClassLoader classloader)
+ private MimeHeaders getMimeHeaders(Map<String, Object> metadata)
{
- //NO OP
- }
-
- public UnMarshaller cloneUnMarshaller() throws CloneNotSupportedException
- {
- return new HTTPMessageUnMarshaller();
- }
-
- private MimeHeaders getMimeHeaders(Map metadata)
- {
log.debug("getMimeHeaders from: " + metadata);
MimeHeaders headers = new MimeHeaders();
- Iterator i = metadata.keySet().iterator();
- while (i.hasNext())
+ for (String key : metadata.keySet())
{
- String key = (String)i.next();
Object value = metadata.get(key);
if (key != null && value instanceof List)
{
- for (Object listValue : (List)value)
+ for (Object listValue : (List<?>)value)
{
headers.addHeader(key, listValue.toString());
}
Modified: stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxws/binding/JsonMessageMarshaller.java
===================================================================
--- stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxws/binding/JsonMessageMarshaller.java 2009-07-04 14:37:52 UTC (rev 10314)
+++ stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxws/binding/JsonMessageMarshaller.java 2009-07-04 14:44:05 UTC (rev 10315)
@@ -28,23 +28,18 @@
import javax.xml.soap.SOAPException;
import javax.xml.soap.SOAPMessage;
-import org.jboss.logging.Logger;
-import org.jboss.remoting.InvocationRequest;
-import org.jboss.remoting.invocation.OnewayInvocation;
-import org.jboss.remoting.marshal.Marshaller;
+import org.jboss.ws.core.client.Marshaller;
import org.jboss.ws.core.soap.SOAPBodyImpl;
import org.jboss.ws.core.soap.SOAPMessageImpl;
import org.jboss.ws.extensions.json.BadgerFishDOMDocumentSerializer;
/**
* @author Thomas.Diesler(a)jboss.org
+ * @author alessio.soldano(a)jboss.com
* @since 25-Nov-2004
*/
public class JsonMessageMarshaller implements Marshaller
{
- // Provide logging
- private static Logger log = Logger.getLogger(JsonMessageMarshaller.class);
-
/**
* Marshaller will need to take the dataObject and convert
* into primitive java data types and write to the
@@ -56,12 +51,6 @@
*/
public void write(Object dataObject, OutputStream output) throws IOException
{
- if (dataObject instanceof InvocationRequest)
- dataObject = ((InvocationRequest)dataObject).getParameter();
-
- if (dataObject instanceof OnewayInvocation)
- dataObject = ((OnewayInvocation)dataObject).getParameters()[0];
-
// TODO: this should not be a SOAP message
if ((dataObject instanceof SOAPMessageImpl) == false)
throw new IllegalArgumentException("Not a SOAPMessageImpl: " + dataObject);
@@ -80,9 +69,4 @@
throw ioex;
}
}
-
- public Marshaller cloneMarshaller() throws CloneNotSupportedException
- {
- return new JsonMessageMarshaller();
- }
}
Modified: stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxws/binding/JsonMessageUnMarshaller.java
===================================================================
--- stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxws/binding/JsonMessageUnMarshaller.java 2009-07-04 14:37:52 UTC (rev 10314)
+++ stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxws/binding/JsonMessageUnMarshaller.java 2009-07-04 14:44:05 UTC (rev 10315)
@@ -23,16 +23,13 @@
import java.io.IOException;
import java.io.InputStream;
-import java.util.Iterator;
-import java.util.List;
import java.util.Map;
-import javax.xml.soap.MimeHeaders;
import javax.xml.soap.SOAPException;
import javax.xml.soap.SOAPMessage;
import org.jboss.logging.Logger;
-import org.jboss.remoting.marshal.UnMarshaller;
+import org.jboss.ws.core.client.UnMarshaller;
import org.jboss.ws.core.soap.MessageFactoryImpl;
import org.jboss.ws.extensions.json.BadgerFishDOMDocumentParser;
import org.w3c.dom.Document;
@@ -46,7 +43,7 @@
// Provide logging
private static Logger log = Logger.getLogger(JsonMessageUnMarshaller.class);
- public Object read(InputStream inputStream, Map metadata) throws IOException, ClassNotFoundException
+ public Object read(InputStream inputStream, Map<String, Object> metadata) throws IOException
{
if (log.isTraceEnabled())
{
@@ -69,43 +66,4 @@
throw ioex;
}
}
-
- /**
- * Set the class loader to use for unmarhsalling. This may
- * be needed when need to have access to class definitions that
- * are not part of this unmarshaller's parent classloader (especially
- * when doing remote classloading).
- *
- * @param classloader
- */
- public void setClassLoader(ClassLoader classloader)
- {
- //NO OP
- }
-
- public UnMarshaller cloneUnMarshaller() throws CloneNotSupportedException
- {
- return new JsonMessageUnMarshaller();
- }
-
- private MimeHeaders getMimeHeaders(Map metadata)
- {
- log.debug("getMimeHeaders from: " + metadata);
-
- MimeHeaders headers = new MimeHeaders();
- Iterator i = metadata.keySet().iterator();
- while (i.hasNext())
- {
- String key = (String)i.next();
- Object value = metadata.get(key);
- if (key != null && value instanceof List)
- {
- for (Object listValue : (List)value)
- {
- headers.addHeader(key, listValue.toString());
- }
- }
- }
- return headers;
- }
}
Modified: stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxws/client/ClientImpl.java
===================================================================
--- stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxws/client/ClientImpl.java 2009-07-04 14:37:52 UTC (rev 10314)
+++ stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxws/client/ClientImpl.java 2009-07-04 14:44:05 UTC (rev 10315)
@@ -49,11 +49,11 @@
import javax.xml.ws.soap.SOAPBinding;
import javax.xml.ws.soap.SOAPFaultException;
-import org.jboss.remoting.transport.http.HTTPMetadataConstants;
import org.jboss.util.NotImplementedException;
import org.jboss.ws.core.CommonBindingProvider;
import org.jboss.ws.core.CommonClient;
import org.jboss.ws.core.CommonMessageContext;
+import org.jboss.ws.core.client.NettyClient;
import org.jboss.ws.core.jaxws.binding.BindingExt;
import org.jboss.ws.core.jaxws.binding.BindingProviderImpl;
import org.jboss.ws.core.jaxws.handler.HandlerChainExecutor;
@@ -216,7 +216,7 @@
Map<?, ?> remotingMetadata = (Map)msgContext.get(CommonMessageContext.REMOTING_METADATA);
// Get the HTTP_RESPONSE_CODE
- Integer resposeCode = (Integer)remotingMetadata.get(HTTPMetadataConstants.RESPONSE_CODE);
+ Integer resposeCode = (Integer)remotingMetadata.get(NettyClient.RESPONSE_CODE);
if (resposeCode != null)
msgContext.put(MessageContextJAXWS.HTTP_RESPONSE_CODE, resposeCode);
Modified: stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/soap/EnvelopeBuilderDOM.java
===================================================================
--- stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/soap/EnvelopeBuilderDOM.java 2009-07-04 14:37:52 UTC (rev 10314)
+++ stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/soap/EnvelopeBuilderDOM.java 2009-07-04 14:44:05 UTC (rev 10315)
@@ -89,6 +89,7 @@
{
return null;
}
+ log.error("Exception while building envelope", ex);
QName faultCode = Constants.SOAP11_FAULT_CODE_CLIENT;
throw new CommonSOAPFaultException(faultCode, ex.getMessage());
}
Modified: stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/soap/FastInfosetMarshaller.java
===================================================================
--- stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/soap/FastInfosetMarshaller.java 2009-07-04 14:37:52 UTC (rev 10314)
+++ stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/soap/FastInfosetMarshaller.java 2009-07-04 14:44:05 UTC (rev 10315)
@@ -28,14 +28,13 @@
import javax.xml.soap.SOAPException;
import javax.xml.soap.SOAPMessage;
-import org.jboss.remoting.InvocationRequest;
-import org.jboss.remoting.invocation.OnewayInvocation;
-import org.jboss.remoting.marshal.Marshaller;
+import org.jboss.ws.core.client.Marshaller;
import com.sun.xml.fastinfoset.dom.DOMDocumentSerializer;
/**
* @author Thomas.Diesler(a)jboss.org
+ * @author alessio.soldano(a)jboss.com
* @since 12-Mar-2008
*/
public class FastInfosetMarshaller implements Marshaller
@@ -51,12 +50,6 @@
*/
public void write(Object dataObject, OutputStream output) throws IOException
{
- if (dataObject instanceof InvocationRequest)
- dataObject = ((InvocationRequest)dataObject).getParameter();
-
- if (dataObject instanceof OnewayInvocation)
- dataObject = ((OnewayInvocation)dataObject).getParameters()[0];
-
if ((dataObject instanceof SOAPMessage) == false)
throw new IllegalArgumentException("Not a SOAPMessage: " + dataObject);
@@ -78,9 +71,4 @@
throw ioex;
}
}
-
- public Marshaller cloneMarshaller() throws CloneNotSupportedException
- {
- return new FastInfosetMarshaller();
- }
}
Modified: stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/soap/SOAPConnectionImpl.java
===================================================================
--- stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/soap/SOAPConnectionImpl.java 2009-07-04 14:37:52 UTC (rev 10314)
+++ stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/soap/SOAPConnectionImpl.java 2009-07-04 14:44:05 UTC (rev 10315)
@@ -84,7 +84,7 @@
if (reqMessage == null)
throw new IllegalArgumentException("Given SOAPMessage cannot be null");
- MessageAbstraction resMessage = callInternal(reqMessage, endpoint, true);
+ MessageAbstraction resMessage = callInternal(reqMessage, endpoint, false);
return (SOAPMessage)resMessage;
}
@@ -140,7 +140,7 @@
try
{
remotingConnection = getRemotingConnection(endpoint);
- MessageAbstraction resMessage = remotingConnection.invoke((SOAPMessageImpl)reqMessage, endpoint, oneway);
+ MessageAbstraction resMessage = remotingConnection.invoke((SOAPMessageImpl)reqMessage, endpoint, oneway, false);
return resMessage;
}
catch (Exception ex)
Modified: stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/soap/SOAPMessageMarshaller.java
===================================================================
--- stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/soap/SOAPMessageMarshaller.java 2009-07-04 14:37:52 UTC (rev 10314)
+++ stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/soap/SOAPMessageMarshaller.java 2009-07-04 14:44:05 UTC (rev 10315)
@@ -27,12 +27,11 @@
import javax.xml.soap.SOAPMessage;
import org.jboss.logging.Logger;
-import org.jboss.remoting.InvocationRequest;
-import org.jboss.remoting.invocation.OnewayInvocation;
-import org.jboss.remoting.marshal.Marshaller;
+import org.jboss.ws.core.client.Marshaller;
/**
* @author Thomas.Diesler(a)jboss.org
+ * @author alessio.soldano(a)jboss.com
* @since 25-Nov-2004
*/
public class SOAPMessageMarshaller implements Marshaller
@@ -51,21 +50,10 @@
*/
public void write(Object dataObject, OutputStream output) throws IOException
{
- if (dataObject instanceof InvocationRequest)
- dataObject = ((InvocationRequest)dataObject).getParameter();
-
- if (dataObject instanceof OnewayInvocation)
- dataObject = ((OnewayInvocation)dataObject).getParameters()[0];
-
if ((dataObject instanceof SOAPMessage) == false)
throw new IllegalArgumentException("Not a SOAPMessage: " + dataObject);
SOAPMessageImpl soapMessage = (SOAPMessageImpl)dataObject;
soapMessage.writeTo(output);
}
-
- public Marshaller cloneMarshaller() throws CloneNotSupportedException
- {
- return new SOAPMessageMarshaller();
- }
}
Modified: stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/soap/SOAPMessageUnMarshaller.java
===================================================================
--- stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/soap/SOAPMessageUnMarshaller.java 2009-07-04 14:37:52 UTC (rev 10314)
+++ stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/soap/SOAPMessageUnMarshaller.java 2009-07-04 14:44:05 UTC (rev 10315)
@@ -29,10 +29,11 @@
import javax.xml.soap.SOAPMessage;
import org.jboss.logging.Logger;
-import org.jboss.remoting.marshal.UnMarshaller;
+import org.jboss.ws.core.client.UnMarshaller;
/**
* @author Thomas.Diesler(a)jboss.org
+ * @author alessio.soldano(a)jboss.com
* @since 25-Nov-2004
*/
public class SOAPMessageUnMarshaller implements UnMarshaller
@@ -40,7 +41,7 @@
// Provide logging
private static Logger log = Logger.getLogger(SOAPMessageUnMarshaller.class);
- public Object read(InputStream inputStream, Map metadata) throws IOException, ClassNotFoundException
+ public Object read(InputStream inputStream, Map<String, Object> metadata) throws IOException
{
if (log.isTraceEnabled())
log.trace("Read input stream with metadata=" + metadata);
@@ -64,13 +65,4 @@
{
return new MessageFactoryImpl();
}
-
- public void setClassLoader(ClassLoader classloader)
- {
- }
-
- public UnMarshaller cloneUnMarshaller() throws CloneNotSupportedException
- {
- return new SOAPMessageUnMarshaller();
- }
}
Modified: stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/soap/SOAPMessageUnMarshallerHTTP.java
===================================================================
--- stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/soap/SOAPMessageUnMarshallerHTTP.java 2009-07-04 14:37:52 UTC (rev 10314)
+++ stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/soap/SOAPMessageUnMarshallerHTTP.java 2009-07-04 14:44:05 UTC (rev 10315)
@@ -24,7 +24,6 @@
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
-import java.util.Iterator;
import java.util.List;
import java.util.Map;
@@ -34,12 +33,13 @@
import javax.xml.soap.SOAPMessage;
import org.jboss.logging.Logger;
-import org.jboss.remoting.marshal.UnMarshaller;
-import org.jboss.remoting.transport.http.HTTPMetadataConstants;
import org.jboss.ws.WSException;
+import org.jboss.ws.core.client.NettyClient;
+import org.jboss.ws.core.client.UnMarshaller;
/**
* @author Thomas.Diesler(a)jboss.org
+ * @author alessio.soldano(a)jboss.com
* @since 25-Nov-2004
*/
public class SOAPMessageUnMarshallerHTTP implements UnMarshaller
@@ -47,7 +47,7 @@
// Provide logging
private static Logger log = Logger.getLogger(SOAPMessageUnMarshallerHTTP.class);
- private static List validResponseCodes = new ArrayList();
+ private static List<Integer> validResponseCodes = new ArrayList<Integer>();
static
{
validResponseCodes.add(HttpServletResponse.SC_OK);
@@ -56,21 +56,21 @@
validResponseCodes.add(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
}
- public Object read(InputStream inputStream, Map metadata) throws IOException, ClassNotFoundException
+ public Object read(InputStream inputStream, Map<String, Object> metadata) throws IOException
{
if (log.isTraceEnabled())
log.trace("Read input stream with metadata=" + metadata);
try
{
- Integer resCode = (Integer)metadata.get(HTTPMetadataConstants.RESPONSE_CODE);
+ Integer resCode = (Integer)metadata.get(NettyClient.RESPONSE_CODE);
if (resCode == null)
{
log.warn("No HTTP resonse code, assuming: SC_OK");
resCode = HttpServletResponse.SC_OK;
}
- String resMessage = (String)metadata.get(HTTPMetadataConstants.RESPONSE_CODE_MESSAGE);
+ String resMessage = (String)metadata.get("ResponseCodeMessage");
if (validResponseCodes.contains(resCode) == false)
throw new WSException("Invalid HTTP server response [" + resCode + "] - " + resMessage);
@@ -98,37 +98,17 @@
return new MessageFactoryImpl();
}
- /**
- * Set the class loader to use for unmarhsalling. This may
- * be needed when need to have access to class definitions that
- * are not part of this unmarshaller's parent classloader (especially
- * when doing remote classloading).
- *
- * @param classloader
- */
- public void setClassLoader(ClassLoader classloader)
+ private MimeHeaders getMimeHeaders(Map<String, Object> metadata)
{
- //NO OP
- }
-
- public UnMarshaller cloneUnMarshaller() throws CloneNotSupportedException
- {
- return new SOAPMessageUnMarshallerHTTP();
- }
-
- private MimeHeaders getMimeHeaders(Map metadata)
- {
log.debug("getMimeHeaders from: " + metadata);
MimeHeaders headers = new MimeHeaders();
- Iterator i = metadata.keySet().iterator();
- while (i.hasNext())
+ for (String key : metadata.keySet())
{
- String key = (String)i.next();
Object value = metadata.get(key);
if (key != null && value instanceof List)
{
- for (Object listValue : (List)value)
+ for (Object listValue : (List<?>)value)
{
headers.addHeader(key, listValue.toString());
}
Modified: stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/utils/ThreadLocalAssociation.java
===================================================================
--- stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/utils/ThreadLocalAssociation.java 2009-07-04 14:37:52 UTC (rev 10314)
+++ stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/utils/ThreadLocalAssociation.java 2009-07-04 14:44:05 UTC (rev 10315)
@@ -42,17 +42,17 @@
* SOAP message context
* @see org.jboss.ws.core.soap.MessageContextAssociation
*/
- private static ThreadLocal<Stack<CommonMessageContext>> msgContextAssoc = new ThreadLocal<Stack<CommonMessageContext>>();
+ private static ThreadLocal<Stack<CommonMessageContext>> msgContextAssoc = new InheritableThreadLocal<Stack<CommonMessageContext>>();
/**
* @see org.jboss.ws.extensions.security.STRTransform
*/
- private static ThreadLocal<SecurityStore> strTransformAssoc = new ThreadLocal<SecurityStore>();
+ private static ThreadLocal<SecurityStore> strTransformAssoc = new InheritableThreadLocal<SecurityStore>();
/**
* Public keys used to sign incoming message
*/
- private static ThreadLocal<List<PublicKey>> signatureKeysAssoc = new ThreadLocal<List<PublicKey>>();
+ private static ThreadLocal<List<PublicKey>> signatureKeysAssoc = new InheritableThreadLocal<List<PublicKey>>();
public static ThreadLocal<Stack<CommonMessageContext>> localMsgContextAssoc()
{
Modified: stack/native/trunk/modules/core/src/main/java/org/jboss/ws/extensions/wsrm/transport/RMChannelTask.java
===================================================================
--- stack/native/trunk/modules/core/src/main/java/org/jboss/ws/extensions/wsrm/transport/RMChannelTask.java 2009-07-04 14:37:52 UTC (rev 10314)
+++ stack/native/trunk/modules/core/src/main/java/org/jboss/ws/extensions/wsrm/transport/RMChannelTask.java 2009-07-04 14:44:05 UTC (rev 10315)
@@ -23,15 +23,13 @@
import java.io.IOException;
import java.net.URI;
+import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.Callable;
import org.jboss.logging.Logger;
-import org.jboss.remoting.CannotConnectException;
-import org.jboss.remoting.Client;
-import org.jboss.remoting.InvokerLocator;
-import org.jboss.remoting.marshal.MarshalFactory;
import org.jboss.ws.core.MessageTrace;
+import org.jboss.ws.core.client.NettyClient;
import org.jboss.ws.extensions.wsrm.RMClientSequence;
import org.jboss.ws.extensions.wsrm.transport.backchannel.RMCallbackHandler;
import org.jboss.ws.extensions.wsrm.transport.backchannel.RMCallbackHandlerFactory;
@@ -44,7 +42,6 @@
final class RMChannelTask implements Callable<RMChannelResponse>
{
private static final Logger logger = Logger.getLogger(RMChannelTask.class);
- private static final String JBOSSWS_SUBSYSTEM = "jbossws-wsrm";
private final RMMessage rmRequest;
RMChannelTask(RMMessage rmRequest)
@@ -58,14 +55,6 @@
try
{
String targetAddress = (String)rmRequest.getMetadata().getContext(RMChannelConstants.INVOCATION_CONTEXT).get(RMChannelConstants.TARGET_ADDRESS);
- String version = (String)rmRequest.getMetadata().getContext(RMChannelConstants.INVOCATION_CONTEXT).get(RMChannelConstants.REMOTING_VERSION);
-
- if (version.startsWith("1.4"))
- {
- MarshalFactory.addMarshaller("JBossWSMessage", RMMarshaller.getInstance(), RMUnMarshaller.getInstance());
- }
-
- InvokerLocator locator = new InvokerLocator(targetAddress);
URI backPort = RMTransportHelper.getBackPortURI(rmRequest);
String messageId = RMTransportHelper.getAddressingMessageId(rmRequest);
@@ -83,39 +72,19 @@
}
boolean oneWay = RMTransportHelper.isOneWayOperation(rmRequest);
- Client client = new Client(locator, JBOSSWS_SUBSYSTEM, rmRequest.getMetadata().getContext(RMChannelConstants.REMOTING_CONFIGURATION_CONTEXT));
- client.connect();
-
- client.setMarshaller(RMMarshaller.getInstance());
-
- if ((false == oneWay) && (null == backPort))
- client.setUnMarshaller(RMUnMarshaller.getInstance());
-
- Map<String, Object> remotingInvocationContext = rmRequest.getMetadata().getContext(RMChannelConstants.REMOTING_INVOCATION_CONTEXT);
-
- // debug the outgoing request message
- MessageTrace.traceMessage("Outgoing RM Request Message", rmRequest.getPayload());
-
+ NettyClient client = new NettyClient(RMMarshaller.getInstance(), RMUnMarshaller.getInstance());
+ Map<String, Object> additionalHeaders = rmRequest.getMetadata().getContext(RMChannelConstants.REMOTING_INVOCATION_CONTEXT);
+ Map<String, Object> callProps = new HashMap<String, Object>();
+ callProps.putAll(rmRequest.getMetadata().getContext(RMChannelConstants.INVOCATION_CONTEXT));
+
RMMessage rmResponse = null;
if (oneWay && (null == backPort))
{
- client.invokeOneway(rmRequest.getPayload(), remotingInvocationContext, false);
+ client.invoke(rmRequest.getPayload(), targetAddress, false, additionalHeaders, callProps);
}
else
{
- Object retVal = null;
- try
- {
- retVal = client.invoke(rmRequest.getPayload(), remotingInvocationContext);
- }
- catch (CannotConnectException cce)
- {
- // remoting hack - ignore NullPointerException cause
- if (false == (cce.getCause() instanceof NullPointerException))
- {
- throw cce;
- }
- }
+ Object retVal = client.invoke(rmRequest.getPayload(), targetAddress, true, additionalHeaders, callProps);
if ((null != retVal) && (false == (retVal instanceof RMMessage)))
{
String msg = retVal.getClass().getName() + ": '" + retVal + "'";
@@ -124,10 +93,8 @@
}
rmResponse = (RMMessage)retVal;
}
+ rmRequest.getMetadata().getContext(RMChannelConstants.INVOCATION_CONTEXT).putAll(callProps);
- // Disconnect the remoting client
- client.disconnect();
-
// trace the incomming response message
if ((rmResponse != null) && (backPort == null))
MessageTrace.traceMessage("Incoming RM Response Message", rmResponse.getPayload());
@@ -148,4 +115,4 @@
return new RMChannelResponse(t);
}
}
-}
+}
\ No newline at end of file
Modified: stack/native/trunk/modules/core/src/main/java/org/jboss/ws/extensions/wsrm/transport/RMMarshaller.java
===================================================================
--- stack/native/trunk/modules/core/src/main/java/org/jboss/ws/extensions/wsrm/transport/RMMarshaller.java 2009-07-04 14:37:52 UTC (rev 10314)
+++ stack/native/trunk/modules/core/src/main/java/org/jboss/ws/extensions/wsrm/transport/RMMarshaller.java 2009-07-04 14:44:05 UTC (rev 10315)
@@ -24,9 +24,7 @@
import java.io.IOException;
import java.io.OutputStream;
-import org.jboss.remoting.InvocationRequest;
-import org.jboss.remoting.invocation.OnewayInvocation;
-import org.jboss.remoting.marshal.Marshaller;
+import org.jboss.ws.core.client.Marshaller;
/**
* Marshalls byte array to the output stream
@@ -49,12 +47,6 @@
public void write(Object dataObject, OutputStream output) throws IOException
{
- if (dataObject instanceof InvocationRequest)
- dataObject = ((InvocationRequest)dataObject).getParameter();
-
- if (dataObject instanceof OnewayInvocation)
- dataObject = ((OnewayInvocation)dataObject).getParameters()[0];
-
if ((dataObject instanceof byte[]) == false)
throw new IllegalArgumentException("Not a byte array: " + dataObject);
Modified: stack/native/trunk/modules/core/src/main/java/org/jboss/ws/extensions/wsrm/transport/RMMessageAssembler.java
===================================================================
--- stack/native/trunk/modules/core/src/main/java/org/jboss/ws/extensions/wsrm/transport/RMMessageAssembler.java 2009-07-04 14:37:52 UTC (rev 10314)
+++ stack/native/trunk/modules/core/src/main/java/org/jboss/ws/extensions/wsrm/transport/RMMessageAssembler.java 2009-07-04 14:44:05 UTC (rev 10315)
@@ -28,9 +28,9 @@
import java.io.InputStream;
import java.util.Map;
-import org.jboss.remoting.marshal.Marshaller;
-import org.jboss.remoting.marshal.UnMarshaller;
import org.jboss.ws.core.MessageAbstraction;
+import org.jboss.ws.core.client.Marshaller;
+import org.jboss.ws.core.client.UnMarshaller;
/**
* Translates JBoss messages to RM sources and vice-versa.
Modified: stack/native/trunk/modules/core/src/main/java/org/jboss/ws/extensions/wsrm/transport/RMMetadata.java
===================================================================
--- stack/native/trunk/modules/core/src/main/java/org/jboss/ws/extensions/wsrm/transport/RMMetadata.java 2009-07-04 14:37:52 UTC (rev 10314)
+++ stack/native/trunk/modules/core/src/main/java/org/jboss/ws/extensions/wsrm/transport/RMMetadata.java 2009-07-04 14:44:05 UTC (rev 10315)
@@ -23,9 +23,10 @@
import java.util.Map;
import java.util.HashMap;
-import org.jboss.remoting.marshal.Marshaller;
-import org.jboss.remoting.marshal.UnMarshaller;
+import org.jboss.ws.core.client.Marshaller;
+import org.jboss.ws.core.client.UnMarshaller;
+
/**
* RM metadata heavily used by this RM transport
*
@@ -36,19 +37,16 @@
private Map<String, Map<String, Object>> contexts = new HashMap<String, Map<String, Object>>();
public RMMetadata(
- String remotingVersion,
String targetAddress,
Marshaller marshaller,
UnMarshaller unmarshaller,
Map<String, Object> invocationContext,
- Map<String, Object> remotingInvocationContext,
- Map<String, Object> remotingConfigurationContext)
+ Map<String, Object> remotingInvocationContext)
{
if (targetAddress == null)
throw new IllegalArgumentException("Target address cannot be null");
invocationContext.put(RMChannelConstants.TARGET_ADDRESS, targetAddress);
- invocationContext.put(RMChannelConstants.REMOTING_VERSION, remotingVersion);
setContext(RMChannelConstants.INVOCATION_CONTEXT, invocationContext);
if (marshaller == null || unmarshaller == null)
@@ -63,11 +61,6 @@
throw new IllegalArgumentException("Remoting invocation context cannot be null");
setContext(RMChannelConstants.REMOTING_INVOCATION_CONTEXT, remotingInvocationContext);
-
- if (remotingConfigurationContext == null)
- throw new IllegalArgumentException("Remoting configuraton context cannot be null");
-
- setContext(RMChannelConstants.REMOTING_CONFIGURATION_CONTEXT, remotingConfigurationContext);
}
public RMMetadata(Map<String, Object> remotingInvocationContext)
Modified: stack/native/trunk/modules/core/src/main/java/org/jboss/ws/extensions/wsrm/transport/RMSender.java
===================================================================
--- stack/native/trunk/modules/core/src/main/java/org/jboss/ws/extensions/wsrm/transport/RMSender.java 2009-07-04 14:37:52 UTC (rev 10314)
+++ stack/native/trunk/modules/core/src/main/java/org/jboss/ws/extensions/wsrm/transport/RMSender.java 2009-07-04 14:44:05 UTC (rev 10315)
@@ -33,7 +33,7 @@
import javax.servlet.http.HttpServletResponse;
import org.jboss.logging.Logger;
-import org.jboss.remoting.transport.http.HTTPMetadataConstants;
+import org.jboss.ws.core.client.NettyClient;
import org.jboss.ws.extensions.wsrm.api.RMException;
import org.jboss.ws.extensions.wsrm.config.RMMessageRetransmissionConfig;
@@ -124,7 +124,7 @@
Map<String, Object> remotingCtx = result.getResponse().getMetadata().getContext(RMChannelConstants.REMOTING_INVOCATION_CONTEXT);
if (remotingCtx != null)
{
- if (Integer.valueOf(HttpServletResponse.SC_INTERNAL_SERVER_ERROR).equals(remotingCtx.get(HTTPMetadataConstants.RESPONSE_CODE)))
+ if (Integer.valueOf(HttpServletResponse.SC_INTERNAL_SERVER_ERROR).equals(remotingCtx.get(NettyClient.RESPONSE_CODE)))
{
logger.debug("Response message received in " + (endTime - startTime) + " miliseconds, but contains internal server code, going to resend the request message");
continue;
Modified: stack/native/trunk/modules/core/src/main/java/org/jboss/ws/extensions/wsrm/transport/RMUnMarshaller.java
===================================================================
--- stack/native/trunk/modules/core/src/main/java/org/jboss/ws/extensions/wsrm/transport/RMUnMarshaller.java 2009-07-04 14:37:52 UTC (rev 10314)
+++ stack/native/trunk/modules/core/src/main/java/org/jboss/ws/extensions/wsrm/transport/RMUnMarshaller.java 2009-07-04 14:44:05 UTC (rev 10315)
@@ -26,7 +26,7 @@
import java.io.InputStream;
import java.util.Map;
-import org.jboss.remoting.marshal.UnMarshaller;
+import org.jboss.ws.core.client.UnMarshaller;
/**
* Unmarshalls byte array from the input stream
@@ -41,13 +41,13 @@
{
return getInstance();
}
-
+
public static UnMarshaller getInstance()
{
return instance;
}
-
- public Object read(InputStream is, Map metadata) throws IOException, ClassNotFoundException
+
+ public Object read(InputStream is, Map metadata) throws IOException
{
if (is == null)
return RMMessageFactory.newMessage(null, new RMMetadata(metadata)); // TODO: investigate why is == null (WSAddressing reply-to test)
@@ -64,10 +64,4 @@
return RMMessageFactory.newMessage(baos.toByteArray(), new RMMetadata(metadata));
}
- public void setClassLoader(ClassLoader classloader)
- {
- // do nothing
- }
-
}
-
Modified: stack/native/trunk/modules/core/src/main/java/org/jboss/ws/extensions/wsrm/transport/backchannel/RMBackPortsInvocationHandler.java
===================================================================
--- stack/native/trunk/modules/core/src/main/java/org/jboss/ws/extensions/wsrm/transport/backchannel/RMBackPortsInvocationHandler.java 2009-07-04 14:37:52 UTC (rev 10314)
+++ stack/native/trunk/modules/core/src/main/java/org/jboss/ws/extensions/wsrm/transport/backchannel/RMBackPortsInvocationHandler.java 2009-07-04 14:44:05 UTC (rev 10315)
@@ -21,76 +21,179 @@
*/
package org.jboss.ws.extensions.wsrm.transport.backchannel;
+import java.net.URL;
+import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
+import java.util.Map;
+import java.util.Set;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
-import javax.management.MBeanServer;
-
import org.jboss.logging.Logger;
-import org.jboss.remoting.InvocationRequest;
-import org.jboss.remoting.ServerInvocationHandler;
-import org.jboss.remoting.ServerInvoker;
-import org.jboss.remoting.callback.InvokerCallbackHandler;
-import org.jboss.remoting.transport.coyote.RequestMap;
-import org.jboss.remoting.transport.http.HTTPMetadataConstants;
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.jboss.netty.buffer.ChannelBufferInputStream;
+import org.jboss.netty.channel.ChannelHandlerContext;
+import org.jboss.netty.channel.ChannelStateEvent;
+import org.jboss.netty.channel.ExceptionEvent;
+import org.jboss.netty.channel.MessageEvent;
+import org.jboss.netty.channel.SimpleChannelUpstreamHandler;
+import org.jboss.netty.handler.codec.http.Cookie;
+import org.jboss.netty.handler.codec.http.CookieDecoder;
+import org.jboss.netty.handler.codec.http.CookieEncoder;
+import org.jboss.netty.handler.codec.http.DefaultHttpResponse;
+import org.jboss.netty.handler.codec.http.HttpHeaders;
+import org.jboss.netty.handler.codec.http.HttpRequest;
+import org.jboss.netty.handler.codec.http.HttpResponse;
+import org.jboss.netty.handler.codec.http.HttpResponseStatus;
+import org.jboss.netty.handler.codec.http.HttpVersion;
+import org.jboss.ws.extensions.wsrm.transport.RMMessage;
+import org.jboss.ws.extensions.wsrm.transport.RMUnMarshaller;
/**
* TODO: Add comment
*
* @author richard.opalka(a)jboss.com
+ * @author alessio.soldano(a)jboss.com
*
* @since Nov 20, 2007
*/
-public final class RMBackPortsInvocationHandler implements ServerInvocationHandler
+public final class RMBackPortsInvocationHandler extends SimpleChannelUpstreamHandler
{
private static final Logger LOG = Logger.getLogger(RMBackPortsInvocationHandler.class);
private final List<RMCallbackHandler> callbacks = new LinkedList<RMCallbackHandler>();
private final Lock lock = new ReentrantLock();
-
+
+
public RMBackPortsInvocationHandler()
{
}
- public RMCallbackHandler getCallback(String requestPath)
+ @Override
+ public void channelOpen(ChannelHandlerContext ctx, ChannelStateEvent e)
{
+ // HERE: Add all accepted channels to the group
+ // so that they are closed properly on shutdown
+ // If the added channel is closed before shutdown,
+ // it will be removed from the group automatically.
+ RMBackPortsServer.channelGroup.add(ctx.getChannel());
+ }
+
+ @Override
+ public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) throws Exception
+ {
+ HttpRequest request = (HttpRequest)e.getMessage();
+ ChannelBuffer content = request.getContent();
+
+ Map<String, Object> requestHeaders = new HashMap<String, Object>();
+ for (String headerName : request.getHeaderNames())
+ {
+ requestHeaders.put(headerName, request.getHeaders(headerName));
+ }
+ boolean error = false;
+ try
+ {
+ String requestPath = new URL(request.getUri()).getPath();
+ RMMessage message = (RMMessage)RMUnMarshaller.getInstance().read(content.readable() ? new ChannelBufferInputStream(content) : null, requestHeaders);
+ handle(requestPath, message);
+ }
+ catch (Throwable t)
+ {
+ error = true;
+ LOG.error("Error decoding request to the backport", t);
+ }
+ finally
+ {
+ writeResponse(e, request, error);
+ }
+ }
+
+
+ private void handle(String requestPath, RMMessage message)
+ {
this.lock.lock();
try
{
+ boolean handlerExists = false;
for (RMCallbackHandler handler : this.callbacks)
{
if (handler.getHandledPath().equals(requestPath))
- return handler;
+ {
+ handlerExists = true;
+ LOG.debug("Handling request path: " + requestPath);
+ handler.handle(message);
+ break;
+ }
}
+ if (handlerExists == false)
+ LOG.warn("No callback handler registered for path: " + requestPath);
}
finally
{
this.lock.unlock();
}
+ }
+
+ private void writeResponse(MessageEvent e, HttpRequest request, boolean error)
+ {
+ // Build the response object.
+ HttpResponse response = new DefaultHttpResponse(HttpVersion.HTTP_1_1, error ? HttpResponseStatus.INTERNAL_SERVER_ERROR : HttpResponseStatus.OK);
+ response.setHeader(HttpHeaders.Names.CONTENT_TYPE, "text/plain; charset=UTF-8");
- return null;
+ String cookieString = request.getHeader(HttpHeaders.Names.COOKIE);
+ if (cookieString != null)
+ {
+ CookieDecoder cookieDecoder = new CookieDecoder();
+ Set<Cookie> cookies = cookieDecoder.decode(cookieString);
+ if (!cookies.isEmpty())
+ {
+ // Reset the cookies if necessary.
+ CookieEncoder cookieEncoder = new CookieEncoder(true);
+ for (Cookie cookie : cookies)
+ {
+ cookieEncoder.addCookie(cookie);
+ }
+ response.addHeader(HttpHeaders.Names.SET_COOKIE, cookieEncoder.encode());
+ }
+ }
+
+ // Write the response.
+ e.getChannel().write(response);
+ e.getChannel().close();
}
- public void registerCallback(RMCallbackHandler callbackHandler)
+ @Override
+ public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e) throws Exception
{
+ e.getCause().printStackTrace();
+ e.getChannel().close();
+ }
+
+ public RMCallbackHandler getCallback(String requestPath)
+ {
this.lock.lock();
try
{
- this.callbacks.add(callbackHandler);
+ for (RMCallbackHandler handler : this.callbacks)
+ {
+ if (handler.getHandledPath().equals(requestPath))
+ return handler;
+ }
}
finally
{
this.lock.unlock();
}
+
+ return null;
}
- public void unregisterCallback(RMCallbackHandler callbackHandler)
+ public void registerCallback(RMCallbackHandler callbackHandler)
{
this.lock.lock();
try
{
- this.callbacks.remove(callbackHandler);
+ this.callbacks.add(callbackHandler);
}
finally
{
@@ -98,53 +201,16 @@
}
}
- public Object invoke(InvocationRequest request) throws Throwable
+ public void unregisterCallback(RMCallbackHandler callbackHandler)
{
this.lock.lock();
try
{
- RequestMap rm = (RequestMap)request.getRequestPayload();
- String requestPath = (String)rm.get(HTTPMetadataConstants.PATH);
- boolean handlerExists = false;
- for (RMCallbackHandler handler : this.callbacks)
- {
- if (handler.getHandledPath().equals(requestPath))
- {
- handlerExists = true;
- LOG.debug("Handling request path: " + requestPath);
- handler.handle(request);
- break;
- }
- }
- if (handlerExists == false)
- LOG.warn("No callback handler registered for path: " + requestPath);
-
- return null;
+ this.callbacks.remove(callbackHandler);
}
finally
{
this.lock.unlock();
}
}
-
- public void addListener(InvokerCallbackHandler callbackHandler)
- {
- // do nothing - we're using custom callback handlers
- }
-
- public void removeListener(InvokerCallbackHandler callbackHandler)
- {
- // do nothing - we're using custom callback handlers
- }
-
- public void setInvoker(ServerInvoker arg0)
- {
- // do nothing
- }
-
- public void setMBeanServer(MBeanServer arg0)
- {
- // do nothing
- }
-
}
Modified: stack/native/trunk/modules/core/src/main/java/org/jboss/ws/extensions/wsrm/transport/backchannel/RMBackPortsServer.java
===================================================================
--- stack/native/trunk/modules/core/src/main/java/org/jboss/ws/extensions/wsrm/transport/backchannel/RMBackPortsServer.java 2009-07-04 14:37:52 UTC (rev 10314)
+++ stack/native/trunk/modules/core/src/main/java/org/jboss/ws/extensions/wsrm/transport/backchannel/RMBackPortsServer.java 2009-07-04 14:44:05 UTC (rev 10315)
@@ -21,20 +21,26 @@
*/
package org.jboss.ws.extensions.wsrm.transport.backchannel;
+import java.net.InetSocketAddress;
+import java.util.concurrent.Executors;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
import org.jboss.logging.Logger;
-import org.jboss.remoting.InvokerLocator;
-import org.jboss.remoting.transport.Connector;
+import org.jboss.netty.bootstrap.ServerBootstrap;
+import org.jboss.netty.channel.Channel;
+import org.jboss.netty.channel.ChannelFactory;
+import org.jboss.netty.channel.group.ChannelGroup;
+import org.jboss.netty.channel.group.DefaultChannelGroup;
+import org.jboss.netty.channel.socket.nio.NioServerSocketChannelFactory;
+import org.jboss.ws.core.client.WSServerPipelineFactory;
import org.jboss.ws.extensions.wsrm.api.RMException;
-import org.jboss.ws.extensions.wsrm.transport.RMMarshaller;
-import org.jboss.ws.extensions.wsrm.transport.RMUnMarshaller;
/**
* Back ports server used by addressable clients
*
* @author richard.opalka(a)jboss.com
+ * @author alessio.soldano(a)jboss.com
*
* @since Nov 20, 2007
*/
@@ -44,9 +50,9 @@
private static final Lock CLASS_LOCK = new ReentrantLock();
private static final long WAIT_PERIOD = 100;
private static RMBackPortsServer INSTANCE;
+ static final ChannelGroup channelGroup = new DefaultChannelGroup("rmBackPortsServer");
private final Object instanceLock = new Object();
- private final Connector connector;
private final String scheme;
private final String host;
private final int port;
@@ -54,6 +60,7 @@
private boolean started;
private boolean stopped;
private boolean terminated;
+ private ChannelFactory factory;
public final void registerCallback(RMCallbackHandler callbackHandler)
{
@@ -70,8 +77,7 @@
return this.handler.getCallback(requestPath);
}
- private RMBackPortsServer(String scheme, String host, int port)
- throws RMException
+ private RMBackPortsServer(String scheme, String host, int port) throws RMException
{
super();
this.scheme = scheme;
@@ -79,17 +85,19 @@
this.port = port;
try
{
- // we have to use custom unmarshaller because default one removes CRNLs
- String customUnmarshaller = "/?unmarshaller=" + RMUnMarshaller.class.getName();
- InvokerLocator il = new InvokerLocator(this.scheme + "://" + this.host + ":" + this.port + customUnmarshaller);
- this.connector = new Connector();
- this.connector.setInvokerLocator(il.getLocatorURI());
- this.connector.create();
-
+ factory = new NioServerSocketChannelFactory(Executors.newCachedThreadPool(), Executors.newCachedThreadPool());
+
+ ServerBootstrap bootstrap = new ServerBootstrap(factory);
this.handler = new RMBackPortsInvocationHandler();
- this.connector.addInvocationHandler("wsrmBackPortsHandler", this.handler);
- this.connector.start();
- LOG.debug("WS-RM Backports Server started on: " + il.getLocatorURI());
+ WSServerPipelineFactory channelPipelineFactory = new WSServerPipelineFactory();
+ channelPipelineFactory.setRequestHandler(this.handler);
+ bootstrap.setPipelineFactory(channelPipelineFactory);
+ bootstrap.setOption("child.tcpNoDelay", true);
+ bootstrap.setOption("child.keepAlive", true);
+ // Bind and start to accept incoming connections.
+ Channel c = bootstrap.bind(new InetSocketAddress(this.port));
+ channelGroup.add(c);
+ LOG.debug("WS-RM Backports Server started on port: " + this.port);
}
catch (Exception e)
{
@@ -136,7 +144,13 @@
}
try
{
- connector.stop();
+ //Close all connections and server sockets.
+ channelGroup.close().awaitUninterruptibly();
+ //Shutdown the selector loop (boss and worker).
+ if (factory != null)
+ {
+ factory.releaseExternalResources();
+ }
}
finally
{
@@ -178,8 +192,7 @@
* @return WS-RM back ports server
* @throws RMException
*/
- public static RMBackPortsServer getInstance(String scheme, String host, int port)
- throws RMException
+ public static RMBackPortsServer getInstance(String scheme, String host, int port) throws RMException
{
CLASS_LOCK.lock();
try
Modified: stack/native/trunk/modules/core/src/main/java/org/jboss/ws/extensions/wsrm/transport/backchannel/RMCallbackHandler.java
===================================================================
--- stack/native/trunk/modules/core/src/main/java/org/jboss/ws/extensions/wsrm/transport/backchannel/RMCallbackHandler.java 2009-07-04 14:37:52 UTC (rev 10314)
+++ stack/native/trunk/modules/core/src/main/java/org/jboss/ws/extensions/wsrm/transport/backchannel/RMCallbackHandler.java 2009-07-04 14:44:05 UTC (rev 10315)
@@ -21,7 +21,6 @@
*/
package org.jboss.ws.extensions.wsrm.transport.backchannel;
-import org.jboss.remoting.InvocationRequest;
import org.jboss.ws.extensions.wsrm.transport.RMMessage;
import org.jboss.ws.extensions.wsrm.transport.RMUnassignedMessageListener;
@@ -35,7 +34,7 @@
public interface RMCallbackHandler
{
String getHandledPath();
- void handle(InvocationRequest payload);
+ void handle(RMMessage message);
RMMessage getMessage(String messageId);
Throwable getFault(String messageId);
void addUnassignedMessageListener(RMUnassignedMessageListener listener);
Modified: stack/native/trunk/modules/core/src/main/java/org/jboss/ws/extensions/wsrm/transport/backchannel/RMCallbackHandlerImpl.java
===================================================================
--- stack/native/trunk/modules/core/src/main/java/org/jboss/ws/extensions/wsrm/transport/backchannel/RMCallbackHandlerImpl.java 2009-07-04 14:37:52 UTC (rev 10314)
+++ stack/native/trunk/modules/core/src/main/java/org/jboss/ws/extensions/wsrm/transport/backchannel/RMCallbackHandlerImpl.java 2009-07-04 14:44:05 UTC (rev 10315)
@@ -27,7 +27,6 @@
import java.util.Map;
import org.jboss.logging.Logger;
-import org.jboss.remoting.InvocationRequest;
import org.jboss.ws.core.MessageTrace;
import org.jboss.ws.extensions.wsrm.transport.RMMessage;
import org.jboss.ws.extensions.wsrm.transport.RMUnassignedMessageListener;
@@ -70,9 +69,8 @@
return this.handledPath;
}
- public final void handle(InvocationRequest request)
+ public final void handle(RMMessage message)
{
- RMMessage message = (RMMessage)request.getParameter();
synchronized (instanceLock)
{
String requestMessage = new String(message.getPayload());
Modified: stack/native/trunk/modules/resources/src/main/resources/bin/wsrunclient.bat
===================================================================
--- stack/native/trunk/modules/resources/src/main/resources/bin/wsrunclient.bat 2009-07-04 14:37:52 UTC (rev 10314)
+++ stack/native/trunk/modules/resources/src/main/resources/bin/wsrunclient.bat 2009-07-04 14:44:05 UTC (rev 10315)
@@ -53,6 +53,7 @@
set WSRUNCLIENT_CLASSPATH=%WSRUNCLIENT_CLASSPATH%;%JBOSS_HOME%/client/FastInfoset.jar
set WSRUNCLIENT_CLASSPATH=%WSRUNCLIENT_CLASSPATH%;%JBOSS_HOME%/client/log4j.jar
set WSRUNCLIENT_CLASSPATH=%WSRUNCLIENT_CLASSPATH%;%JBOSS_HOME%/client/mail.jar
+set WSRUNCLIENT_CLASSPATH=%WSRUNCLIENT_CLASSPATH%;%JBOSS_HOME%/client/netty.jar
set WSRUNCLIENT_CLASSPATH=%WSRUNCLIENT_CLASSPATH%;%JBOSS_HOME%/client/policy.jar
set WSRUNCLIENT_CLASSPATH=%WSRUNCLIENT_CLASSPATH%;%JBOSS_HOME%/client/stax-api.jar
set WSRUNCLIENT_CLASSPATH=%WSRUNCLIENT_CLASSPATH%;%JBOSS_HOME%/client/xmlsec.jar
Modified: stack/native/trunk/modules/resources/src/main/resources/bin/wsrunclient.sh
===================================================================
--- stack/native/trunk/modules/resources/src/main/resources/bin/wsrunclient.sh 2009-07-04 14:37:52 UTC (rev 10314)
+++ stack/native/trunk/modules/resources/src/main/resources/bin/wsrunclient.sh 2009-07-04 14:44:05 UTC (rev 10315)
@@ -80,6 +80,7 @@
WSRUNCLIENT_CLASSPATH="$WSRUNCLIENT_CLASSPATH:$JBOSS_HOME/client/FastInfoset.jar"
WSRUNCLIENT_CLASSPATH="$WSRUNCLIENT_CLASSPATH:$JBOSS_HOME/client/log4j.jar"
WSRUNCLIENT_CLASSPATH="$WSRUNCLIENT_CLASSPATH:$JBOSS_HOME/client/mail.jar"
+WSRUNCLIENT_CLASSPATH="$WSRUNCLIENT_CLASSPATH:$JBOSS_HOME/client/netty.jar"
WSRUNCLIENT_CLASSPATH="$WSRUNCLIENT_CLASSPATH:$JBOSS_HOME/client/policy.jar"
WSRUNCLIENT_CLASSPATH="$WSRUNCLIENT_CLASSPATH:$JBOSS_HOME/client/stax-api.jar"
WSRUNCLIENT_CLASSPATH="$WSRUNCLIENT_CLASSPATH:$JBOSS_HOME/client/xmlsec.jar"
Modified: stack/native/trunk/modules/resources/src/main/resources/bin/wstools.bat
===================================================================
--- stack/native/trunk/modules/resources/src/main/resources/bin/wstools.bat 2009-07-04 14:37:52 UTC (rev 10314)
+++ stack/native/trunk/modules/resources/src/main/resources/bin/wstools.bat 2009-07-04 14:44:05 UTC (rev 10315)
@@ -18,6 +18,7 @@
set WSTOOLS_CLASSPATH=%WSTOOLS_CLASSPATH%;%JAVA_HOME%/lib/tools.jar
set WSTOOLS_CLASSPATH=%WSTOOLS_CLASSPATH%;%JBOSS_HOME%/client/activation.jar
set WSTOOLS_CLASSPATH=%WSTOOLS_CLASSPATH%;%JBOSS_HOME%/client/getopt.jar
+set WSTOOLS_CLASSPATH=%WSTOOLS_CLASSPATH%;%JBOSS_HOME%/client/netty.jar
set WSTOOLS_CLASSPATH=%WSTOOLS_CLASSPATH%;%JBOSS_HOME%/client/wstx.jar
set WSTOOLS_CLASSPATH=%WSTOOLS_CLASSPATH%;%JBOSS_HOME%/client/wsdl4j.jar
set WSTOOLS_CLASSPATH=%WSTOOLS_CLASSPATH%;%JBOSS_HOME%/client/jbossall-client.jar
Modified: stack/native/trunk/modules/resources/src/main/resources/bin/wstools.sh
===================================================================
--- stack/native/trunk/modules/resources/src/main/resources/bin/wstools.sh 2009-07-04 14:37:52 UTC (rev 10314)
+++ stack/native/trunk/modules/resources/src/main/resources/bin/wstools.sh 2009-07-04 14:44:05 UTC (rev 10315)
@@ -48,6 +48,7 @@
WSTOOLS_CLASSPATH="$WSTOOLS_CLASSPATH:$JAVA_HOME/lib/tools.jar"
WSTOOLS_CLASSPATH="$WSTOOLS_CLASSPATH:$JBOSS_HOME/client/activation.jar"
WSTOOLS_CLASSPATH="$WSTOOLS_CLASSPATH:$JBOSS_HOME/client/getopt.jar"
+WSTOOLS_CLASSPATH="$WSTOOLS_CLASSPATH:$JBOSS_HOME/client/netty.jar"
WSTOOLS_CLASSPATH="$WSTOOLS_CLASSPATH:$JBOSS_HOME/client/wstx.jar"
WSTOOLS_CLASSPATH="$WSTOOLS_CLASSPATH:$JBOSS_HOME/client/wsdl4j.jar"
WSTOOLS_CLASSPATH="$WSTOOLS_CLASSPATH:$JBOSS_HOME/client/jbossall-client.jar"
Modified: stack/native/trunk/modules/resources/src/main/resources/resources/default-deploy.conf
===================================================================
--- stack/native/trunk/modules/resources/src/main/resources/resources/default-deploy.conf 2009-07-04 14:37:52 UTC (rev 10314)
+++ stack/native/trunk/modules/resources/src/main/resources/resources/default-deploy.conf 2009-07-04 14:44:05 UTC (rev 10315)
@@ -1 +1 @@
-bin/wsconsume.bat bin/wsconsume.sh bin/wsprovide.bat bin/wsprovide.sh bin/wsrunclient.bat bin/wsrunclient.sh bin/wstools.bat bin/wstools.sh client/jettison.jar client/jaxb-api.jar client/jaxb-impl.jar client/jaxb-xjc.jar client/jaxws-rt.jar client/jaxws-tools.jar client/jboss-jaxrpc.jar client/jboss-jaxws-ext.jar client/jboss-jaxws.jar client/jboss-saaj.jar client/jbossws-native-jaxrpc.jar client/jbossws-native-jaxws-ext.jar client/jbossws-native-jaxws.jar client/jbossws-native-saaj.jar client/jbossws-client.jar client/jbossws-native-client.jar client/jbossws-native-core.jar client/jbossws-common.jar client/jbossws-framework.jar client/jbossws-spi.jar client/policy.jar client/stax-ex.jar client/streambuffer.jar client/wsdl4j.jar lib/jaxb-api.jar lib/jaxb-impl.jar common/lib/jboss-jaxrpc.jar common/lib/jboss-jaxws-ext.jar common/lib/jboss-jaxws.jar common/lib/jboss-saaj.jar common/lib/jbossws-native-jaxrpc.jar common/lib/jbossws-native-jaxws-ext.jar common/lib/jbossws-native!
-jaxws.jar common/lib/jbossws-native-saaj.jar common/lib/jbossws-common.jar common/lib/jbossws-framework.jar common/lib/jbossws-spi.jar server/default/deploy/jbossws.sar server/default/deploy/juddi-service.sar server/default/deploy/jbossws-container-jboss-beans.xml server/default/deployers/jbossws.deployer/FastInfoset.jar server/default/deployers/jbossws.deployer/jboss-jaxb-intros.jar server/default/deployers/jbossws.deployer/jbossws-native-core.jar server/default/deployers/jbossws.deployer/jettison.jar server/default/deployers/jbossws.deployer/policy.jar server/default/deployers/jbossws.deployer/wsdl4j.jar server/default/deployers/jbossws.deployer/xmlsec.jar server/default/deployers/jbossws.deployer/META-INF/jbossws-container-jboss-beans.xml lib/endorsed/jbossws-native-* lib/endorsed/jaxb-api.jar
+bin/wsconsume.bat bin/wsconsume.sh bin/wsprovide.bat bin/wsprovide.sh bin/wsrunclient.bat bin/wsrunclient.sh bin/wstools.bat bin/wstools.sh client/jettison.jar client/jaxb-api.jar client/jaxb-impl.jar client/jaxb-xjc.jar client/jaxws-rt.jar client/jaxws-tools.jar client/jboss-jaxrpc.jar client/jboss-jaxws-ext.jar client/jboss-jaxws.jar client/jboss-saaj.jar client/jbossws-native-jaxrpc.jar client/jbossws-native-jaxws-ext.jar client/jbossws-native-jaxws.jar client/jbossws-native-saaj.jar client/jbossws-client.jar client/jbossws-native-client.jar client/jbossws-native-core.jar client/jbossws-common.jar client/jbossws-framework.jar client/jbossws-spi.jar client/netty.jar client/policy.jar client/stax-ex.jar client/streambuffer.jar client/wsdl4j.jar lib/jaxb-api.jar lib/jaxb-impl.jar common/lib/jboss-jaxrpc.jar common/lib/jboss-jaxws-ext.jar common/lib/jboss-jaxws.jar common/lib/jboss-saaj.jar common/lib/jbossws-native-jaxrpc.jar common/lib/jbossws-native-jaxws-ext.jar common/l!
ib/jbossws-native-jaxws.jar common/lib/jbossws-native-saaj.jar common/lib/jbossws-common.jar common/lib/jbossws-framework.jar common/lib/jbossws-spi.jar server/default/deploy/jbossws.sar server/default/deploy/juddi-service.sar server/default/deploy/jbossws-container-jboss-beans.xml server/default/deployers/jbossws.deployer/FastInfoset.jar server/default/deployers/jbossws.deployer/jboss-jaxb-intros.jar server/default/deployers/jbossws.deployer/jbossws-native-core.jar server/default/deployers/jbossws.deployer/jettison.jar server/default/deployers/jbossws.deployer/netty.jar server/default/deployers/jbossws.deployer/policy.jar server/default/deployers/jbossws.deployer/wsdl4j.jar server/default/deployers/jbossws.deployer/xmlsec.jar server/default/deployers/jbossws.deployer/META-INF/jbossws-container-jboss-beans.xml lib/endorsed/jbossws-native-* lib/endorsed/jaxb-api.jar
Modified: stack/native/trunk/modules/resources/src/main/resources/resources/jbossws-deploy-macros.xml
===================================================================
--- stack/native/trunk/modules/resources/src/main/resources/resources/jbossws-deploy-macros.xml 2009-07-04 14:37:52 UTC (rev 10314)
+++ stack/native/trunk/modules/resources/src/main/resources/resources/jbossws-deploy-macros.xml 2009-07-04 14:44:05 UTC (rev 10315)
@@ -44,6 +44,7 @@
<include name="**/jbossws-native-saaj.jar"/>
<include name="**/jbossws-spi.jar"/>
<include name="**/jettison.jar"/>
+ <include name="**/netty.jar"/>
<include name="**/policy.jar"/>
<include name="**/stax-api.jar"/>
<include name="**/stax-ex.jar"/>
@@ -79,6 +80,7 @@
<include name="**/jboss-jaxb-intros.jar"/>
<include name="**/jbossws-native-core.jar"/>
<include name="**/jettison.jar"/>
+ <include name="**/netty.jar"/>
<include name="**/policy.jar"/>
<include name="**/wsdl4j.jar"/>
<include name="**/xmlsec.jar"/>
Modified: stack/native/trunk/pom.xml
===================================================================
--- stack/native/trunk/pom.xml 2009-07-04 14:37:52 UTC (rev 10314)
+++ stack/native/trunk/pom.xml 2009-07-04 14:44:05 UTC (rev 10315)
@@ -68,10 +68,10 @@
<jboss.common.version>1.2.1.GA</jboss.common.version>
<jboss.jaxbintros.version>1.0.0.GA</jboss.jaxbintros.version>
<jboss.logging.version>2.0.5.GA</jboss.logging.version>
- <jboss.remoting.version>2.5.0.SP2</jboss.remoting.version>
<jboss.jaxr.version>1.2.1.GA</jboss.jaxr.version>
<apache.scout.version>0.7rc2</apache.scout.version>
<juddi.version>0.9RC4</juddi.version>
+ <netty.version>3.1.0.CR1</netty.version>
<sun.fastinfoset.version>1.2.2</sun.fastinfoset.version>
<sun.jaxws.version>2.1.3</sun.jaxws.version>
<woodstox.version>3.2.6</woodstox.version>
@@ -215,11 +215,6 @@
<artifactId>jboss-common</artifactId>
<version>${jboss.common.version}</version>
</dependency>
- <dependency>
- <groupId>org.jboss.remoting</groupId>
- <artifactId>jboss-remoting</artifactId>
- <version>${jboss.remoting.version}</version>
- </dependency>
<!-- transitive dependencies -->
<dependency>
<groupId>commons-logging</groupId>
@@ -337,6 +332,11 @@
<artifactId>xmlsec</artifactId>
<version>${xmlsec.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.jboss.netty</groupId>
+ <artifactId>netty</artifactId>
+ <version>${netty.version}</version>
+ </dependency>
</dependencies>
</dependencyManagement>
Modified: stack/native/trunk/src/main/scripts/assembly-deploy-artifacts.xml
===================================================================
--- stack/native/trunk/src/main/scripts/assembly-deploy-artifacts.xml 2009-07-04 14:37:52 UTC (rev 10314)
+++ stack/native/trunk/src/main/scripts/assembly-deploy-artifacts.xml 2009-07-04 14:44:05 UTC (rev 10315)
@@ -52,6 +52,7 @@
<include>com.sun.xml.stream.buffer:streambuffer:jar</include>
<include>wsdl4j:wsdl4j:jar</include>
<include>org.apache:xmlsec:jar</include>
+ <include>org.jboss.netty:netty:jar</include>
</includes>
</dependencySet>
<dependencySet>
16 years, 4 months
JBossWS SVN: r10314 - common/trunk/src/main/java/org/jboss/wsf/common.
by jbossws-commits@lists.jboss.org
Author: alessio.soldano(a)jboss.com
Date: 2009-07-04 10:37:52 -0400 (Sat, 04 Jul 2009)
New Revision: 10314
Modified:
common/trunk/src/main/java/org/jboss/wsf/common/DOMUtils.java
Log:
[JBWS-2554] Making threadlocals inheritable
Modified: common/trunk/src/main/java/org/jboss/wsf/common/DOMUtils.java
===================================================================
--- common/trunk/src/main/java/org/jboss/wsf/common/DOMUtils.java 2009-07-04 14:19:32 UTC (rev 10313)
+++ common/trunk/src/main/java/org/jboss/wsf/common/DOMUtils.java 2009-07-04 14:37:52 UTC (rev 10314)
@@ -73,8 +73,8 @@
private static final String DEFER_NODE_EXPANSION_FEATURE = "http://apache.org/xml/features/dom/defer-node-expansion";
// All elements created by the same thread are created by the same builder and belong to the same doc
- private static ThreadLocal<Document> documentThreadLocal = new ThreadLocal<Document>();
- private static ThreadLocal<DocumentBuilder> builderThreadLocal = new ThreadLocal<DocumentBuilder>() {
+ private static ThreadLocal<Document> documentThreadLocal = new InheritableThreadLocal<Document>();
+ private static ThreadLocal<DocumentBuilder> builderThreadLocal = new InheritableThreadLocal<DocumentBuilder>() {
protected DocumentBuilder initialValue()
{
DocumentBuilderFactory factory = null;
16 years, 4 months
JBossWS SVN: r10313 - stack/native/branches/netty/modules/core/src/main/java/org/jboss/ws/core/jaxws/binding.
by jbossws-commits@lists.jboss.org
Author: alessio.soldano(a)jboss.com
Date: 2009-07-04 10:19:32 -0400 (Sat, 04 Jul 2009)
New Revision: 10313
Modified:
stack/native/branches/netty/modules/core/src/main/java/org/jboss/ws/core/jaxws/binding/HTTPMessageUnMarshaller.java
Log:
Fix
Modified: stack/native/branches/netty/modules/core/src/main/java/org/jboss/ws/core/jaxws/binding/HTTPMessageUnMarshaller.java
===================================================================
--- stack/native/branches/netty/modules/core/src/main/java/org/jboss/ws/core/jaxws/binding/HTTPMessageUnMarshaller.java 2009-07-04 08:05:00 UTC (rev 10312)
+++ stack/native/branches/netty/modules/core/src/main/java/org/jboss/ws/core/jaxws/binding/HTTPMessageUnMarshaller.java 2009-07-04 14:19:32 UTC (rev 10313)
@@ -33,6 +33,7 @@
import org.jboss.logging.Logger;
import org.jboss.ws.WSException;
import org.jboss.ws.core.HTTPMessageImpl;
+import org.jboss.ws.core.client.NettyClient;
import org.jboss.ws.core.client.UnMarshaller;
/**
@@ -59,9 +60,8 @@
log.trace("Read input stream with metadata=" + metadata);
}
- //TODO!!! fix constants
- Integer resCode = (Integer)metadata.get("ResponseCode");
- String resMessage = (String)metadata.get("ResponseCodeMessage");
+ Integer resCode = (Integer)metadata.get(NettyClient.RESPONSE_CODE);
+ String resMessage = (String)metadata.get(NettyClient.RESPONSE_CODE_MESSAGE);
if (resCode != null && validResponseCodes.contains(resCode) == false)
throw new WSException("Invalid HTTP server response [" + resCode + "] - " + resMessage);
16 years, 4 months
JBossWS SVN: r10312 - in stack/native/branches/netty/modules/core/src/main/java/org/jboss/ws/core/client: ssl and 1 other directory.
by jbossws-commits@lists.jboss.org
Author: alessio.soldano(a)jboss.com
Date: 2009-07-04 04:05:00 -0400 (Sat, 04 Jul 2009)
New Revision: 10312
Added:
stack/native/branches/netty/modules/core/src/main/java/org/jboss/ws/core/client/ssl/
stack/native/branches/netty/modules/core/src/main/java/org/jboss/ws/core/client/ssl/JBossWSKeyManager.java
stack/native/branches/netty/modules/core/src/main/java/org/jboss/ws/core/client/ssl/SSLContextFactory.java
Modified:
stack/native/branches/netty/modules/core/src/main/java/org/jboss/ws/core/client/HTTPRemotingConnection.java
stack/native/branches/netty/modules/core/src/main/java/org/jboss/ws/core/client/NettyClient.java
stack/native/branches/netty/modules/core/src/main/java/org/jboss/ws/core/client/WSClientPipelineFactory.java
Log:
SSL support
Modified: stack/native/branches/netty/modules/core/src/main/java/org/jboss/ws/core/client/HTTPRemotingConnection.java
===================================================================
--- stack/native/branches/netty/modules/core/src/main/java/org/jboss/ws/core/client/HTTPRemotingConnection.java 2009-07-03 12:31:04 UTC (rev 10311)
+++ stack/native/branches/netty/modules/core/src/main/java/org/jboss/ws/core/client/HTTPRemotingConnection.java 2009-07-04 08:05:00 UTC (rev 10312)
@@ -56,35 +56,6 @@
// provide logging
private static Logger log = Logger.getLogger(HTTPRemotingConnection.class);
-// private static final int DEFAULT_CHUNK_SIZE = 1024;
-
- // private Map<String, Object> clientConfig = new HashMap<String, Object>();
-
- // private static Map<String, String> metadataMap = new HashMap<String, String>();
- // static
- // {
- // metadataMap.put(Stub.USERNAME_PROPERTY, "http.basic.username");
- // metadataMap.put(Stub.PASSWORD_PROPERTY, "http.basic.password");
- // metadataMap.put(BindingProvider.USERNAME_PROPERTY, "http.basic.username");
- // metadataMap.put(BindingProvider.PASSWORD_PROPERTY, "http.basic.password");
- // }
- // private static Map<String, String> configMap = new HashMap<String, String>();
- // static
- // {
- // configMap.put(StubExt.PROPERTY_KEY_ALIAS, "org.jboss.remoting.keyAlias");
- // configMap.put(StubExt.PROPERTY_KEY_STORE, "org.jboss.remoting.keyStore");
- // configMap.put(StubExt.PROPERTY_KEY_STORE_ALGORITHM, "org.jboss.remoting.keyStoreAlgorithm");
- // configMap.put(StubExt.PROPERTY_KEY_STORE_PASSWORD, "org.jboss.remoting.keyStorePassword");
- // configMap.put(StubExt.PROPERTY_KEY_STORE_TYPE, "org.jboss.remoting.keyStoreType");
- // configMap.put(StubExt.PROPERTY_SOCKET_FACTORY, "socketFactoryClassName");
- // configMap.put(StubExt.PROPERTY_SSL_PROTOCOL, "org.jboss.remoting.sslProtocol");
- // configMap.put(StubExt.PROPERTY_SSL_PROVIDER_NAME, "org.jboss.remoting.sslProviderName");
- // configMap.put(StubExt.PROPERTY_TRUST_STORE, "org.jboss.remoting.trustStore");
- // configMap.put(StubExt.PROPERTY_TRUST_STORE_ALGORITHM, "org.jboss.remoting.truststoreAlgorithm");
- // configMap.put(StubExt.PROPERTY_TRUST_STORE_PASSWORD, "org.jboss.remoting.trustStorePassword");
- // configMap.put(StubExt.PROPERTY_TRUST_STORE_TYPE, "org.jboss.remoting.trustStoreType");
- // }
-
private boolean closed;
private Integer chunkSize;
Modified: stack/native/branches/netty/modules/core/src/main/java/org/jboss/ws/core/client/NettyClient.java
===================================================================
--- stack/native/branches/netty/modules/core/src/main/java/org/jboss/ws/core/client/NettyClient.java 2009-07-03 12:31:04 UTC (rev 10311)
+++ stack/native/branches/netty/modules/core/src/main/java/org/jboss/ws/core/client/NettyClient.java 2009-07-04 08:05:00 UTC (rev 10312)
@@ -30,6 +30,7 @@
import java.util.concurrent.Executor;
import java.util.concurrent.Executors;
+import javax.net.ssl.SSLEngine;
import javax.xml.rpc.Stub;
import javax.xml.ws.BindingProvider;
@@ -49,10 +50,12 @@
import org.jboss.netty.handler.codec.http.HttpMethod;
import org.jboss.netty.handler.codec.http.HttpRequest;
import org.jboss.netty.handler.codec.http.HttpVersion;
+import org.jboss.netty.handler.ssl.SslHandler;
import org.jboss.security.Base64Encoder;
import org.jboss.ws.core.CommonMessageContext;
import org.jboss.ws.core.StubExt;
import org.jboss.ws.core.WSTimeoutException;
+import org.jboss.ws.core.client.ssl.SSLContextFactory;
import org.jboss.ws.core.soap.MessageContextAssociation;
import org.jboss.ws.feature.FastInfosetFeature;
import org.jboss.ws.metadata.config.CommonConfig;
@@ -125,6 +128,16 @@
public Object invoke(Object reqMessage, String targetAddress, boolean waitForResponse, Map<String, Object> additionalHeaders, Map<String, Object> callProps)
throws IOException
{
+ URL target;
+ try
+ {
+ target = new URL(targetAddress);
+ }
+ catch (MalformedURLException e)
+ {
+ throw new RuntimeException("Invalid address: " + targetAddress, e);
+ }
+
ChannelFactory factory = new NioClientSocketChannelFactory(bossExecutor, workerExecutor);
ClientBootstrap bootstrap = new ClientBootstrap(factory);
@@ -135,6 +148,14 @@
responseHandler = new WSResponseHandler(unmarshaller);
channelPipelineFactory.setResponseHandler(responseHandler);
}
+ if ("https".equalsIgnoreCase(target.getProtocol()))
+ {
+ SSLContextFactory sslContextFactory = new SSLContextFactory(callProps);
+ SSLEngine engine = sslContextFactory.getSSLContext().createSSLEngine();
+ engine.setUseClientMode(true);
+ channelPipelineFactory.setSslHandler(new SslHandler(engine));
+ }
+
bootstrap.setPipelineFactory(channelPipelineFactory);
Channel channel = null;
@@ -142,15 +163,6 @@
{
setActualTimeout(callProps);
//Start the connection attempt
- URL target;
- try
- {
- target = new URL(targetAddress);
- }
- catch (MalformedURLException e)
- {
- throw new RuntimeException("Invalid address: " + targetAddress, e);
- }
ChannelFuture future = bootstrap.connect(getSocketAddress(target));
//Wait until the connection attempt succeeds or fails
Modified: stack/native/branches/netty/modules/core/src/main/java/org/jboss/ws/core/client/WSClientPipelineFactory.java
===================================================================
--- stack/native/branches/netty/modules/core/src/main/java/org/jboss/ws/core/client/WSClientPipelineFactory.java 2009-07-03 12:31:04 UTC (rev 10311)
+++ stack/native/branches/netty/modules/core/src/main/java/org/jboss/ws/core/client/WSClientPipelineFactory.java 2009-07-04 08:05:00 UTC (rev 10312)
@@ -40,12 +40,17 @@
{
private static final int MAX_CONTENT_SIZE = 1073741824;
private ChannelHandler responseHandler;
- private ChannelHandler sshHandler;
+ private ChannelHandler sslHandler;
public ChannelPipeline getPipeline() throws Exception
{
// Create a default pipeline implementation.
ChannelPipeline pipeline = pipeline();
+
+ if (sslHandler != null)
+ {
+ pipeline.addLast("ssl", sslHandler);
+ }
pipeline.addLast("decoder", new HttpResponseDecoder());
// Uncomment the following line if you don't want to handle HttpChunks.
pipeline.addLast("aggregator", new HttpChunkAggregator(MAX_CONTENT_SIZE));
@@ -67,14 +72,14 @@
this.responseHandler = responseHandler;
}
- public ChannelHandler getSshHandler()
+ public ChannelHandler getSslHandler()
{
- return sshHandler;
+ return sslHandler;
}
- public void setSshHandler(ChannelHandler sshHandler)
+ public void setSslHandler(ChannelHandler sslHandler)
{
- this.sshHandler = sshHandler;
+ this.sslHandler = sslHandler;
}
Added: stack/native/branches/netty/modules/core/src/main/java/org/jboss/ws/core/client/ssl/JBossWSKeyManager.java
===================================================================
--- stack/native/branches/netty/modules/core/src/main/java/org/jboss/ws/core/client/ssl/JBossWSKeyManager.java (rev 0)
+++ stack/native/branches/netty/modules/core/src/main/java/org/jboss/ws/core/client/ssl/JBossWSKeyManager.java 2009-07-04 08:05:00 UTC (rev 10312)
@@ -0,0 +1,78 @@
+/*
+* 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.ws.core.client.ssl;
+
+import java.net.Socket;
+import java.security.Principal;
+import java.security.PrivateKey;
+import java.security.cert.X509Certificate;
+
+import javax.net.ssl.X509KeyManager;
+
+/**
+ *
+ * @author alessio.soldano(a)jboss.com
+ * @since 03-July-2009
+ *
+ */
+public class JBossWSKeyManager implements X509KeyManager
+{
+ private X509KeyManager targetManager = null;
+ private String alias = null;
+
+ public JBossWSKeyManager(X509KeyManager x509KeyManager, String alias)
+ {
+ this.targetManager = x509KeyManager;
+ this.alias = alias;
+ }
+
+ public PrivateKey getPrivateKey(String string)
+ {
+ return targetManager.getPrivateKey(string);
+ }
+
+ public X509Certificate[] getCertificateChain(String string)
+ {
+ return targetManager.getCertificateChain(string);
+ }
+
+ public String[] getClientAliases(String string, Principal[] principals)
+ {
+ return targetManager.getClientAliases(string, principals);
+ }
+
+ public String[] getServerAliases(String string, Principal[] principals)
+ {
+ return targetManager.getServerAliases(string, principals);
+ }
+
+ public String chooseServerAlias(String string, Principal[] principals, Socket socket)
+ {
+ return targetManager.chooseServerAlias(string, principals, socket);
+ }
+
+ public String chooseClientAlias(String[] strings, Principal[] principals, Socket socket)
+ {
+ // just returning supplied alias instead of searching
+ return alias;
+ }
+}
Property changes on: stack/native/branches/netty/modules/core/src/main/java/org/jboss/ws/core/client/ssl/JBossWSKeyManager.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: stack/native/branches/netty/modules/core/src/main/java/org/jboss/ws/core/client/ssl/SSLContextFactory.java
===================================================================
--- stack/native/branches/netty/modules/core/src/main/java/org/jboss/ws/core/client/ssl/SSLContextFactory.java (rev 0)
+++ stack/native/branches/netty/modules/core/src/main/java/org/jboss/ws/core/client/ssl/SSLContextFactory.java 2009-07-04 08:05:00 UTC (rev 10312)
@@ -0,0 +1,1303 @@
+/*
+* 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.ws.core.client.ssl;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.security.KeyStore;
+import java.security.KeyStoreException;
+import java.security.NoSuchAlgorithmException;
+import java.security.NoSuchProviderException;
+import java.security.Provider;
+import java.security.SecureRandom;
+import java.security.UnrecoverableKeyException;
+import java.security.cert.CertificateException;
+import java.security.cert.X509Certificate;
+import java.util.Map;
+
+import javax.net.ssl.KeyManager;
+import javax.net.ssl.KeyManagerFactory;
+import javax.net.ssl.SSLContext;
+import javax.net.ssl.TrustManager;
+import javax.net.ssl.TrustManagerFactory;
+import javax.net.ssl.X509KeyManager;
+import javax.net.ssl.X509TrustManager;
+
+import org.jboss.logging.Logger;
+import org.jboss.ws.core.StubExt;
+
+/**
+ * This builds SSLContext instances. It's a modified version of org.jboss.remoting.security.SSLSocketBuilder
+ *
+ * @author <a href="mailto:mazz@jboss.com">John Mazzitelli</a>
+ * @author <a href="mailto:telrod@jboss.com">Tom Elrod</a>
+ * @author <a href="mailto:alessio.soldano@jboss.com">Alessio Soldano</a>
+ *
+ */
+public class SSLContextFactory
+{
+ /**
+ * If the protocol isn't specified, this will be the default.
+ * Value is "TLS".
+ */
+ public static final String DEFAULT_SSL_PROTOCOL = "TLS";
+
+ /**
+ * Constant defining the config property used to define if the sockets will be in
+ * client or server mode.
+ */
+ public static final String SSL_USE_CLIENT_MODE = "org.jboss.ws.sslUseClientMode";
+
+ /**
+ * Constant defining the config property used to define if the server sockets will be in
+ * client or server mode.
+ */
+ public static final String SERVER_SSL_USE_CLIENT_MODE = "org.jboss.ws.serverSslUseClientMode";
+
+ /**
+ * Constant defining the config property used to define if a client should attempt to
+ * authenticate a server certificate as one it trusts. The value of such a property is
+ * a boolean.
+ */
+ public static final String SSL_SERVER_AUTH_MODE = "org.jboss.ws.sslServerAuthMode";
+
+ /**
+ * Constant defining the config property that indicates the key password for the keys in the key store.
+ */
+ public static final String KEY_PASSWORD = "org.jboss.ws.keyPassword";
+
+ /**
+ * Constant that defines the standard system property that the javax.net.ssl
+ * classes look for when locating the keystore file.
+ */
+ public static final String STANDARD_KEY_STORE_FILE_PATH = "javax.net.ssl.keyStore";
+
+ /**
+ * Constant that defines the standard system property that the javax.net.ssl
+ * classes look for when needing to know what type the keystore file is.
+ */
+ public static final String STANDARD_KEY_STORE_TYPE = "javax.net.ssl.keyStoreType";
+
+ /**
+ * Constant that defines the standard system property that the javax.net.ssl
+ * classes look for when needing the keystore password.
+ */
+ public static final String STANDARD_KEY_STORE_PASSWORD = "javax.net.ssl.keyStorePassword";
+
+ /**
+ * Default key/trust store type if one not set as bean property, via config, or via system property.
+ * Value is 'JKS'.
+ */
+ public static final String DEFAULT_KEY_STORE_TYPE = "JKS";
+
+ /**
+ * Default key/trust store algorithm if one net set as bean property or via config.
+ * Value is 'SunX509'.
+ */
+ public static final String DEFAULT_KEY_STORE_ALGORITHM = "SunX509";
+
+ /**
+ * Constant that defines the standard system property that the javax.net.ssl
+ * classes look for when locating the truststore file.
+ */
+ public static final String STANDARD_TRUST_STORE_FILE_PATH = "javax.net.ssl.trustStore";
+
+ /**
+ * Constant that defines the standard system property that the javax.net.ssl
+ * classes look for when needing to know what type the truststore file is.
+ */
+ public static final String STANDARD_TRUST_STORE_TYPE = "javax.net.ssl.trustStoreType";
+
+ /**
+ * Constant that defines the standard system property that the javax.net.ssl
+ * classes look for when needing the truststore password.
+ */
+ public static final String STANDARD_TRUST_STORE_PASSWORD = "javax.net.ssl.trustStorePassword";
+
+ private SSLContext sslContextServerSocketFactory = null; // context that builds the server socket factories
+ private SSLContext sslContextSocketFactory = null; // context that builds the socket factories
+ private Provider provider = null;
+ private String providerName = null;
+ private String secureSocketProtocol = null;
+
+ private KeyManager[] keyManagers = null;
+ private TrustManager[] trustManagers = null;
+ private SecureRandom secureRandom = null;
+
+ private URL keyStoreFilePath = null;
+ private String keyStoreType = null;
+ private String keyStoreAlgorithm = null;
+ private String keyStorePassword = null;
+ private String keyAlias = null;
+ private String keyPassword = null;
+
+ private URL trustStoreFilePath = null;
+ private String trustStoreType = null;
+ private String trustStoreAlgorithm = null;
+ private String trustStorePassword = null;
+
+ private Map<String, Object> config = null;
+ private Boolean socketUseClientMode = null;
+ private Boolean serverSocketUseClientMode = null;
+ private Boolean serverAuthMode = null;
+
+ private static final Logger log = Logger.getLogger(SSLContextFactory.class);
+
+ /**
+ * Constructor for {@link SSLContextFactory} that does not have
+ * any configuration so it falls back to all defaults.
+ */
+ public SSLContextFactory()
+ {
+ this(null);
+ }
+
+ /**
+ * Constructor for {@link SSLContextFactory} that allows the caller to
+ * override the default settings for the various SSL configuration
+ * properties.
+ *
+ * @param config configuration with properties defining things like where the
+ * keystore and truststore files are, their types, etc.
+ */
+ public SSLContextFactory(Map<String, Object> config)
+ {
+ this.config = config;
+ }
+
+ public SSLContext getSSLContext() throws IOException
+ {
+ if (sslContextSocketFactory == null)
+ {
+ initializeSocketFactorySSLContext();
+ }
+ return sslContextSocketFactory;
+ }
+
+ public SSLContext getServerSSLContext() throws IOException
+ {
+ if (sslContextServerSocketFactory == null)
+ {
+ initializeServerSocketFactorySSLContext();
+ }
+ return sslContextServerSocketFactory;
+ }
+
+ /**
+ * @see org.jboss.remoting.security.SSLSocketBuilderMBean#getSecureSocketProtocol()
+ */
+ public String getSecureSocketProtocol()
+ {
+ if (secureSocketProtocol == null)
+ {
+ if(config != null)
+ {
+ secureSocketProtocol = (String) config.get(StubExt.PROPERTY_SSL_PROTOCOL);
+ }
+ if (secureSocketProtocol == null)
+ {
+ secureSocketProtocol = DEFAULT_SSL_PROTOCOL;
+ }
+ }
+
+ return secureSocketProtocol;
+ }
+
+ /**
+ * @see org.jboss.remoting.security.SSLSocketBuilderMBean#setSecureSocketProtocol(String)
+ */
+ public void setSecureSocketProtocol(String protocol)
+ {
+ if(protocol != null && protocol.length() > 0)
+ {
+ this.secureSocketProtocol = protocol;
+ }
+ else
+ {
+ throw new IllegalArgumentException("Can not set remoting socket factory with null protocol");
+ }
+ }
+
+ /**
+ * @see org.jboss.remoting.security.SSLSocketBuilderMBean#getProvider()
+ */
+ public Provider getProvider()
+ {
+ return provider;
+ }
+
+ /**
+ * @see org.jboss.remoting.security.SSLSocketBuilderMBean#setProvider(java.security.Provider)
+ */
+ public void setProvider(Provider provider)
+ {
+ this.provider = provider;
+ }
+
+ /**
+ * @see org.jboss.remoting.security.SSLSocketBuilderMBean#getProviderName()
+ */
+ public String getProviderName()
+ {
+ if (providerName == null)
+ {
+ if(config != null)
+ {
+ providerName = (String) config.get(StubExt.PROPERTY_SSL_PROVIDER_NAME);
+ }
+ }
+ return providerName;
+ }
+
+ /**
+ * @see org.jboss.remoting.security.SSLSocketBuilderMBean#setProviderName(java.lang.String)
+ */
+ public void setProviderName(String providerName)
+ {
+ this.providerName = providerName;
+ }
+
+ /**
+ * @see org.jboss.remoting.security.SSLSocketBuilderMBean#getSecureRandom()
+ */
+ public SecureRandom getSecureRandom()
+ {
+ if(secureRandom != null)
+ {
+ return secureRandom;
+ }
+
+ secureRandom = new SecureRandom();
+
+ return secureRandom;
+ }
+
+ /**
+ * @see org.jboss.remoting.security.SSLSocketBuilderMBean#setSecureRandom(java.security.SecureRandom)
+ */
+ public void setSecureRandom(SecureRandom secureRandom)
+ {
+ this.secureRandom = secureRandom;
+ }
+
+ /**
+ * @see org.jboss.remoting.security.SSLSocketBuilderMBean#getKeyStoreURL()
+ */
+ public String getKeyStoreURL()
+ {
+ URL keyStore = getKeyStore();
+ if(keyStore != null)
+ {
+ return keyStore.toString();
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ /**
+ * @see org.jboss.remoting.security.SSLSocketBuilderMBean#getKeyStore()
+ */
+ public URL getKeyStore()
+ {
+ if(keyStoreFilePath != null)
+ {
+ return keyStoreFilePath;
+ }
+
+ if(config != null)
+ {
+ String path = (String) config.get(StubExt.PROPERTY_KEY_STORE);
+ if(path != null && path.length() > 0)
+ {
+ setKeyStoreURL( path );
+ }
+ }
+
+ if(keyStoreFilePath == null)
+ {
+ String path = System.getProperty(STANDARD_KEY_STORE_FILE_PATH);
+ if(path != null && path.length() > 0)
+ {
+ setKeyStoreURL( path );
+ }
+ }
+
+ return keyStoreFilePath;
+ }
+
+ /**
+ * @see org.jboss.remoting.security.SSLSocketBuilderMBean#setKeyStoreURL(java.lang.String)
+ */
+ public void setKeyStoreURL(String keyStoreFilePath)
+ {
+ try
+ {
+ this.keyStoreFilePath = validateStoreURL(keyStoreFilePath);
+ }
+ catch (IOException e)
+ {
+ throw new RuntimeException( "Cannot validate the store URL: " + keyStoreFilePath , e );
+ }
+ }
+
+ /**
+ * @see org.jboss.remoting.security.SSLSocketBuilderMBean#setKeyStore(java.net.URL)
+ */
+ public void setKeyStore(URL keyStore)
+ {
+ this.keyStoreFilePath = keyStore;
+ }
+
+ /**
+ * @see org.jboss.remoting.security.SSLSocketBuilderMBean#getKeyStoreType()
+ */
+ public String getKeyStoreType()
+ {
+ if(keyStoreType != null)
+ {
+ return keyStoreType;
+ }
+
+ if(config != null)
+ {
+ String type = (String)config.get(StubExt.PROPERTY_KEY_STORE_TYPE);
+ if(type != null && type.length() > 0)
+ {
+ keyStoreType = type;
+ }
+ }
+
+ if(keyStoreType == null)
+ {
+ keyStoreType = System.getProperty(STANDARD_KEY_STORE_TYPE);
+
+ if(keyStoreType == null)
+ {
+ keyStoreType = DEFAULT_KEY_STORE_TYPE;
+ }
+ }
+
+ return keyStoreType;
+ }
+
+ /**
+ * @see org.jboss.remoting.security.SSLSocketBuilderMBean#setKeyStoreType(java.lang.String)
+ */
+ public void setKeyStoreType(String keyStoreType)
+ {
+ this.keyStoreType = keyStoreType;
+ }
+
+ /**
+ * @see org.jboss.remoting.security.SSLSocketBuilderMBean#getKeyStoreAlgorithm()
+ */
+ public String getKeyStoreAlgorithm()
+ {
+ if(keyStoreAlgorithm != null)
+ {
+ return keyStoreAlgorithm;
+ }
+
+ if(config != null)
+ {
+ String alg = (String)config.get(StubExt.PROPERTY_KEY_STORE_ALGORITHM);
+ if(alg != null && alg.length() > 0)
+ {
+ keyStoreAlgorithm = alg;
+ }
+ }
+
+ if(keyStoreAlgorithm == null)
+ {
+ keyStoreAlgorithm = DEFAULT_KEY_STORE_ALGORITHM;
+ }
+
+ return keyStoreAlgorithm;
+ }
+
+ /**
+ * @see org.jboss.remoting.security.SSLSocketBuilderMBean#setKeyStoreAlgorithm(java.lang.String)
+ */
+ public void setKeyStoreAlgorithm(String algorithm)
+ {
+ this.keyStoreAlgorithm = algorithm;
+ }
+
+ /**
+ * Returns the password used to gain access to the keystore.
+ *
+ * @return keystore password
+ */
+ public String getKeyStorePassword()
+ {
+ if(keyStorePassword != null)
+ {
+ return keyStorePassword;
+ }
+
+ if(config != null)
+ {
+ String passwd = (String)config.get(StubExt.PROPERTY_KEY_STORE_PASSWORD);
+ if(passwd != null && passwd.length() > 0)
+ {
+ keyStorePassword = passwd;
+ }
+ }
+
+ if(keyStorePassword == null)
+ {
+ keyStorePassword = System.getProperty(STANDARD_KEY_STORE_PASSWORD);
+ }
+
+ return keyStorePassword;
+ }
+
+ /**
+ * @see org.jboss.remoting.security.SSLSocketBuilderMBean#setKeyStorePassword(java.lang.String)
+ */
+ public void setKeyStorePassword(String keyStorePassword)
+ {
+ this.keyStorePassword = keyStorePassword;
+ }
+
+ /**
+ * @see org.jboss.remoting.security.SSLSocketBuilderMBean#getTrustStoreURL()
+ */
+ public String getTrustStoreURL()
+ {
+ URL trustStore = getTrustStore();
+ if(trustStore != null)
+ {
+ return trustStore.toString();
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ /**
+ * @see org.jboss.remoting.security.SSLSocketBuilderMBean#getTrustStore()
+ */
+ public URL getTrustStore()
+ {
+ if(trustStoreFilePath != null)
+ {
+ return trustStoreFilePath;
+ }
+
+ if(config != null)
+ {
+ String path = (String)config.get(StubExt.PROPERTY_TRUST_STORE);
+ if(path != null && path.length() > 0)
+ {
+ setTrustStoreURL( path );
+ }
+ }
+
+ if(trustStoreFilePath == null)
+ {
+ String path = System.getProperty(STANDARD_TRUST_STORE_FILE_PATH);
+ if(path != null && path.length() > 0)
+ {
+ setTrustStoreURL( path );
+ }
+ }
+
+ return trustStoreFilePath;
+ }
+
+ /**
+ * @see org.jboss.remoting.security.SSLSocketBuilderMBean#setTrustStore(java.net.URL)
+ */
+ public void setTrustStore(URL trustStore)
+ {
+ this.trustStoreFilePath = trustStore;
+ }
+
+ /**
+ * @see org.jboss.remoting.security.SSLSocketBuilderMBean#setTrustStoreURL(java.lang.String)
+ */
+ public void setTrustStoreURL(String trustStoreFilePath)
+ {
+ try
+ {
+ this.trustStoreFilePath = validateStoreURL(trustStoreFilePath);
+ }
+ catch (IOException e)
+ {
+ throw new RuntimeException( "Cannot validate the store URL: " + trustStoreFilePath , e );
+ }
+ }
+
+ /**
+ * @see org.jboss.remoting.security.SSLSocketBuilderMBean#getTrustStoreType()
+ */
+ public String getTrustStoreType()
+ {
+ if(trustStoreType != null)
+ {
+ return trustStoreType;
+ }
+
+ if(config != null)
+ {
+ String type = (String)config.get(StubExt.PROPERTY_TRUST_STORE_TYPE);
+ if(type != null && type.length() > 0)
+ {
+ trustStoreType = type;
+ }
+ }
+
+ if(trustStoreType == null)
+ {
+ trustStoreType = System.getProperty(STANDARD_TRUST_STORE_TYPE);
+
+ if(trustStoreType == null)
+ {
+ trustStoreType = getKeyStoreType();
+ }
+ }
+
+ return trustStoreType;
+ }
+
+ /**
+ * @see org.jboss.remoting.security.SSLSocketBuilderMBean#setTrustStoreType(java.lang.String)
+ */
+ public void setTrustStoreType(String trustStoreType)
+ {
+ this.trustStoreType = trustStoreType;
+ }
+
+ /**
+ * @see org.jboss.remoting.security.SSLSocketBuilderMBean#getTrustStoreAlgorithm()
+ */
+ public String getTrustStoreAlgorithm()
+ {
+ if(trustStoreAlgorithm != null)
+ {
+ return trustStoreAlgorithm;
+ }
+
+ if(config != null)
+ {
+ String alg = (String)config.get(StubExt.PROPERTY_TRUST_STORE_ALGORITHM);
+ if(alg != null && alg.length() > 0)
+ {
+ trustStoreAlgorithm = alg;
+ }
+ }
+
+ if(trustStoreAlgorithm == null)
+ {
+ trustStoreAlgorithm = getKeyStoreAlgorithm();
+ }
+
+ return trustStoreAlgorithm;
+ }
+
+ /**
+ * @see org.jboss.remoting.security.SSLSocketBuilderMBean#setTrustStoreAlgorithm(java.lang.String)
+ */
+ public void setTrustStoreAlgorithm(String algorithm)
+ {
+ this.trustStoreAlgorithm = algorithm;
+ }
+
+ /**
+ * Returns the password used to gain access to the truststore.
+ *
+ * @return truststore password
+ */
+ public String getTrustStorePassword()
+ {
+ if(trustStorePassword != null)
+ {
+ return trustStorePassword;
+ }
+
+ if(config != null)
+ {
+ String passwd = (String)config.get(StubExt.PROPERTY_TRUST_STORE_PASSWORD);
+ if(passwd != null && passwd.length() > 0)
+ {
+ trustStorePassword = passwd;
+ }
+ }
+
+ if(trustStorePassword == null)
+ {
+ trustStorePassword = System.getProperty(STANDARD_TRUST_STORE_PASSWORD);
+ if(trustStorePassword == null)
+ {
+ trustStorePassword = getKeyStorePassword();
+ }
+ }
+
+ return trustStorePassword;
+ }
+
+ /**
+ * @see org.jboss.remoting.security.SSLSocketBuilderMBean#setTrustStorePassword(java.lang.String)
+ */
+ public void setTrustStorePassword(String trustStorePassword)
+ {
+ this.trustStorePassword = trustStorePassword;
+ }
+
+ /**
+ * @see org.jboss.remoting.security.SSLSocketBuilderMBean#getKeyAlias()
+ */
+ public String getKeyAlias()
+ {
+ if(keyAlias != null)
+ {
+ return keyAlias;
+ }
+ if(config != null)
+ {
+ keyAlias = (String)config.get(StubExt.PROPERTY_KEY_ALIAS);
+ }
+ return keyAlias;
+ }
+
+ /**
+ * @see org.jboss.remoting.security.SSLSocketBuilderMBean#setKeyAlias(java.lang.String)
+ */
+ public void setKeyAlias(String alias)
+ {
+ this.keyAlias = alias;
+ }
+
+ /**
+ * Returns the password to use for the keys within the key store.
+ * If this value is not set, this will return <code>null</code> but
+ * when this value is needed by this class, the value for the key store
+ * password will be used instead.
+ *
+ * @return key password
+ */
+ public String getKeyPassword()
+ {
+ if(keyPassword != null)
+ {
+ return keyPassword;
+ }
+
+ if(config != null)
+ {
+ String passwd = (String)config.get(KEY_PASSWORD);
+ if(passwd != null && passwd.length() > 0)
+ {
+ keyPassword = passwd;
+ }
+ }
+
+ return keyPassword;
+ }
+
+ /**
+ * @see org.jboss.remoting.security.SSLSocketBuilderMBean#setKeyPassword(java.lang.String)
+ */
+ public void setKeyPassword(String keyPassword)
+ {
+ this.keyPassword = keyPassword;
+ }
+
+ /**
+ * @see org.jboss.remoting.security.SSLSocketBuilderMBean#isSocketUseClientMode()
+ */
+ public boolean isSocketUseClientMode( )
+ {
+ if (socketUseClientMode == null)
+ {
+ if (config != null && config.containsKey(SSL_USE_CLIENT_MODE))
+ {
+ socketUseClientMode = Boolean.valueOf((String) config.get(SSL_USE_CLIENT_MODE));
+ }
+ else
+ {
+ socketUseClientMode = Boolean.TRUE;
+ }
+ }
+
+ return socketUseClientMode.booleanValue();
+ }
+
+ /**
+ * @see org.jboss.remoting.security.SSLSocketBuilderMBean#isServerSocketUseClientMode()
+ */
+ public boolean isServerSocketUseClientMode( )
+ {
+ if (serverSocketUseClientMode == null)
+ {
+ if (config != null && config.containsKey(SERVER_SSL_USE_CLIENT_MODE))
+ {
+ serverSocketUseClientMode = Boolean.valueOf((String) config.get(SERVER_SSL_USE_CLIENT_MODE));
+ }
+ else
+ {
+ serverSocketUseClientMode = Boolean.FALSE;
+ }
+ }
+
+ return serverSocketUseClientMode.booleanValue();
+ }
+
+ /**
+ * @see org.jboss.remoting.security.SSLSocketBuilderMBean#setSocketUseClientMode(boolean)
+ */
+ public void setSocketUseClientMode( boolean useClientMode )
+ {
+ this.socketUseClientMode = Boolean.valueOf(useClientMode);
+ }
+
+ /**
+ * @see org.jboss.remoting.security.SSLSocketBuilderMBean#setServerSocketUseClientMode(boolean)
+ */
+ public void setServerSocketUseClientMode( boolean useClientMode )
+ {
+ this.serverSocketUseClientMode = Boolean.valueOf(useClientMode);
+ }
+
+ /**
+ * @see org.jboss.remoting.security.SSLSocketBuilderMBean#isServerAuthMode()
+ */
+ public boolean isServerAuthMode()
+ {
+ if (serverAuthMode == null)
+ {
+ if (config != null && config.containsKey(SSL_SERVER_AUTH_MODE))
+ {
+ serverAuthMode = Boolean.valueOf( (String) config.get(SSL_SERVER_AUTH_MODE) );
+ }
+ else
+ {
+ serverAuthMode = Boolean.TRUE;
+ }
+ }
+
+ return serverAuthMode.booleanValue();
+ }
+
+ /**
+ * @see org.jboss.remoting.security.SSLSocketBuilderMBean#setServerAuthMode(boolean)
+ */
+ public void setServerAuthMode(boolean mode)
+ {
+ serverAuthMode = Boolean.valueOf(mode);
+ }
+
+ /**
+ * Creates (but does not initialize) the SSL context used by this object
+ * to create server socket factories.
+ * The provider/protocol is used to determine what SSL context to use.
+ * Call {@link #initializeServerSocketFactorySSLContext()} if you want
+ * to create and initialize in one method call.
+ * If the server socket factory SSL context was already created, this will create
+ * a new one and remove the old one.
+ *
+ * @throws IOException
+ */
+ protected void createServerSocketFactorySSLContext()
+ throws IOException
+ {
+ try
+ {
+ if(getProvider() != null)
+ {
+ sslContextServerSocketFactory = SSLContext.getInstance(getSecureSocketProtocol(), getProvider());
+ }
+ else if(getProviderName() != null)
+ {
+ sslContextServerSocketFactory = SSLContext.getInstance(getSecureSocketProtocol(), getProviderName());
+ }
+ else
+ {
+ sslContextServerSocketFactory = SSLContext.getInstance(getSecureSocketProtocol());
+ }
+ }
+ catch(Exception e)
+ {
+ IOException ioe = new IOException("Error creating server socket factory SSL context: " + e.getMessage());
+ ioe.setStackTrace(e.getStackTrace());
+ throw ioe;
+ }
+
+ return;
+ }
+
+ /**
+ * Creates (but does not initialize) the SSL context used by this object
+ * to create socket factories.
+ * The provider/protocol is used to determine what SSL context to use.
+ * Call {@link #initializeSocketFactorySSLContext()} if you want
+ * to create and initialize in one method call.
+ * If the socket factory SSL context was already created, this will create
+ * a new one and remove the old one.
+ *
+ * @throws IOException
+ */
+ protected void createSocketFactorySSLContext()
+ throws IOException
+ {
+ try
+ {
+ if(getProvider() != null)
+ {
+ sslContextSocketFactory = SSLContext.getInstance(getSecureSocketProtocol(), getProvider());
+ }
+ else if(getProviderName() != null)
+ {
+ sslContextSocketFactory = SSLContext.getInstance(getSecureSocketProtocol(), getProviderName());
+ }
+ else
+ {
+ sslContextSocketFactory = SSLContext.getInstance(getSecureSocketProtocol());
+ }
+ }
+ catch(Exception e)
+ {
+ IOException ioe = new IOException("Error creating socket factory SSL context: " + e.getMessage());
+ ioe.setStackTrace(e.getStackTrace());
+ throw ioe;
+ }
+
+ return;
+ }
+
+ /**
+ * Initializes the SSL context used by this object that will create the server socket factories.
+ * If the SSL context is not yet created, this method will also create it.
+ * The provider/protocol is used to determine what SSL context to use. Key and trust managers
+ * are loaded and a secure random object is created and the SSL context for the
+ * protocol/provider is initialized with them.
+ *
+ * @throws IOException
+ */
+ protected void initializeServerSocketFactorySSLContext()
+ throws IOException
+ {
+ try
+ {
+ if (sslContextServerSocketFactory == null)
+ {
+ createServerSocketFactorySSLContext();
+ }
+
+ try
+ {
+ keyManagers = loadKeyManagers();
+ }
+ catch (NullStoreURLException e)
+ {
+ if (isServerSocketUseClientMode())
+ {
+ keyManagers = null;
+ log.debug("Could not find keytore url. " + e.getMessage());
+ }
+ else
+ {
+ // because this ssl context will create server socket factories, will throw if can not find keystore
+ IOException ioe = new IOException("Can not find keystore url.");
+ ioe.initCause(e);
+ throw ioe;
+ }
+ }
+
+ try
+ {
+ boolean isClientMode = isServerSocketUseClientMode();
+ trustManagers = loadTrustManagers(isClientMode);
+ }
+ catch (NullStoreURLException e)
+ {
+ trustManagers = null;
+ log.debug("Could not find truststore url. " + e.getMessage());
+ }
+
+ secureRandom = getSecureRandom();
+
+ sslContextServerSocketFactory.init(keyManagers, trustManagers, secureRandom);
+ }
+ catch(Exception e)
+ {
+ IOException ioe = new IOException("Error initializing server socket factory SSL context: " + e.getMessage());
+ ioe.setStackTrace(e.getStackTrace());
+ throw ioe;
+ }
+
+ return;
+ }
+
+ /**
+ * Initializes the SSL context used by this object that will create the socket factories.
+ * If the SSL context is not yet created, this method will also create it.
+ * The provider/protocol is used to determine what SSL context to use. Key and trust managers
+ * are loaded and a secure random object is created and the SSL context for the
+ * protocol/provider is initialized with them.
+ *
+ * @throws IOException
+ */
+ protected void initializeSocketFactorySSLContext()
+ throws IOException
+ {
+ try
+ {
+ if (sslContextSocketFactory == null)
+ {
+ createSocketFactorySSLContext();
+ }
+
+ try
+ {
+ keyManagers = loadKeyManagers();
+ }
+ catch (NullStoreURLException e)
+ {
+ // this is allowable since would be the normal scenario
+ keyManagers = null;
+ log.debug("Could not find keystore url. " + e.getMessage());
+ }
+
+ try
+ {
+ boolean isClientMode = isSocketUseClientMode();
+ trustManagers = loadTrustManagers(isClientMode);
+ }
+ catch (NullStoreURLException e)
+ {
+ // If the keyManagers is not null, could possibly be using in client mode
+ // so want to allow it. Otherwise, need to throw exception as will not be able
+ // to use in client mode or not
+ if(keyManagers != null)
+ {
+ trustManagers = null;
+ log.debug("Could not find truststore url. " + e.getMessage());
+ }
+ else
+ {
+ IOException ioe = new IOException("Can not find truststore url.");
+ ioe.initCause(e);
+ throw ioe;
+ }
+ }
+
+ secureRandom = getSecureRandom();
+
+ sslContextSocketFactory.init(keyManagers, trustManagers, secureRandom);
+ }
+ catch(Exception e)
+ {
+ IOException ioe = new IOException("Error initializing socket factory SSL context: " + e.getMessage());
+ ioe.setStackTrace(e.getStackTrace());
+ throw ioe;
+ }
+
+ return;
+ }
+
+ /**
+ * Loads the trust managers based on this object's truststore.
+ *
+ * @return array of trust managers that should be loaded in this object's SSL context
+ *
+ * @throws NoSuchProviderException
+ * @throws NoSuchAlgorithmException
+ * @throws IOException
+ * @throws CertificateException
+ * @throws KeyStoreException
+ * @throws NullStoreURLException
+ */
+ protected TrustManager[] loadTrustManagers(boolean isClientMode)
+ throws NoSuchProviderException, NoSuchAlgorithmException, IOException, CertificateException, KeyStoreException, NullStoreURLException
+ {
+ if(isClientMode && !isServerAuthMode())
+ {
+ // we are in client mode and do not want to perform server cert authentication
+ // return a trust manager that trusts all certs
+ trustManagers = new TrustManager[] {
+ new X509TrustManager() {
+ public void checkClientTrusted( X509Certificate[] chain, String authType ) {}
+ public void checkServerTrusted( X509Certificate[] chain, String authType ) {}
+ public X509Certificate[] getAcceptedIssuers() { return null; }
+ }};
+ }
+ else
+ {
+ String tsType = getTrustStoreType();
+ String tsPasswd = getTrustStorePassword();
+ URL tsPathURL = getTrustStore();
+
+ String tsAlg = getTrustStoreAlgorithm();
+
+ TrustManagerFactory trustMgrFactory;
+ KeyStore trustStore = loadKeyStore(tsType, tsPathURL, tsPasswd);
+
+ if (getProvider() != null)
+ {
+ trustMgrFactory = TrustManagerFactory.getInstance(tsAlg, getProvider());
+ }
+ else if (getProviderName() != null)
+ {
+ trustMgrFactory = TrustManagerFactory.getInstance(tsAlg, getProviderName());
+ }
+ else
+ {
+ trustMgrFactory = TrustManagerFactory.getInstance(tsAlg);
+ }
+
+ if (trustStore != null)
+ {
+ trustMgrFactory.init(trustStore);
+
+ trustManagers = trustMgrFactory.getTrustManagers();
+ }
+ }
+
+ return trustManagers;
+ }
+
+ /**
+ * Loads the key managers based on this object's truststore.
+ *
+ * @return array of key managers that should be loaded in this object's SSL context
+ *
+ * @throws NoSuchProviderException
+ * @throws NoSuchAlgorithmException
+ * @throws IOException
+ * @throws CertificateException
+ * @throws KeyStoreException
+ * @throws UnrecoverableKeyException
+ * @throws NullStoreURLException
+ */
+ protected KeyManager[] loadKeyManagers()
+ throws NoSuchProviderException, NoSuchAlgorithmException, IOException, CertificateException,
+ KeyStoreException, UnrecoverableKeyException, NullStoreURLException
+ {
+ String ksPasswd = getKeyStorePassword();
+ String ksType = getKeyStoreType();
+ URL ksPathURL = getKeyStore();
+
+ KeyStore keyStore = loadKeyStore(ksType, ksPathURL, ksPasswd);
+
+ if(keyStore != null)
+ {
+ String alias = getKeyAlias();
+
+ // check that keystore contains supplied alias (if there is one)
+ if(alias != null)
+ {
+ boolean containsAlias = keyStore.isKeyEntry(alias);
+ if(!containsAlias)
+ {
+ // can not continue as supplied alias does not exist as key entry
+ throw new IOException("Can not find key entry for key store (" + ksPathURL + ") with given alias (" + alias + ")");
+ }
+ }
+
+ KeyManagerFactory keyMgrFactory = null;
+ String alg = getKeyStoreAlgorithm();
+
+ if(getProvider() != null)
+ {
+ keyMgrFactory = KeyManagerFactory.getInstance(alg, getProvider());
+ }
+ else if(getProviderName() != null)
+ {
+ keyMgrFactory = KeyManagerFactory.getInstance(alg, getProviderName());
+ }
+ else
+ {
+ keyMgrFactory = KeyManagerFactory.getInstance(alg);
+ }
+
+ // get they key password, if it isn't defined, use the key store password
+ String keyPasswd = getKeyPassword();
+ if (keyPasswd == null || keyPasswd.length() == 0)
+ {
+ keyPasswd = ksPasswd;
+ }
+
+ keyMgrFactory.init(keyStore, keyPasswd.toCharArray());
+ keyManagers = keyMgrFactory.getKeyManagers();
+
+ // if alias provided, use helper impl to hard wire alias name to be used
+ if(alias != null)
+ {
+ //TODO: -TME Need careful review of if this is really needed or not.
+ for(int x = 0; x < keyManagers.length; x++)
+ {
+ keyManagers[x] = new JBossWSKeyManager((X509KeyManager)keyManagers[x], alias);
+ }
+ }
+
+ }
+ return keyManagers;
+ }
+
+ /**
+ * Loads a key store file and returns it.
+ *
+ * @param storeType the type of store file
+ * @param storePathURL the URL to the file - may be relative to the current thread's classloader
+ * or may be absolute path to a file on the file system.
+ * @param storePassword password to gain access to the store file
+ *
+ * @return the key store
+ *
+ * @throws KeyStoreException
+ * @throws NoSuchProviderException
+ * @throws IOException
+ * @throws NoSuchAlgorithmException
+ * @throws CertificateException
+ * @throws NullStoreURLException
+ */
+ protected KeyStore loadKeyStore(String storeType, URL storePathURL, String storePassword)
+ throws KeyStoreException, NoSuchProviderException, IOException, NoSuchAlgorithmException, CertificateException, NullStoreURLException
+ {
+ KeyStore keyStore = null;
+
+ if(getProvider() != null)
+ {
+ keyStore = KeyStore.getInstance(storeType, getProvider());
+ }
+ else if(getProviderName() != null)
+ {
+ keyStore = KeyStore.getInstance(storeType, getProviderName());
+ }
+ else
+ {
+ keyStore = KeyStore.getInstance(storeType);
+ }
+
+ if ( storePathURL == null )
+ {
+ throw new NullStoreURLException("Can not find store file for url because store url is null.");
+ }
+
+ // now that keystore instance created, need to load data from file
+ InputStream keyStoreInputStream = null;
+
+ try
+ {
+ keyStoreInputStream = storePathURL.openStream();
+
+ // is ok for password to be null, as will just be used to check integrity of store
+ char[] password = storePassword != null ? storePassword.toCharArray() : null;
+ keyStore.load(keyStoreInputStream, password);
+ }
+ finally
+ {
+ if(keyStoreInputStream != null)
+ {
+ try
+ {
+ keyStoreInputStream.close();
+ }
+ catch(IOException e)
+ {
+ // no op
+ }
+ keyStoreInputStream = null;
+ }
+ }
+
+ return keyStore;
+ }
+
+ /**
+ * Given a store file path, this will verify that the store actually exists.
+ * First, it checks to see if its a valid URL, then it checks to see if the
+ * file path is found in the file system and finally will be checked to see
+ * if it can be found as a resource within the current thread's classloader.
+ * An exception is thrown if the store cannot be found.
+ *
+ * @param storePath the path which can be a URL, path to a resource in classloader
+ * or a file path on the file system.
+ *
+ * @return the URL of the file that was found
+ *
+ * @throws IOException if the store could not be found
+ */
+ protected URL validateStoreURL(String storePath) throws IOException
+ {
+ URL url = null;
+
+ // First see if this is a URL
+ try
+ {
+ url = new URL(storePath);
+ }
+ catch(MalformedURLException e)
+ {
+ // Not a URL or a protocol without a handler so...
+ // next try to locate this as file path
+ File tst = new File(storePath);
+
+ if(tst.exists() == true)
+ {
+ url = tst.toURL();
+ }
+ else
+ {
+ // not a file either, lastly try to locate this as a classpath resource
+ if(url == null)
+ {
+ ClassLoader loader = Thread.currentThread().getContextClassLoader();
+ url = loader.getResource(storePath);
+ }
+ }
+ }
+
+ // Fail if no valid key store was located
+ if(url == null)
+ {
+ String msg = "Failed to find url=" + storePath + " as a URL, file or resource";
+ throw new MalformedURLException(msg);
+ }
+
+ return url;
+ }
+
+ /**
+ * Used to indicate a store URL was not specified and thus the store is not available.
+ */
+ protected class NullStoreURLException extends Exception
+ {
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * @see Exception#Exception(String)
+ */
+ public NullStoreURLException(String message)
+ {
+ super(message);
+ }
+ }
+}
\ No newline at end of file
Property changes on: stack/native/branches/netty/modules/core/src/main/java/org/jboss/ws/core/client/ssl/SSLContextFactory.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
16 years, 4 months