[jboss-svn-commits] JBL Code SVN: r15361 - in labs/jbossesb/trunk/product: rosetta/src/org/jboss/internal/soa/esb and 5 other directories.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Tue Sep 25 10:41:15 EDT 2007


Author: tfennelly
Date: 2007-09-25 10:41:15 -0400 (Tue, 25 Sep 2007)
New Revision: 15361

Added:
   labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/remoting/
   labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/remoting/HttpUnmarshaller.java
Modified:
   labs/jbossesb/trunk/product/lib/ext/jboss-remoting.jar
   labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/gateway/JBossRemotingGatewayListener.java
   labs/jbossesb/trunk/product/samples/quickstarts/webservice_wssecurity/images/esb-console.png
   labs/jbossesb/trunk/product/samples/quickstarts/webservice_wssecurity/src/META-INF/jboss-wsse-client.xml
   labs/jbossesb/trunk/product/samples/quickstarts/webservice_wssecurity/war/resources/WEB-INF/jboss-wsse-server.xml
Log:
Verify WS-Security support when running with SOAPProcessor Action: http://jira.jboss.com/jira/browse/JBESB-730
(The message signing aspects of wsse)

Modified: labs/jbossesb/trunk/product/lib/ext/jboss-remoting.jar
===================================================================
(Binary files differ)

Added: labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/remoting/HttpUnmarshaller.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/remoting/HttpUnmarshaller.java	                        (rev 0)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/remoting/HttpUnmarshaller.java	2007-09-25 14:41:15 UTC (rev 15361)
@@ -0,0 +1,179 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * 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,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ *
+ * (C) 2005-2006, JBoss Inc.
+ */
+package org.jboss.internal.soa.esb.remoting;
+
+import org.apache.log4j.Logger;
+import org.jboss.remoting.marshal.UnMarshaller;
+import org.jboss.remoting.marshal.serializable.SerializableUnMarshaller;
+import org.jboss.remoting.transport.http.HTTPMetadataConstants;
+import org.jboss.remoting.transport.web.WebUtil;
+
+import java.io.*;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * JBoss Remoting "http" unmarshaller.
+ * <p/>
+ * This is a direct copy of the HTTPUnMarshaller class from JBossRemoting.  It fixes
+ * what we consider to be a bug in this class, which is the removal at new-line
+ * characters (CR, LF) from the message through it's use of a BufferedReader.
+ *
+ * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
+ */
+public class HttpUnmarshaller extends SerializableUnMarshaller {
+
+    static final long serialVersionUID = 1085086661310576768L;
+
+    public final static String DATATYPE = "http";
+
+    protected final Logger log = Logger.getLogger(getClass());
+
+    /**
+     * Will try to unmarshall data from inputstream.  Will try to convert to either an object
+     * or a string.  If there is no data to read, will return null.
+     *
+     * @param inputStream
+     * @param metadata
+     * @param version
+     * @return
+     * @throws IOException
+     * @throws ClassNotFoundException
+     */
+    public Object read(InputStream inputStream, Map metadata, int version) throws IOException, ClassNotFoundException {
+        if (isBinaryData(metadata)) {
+            try {
+                return super.read(inputStream, metadata, version);
+            }
+            catch (EOFException e) {
+                return null;
+            }
+        }
+
+        int contentLength = -1;
+        Object ret = null;
+        int bufferSize = 1024;
+        byte[] byteBuffer = new byte[bufferSize];
+        ByteArrayOutputStream byteOutputStream = new ByteArrayOutputStream();
+
+        // check the metadat to see if is entry for content length
+        if (metadata != null) {
+            Object value = metadata.get("Content-Length");
+            if (value == null) {
+                value = metadata.get("content-length");
+            }
+            if (value != null) {
+                if (value instanceof List) {
+                    List valueList = (List) value;
+                    if (valueList != null && valueList.size() > 0) {
+                        value = valueList.get(0);
+                    }
+                }
+                if (value instanceof String) {
+                    try {
+                        contentLength = Integer.parseInt((String) value);
+                    }
+                    catch (NumberFormatException e) {
+                        log.warn("Error converting Content-Length value (" + value + ") from metadata into int value.");
+                    }
+                } else {
+                    log.warn("Can not get Content-Length from header for http unmarshalling.");
+                }
+            }
+        }
+
+        int pointer = 0;
+        int amtRead = inputStream.read(byteBuffer);
+        while (amtRead > 0) {
+            byteOutputStream.write(byteBuffer, pointer, amtRead);
+            if (amtRead < bufferSize && byteOutputStream.size() >= contentLength) {
+                //done reading, so process
+                break;
+            }
+            amtRead = inputStream.read(byteBuffer);
+        }
+
+        byteOutputStream.flush();
+
+        byte[] totalByteArray = byteOutputStream.toByteArray();
+
+        if (totalByteArray.length == 0) {
+            //nothing to read, so is null
+            return null;
+        }
+
+        //boolean isError = isErrorReturn(metadata);
+        //if(isBinary || isError)
+
+        try {
+            ret = new String(totalByteArray);
+        }
+        catch (Exception e) {
+            log.error("Can not unmarshall inputstream.  Tried to unmarshall as both an object and string type.", e);
+            throw new IOException("Can not unmarshall inputstream.");
+        }
+
+        return ret;
+
+    }
+
+    public UnMarshaller cloneUnMarshaller() throws CloneNotSupportedException {
+        HttpUnmarshaller unmarshaller = new HttpUnmarshaller();
+        unmarshaller.setClassLoader(this.customClassLoader);
+        return unmarshaller;
+    }
+
+    private boolean isErrorReturn(Map metadata) {
+        boolean isError = false;
+        if (metadata != null) {
+            // key of null will be the response (http type, response code, and response message)
+            Object value = metadata.get(HTTPMetadataConstants.RESPONSE_CODE);
+            if (value != null && value instanceof Integer) {
+                int responseCode = ((Integer) value).intValue();
+                if (responseCode > 400) {
+                    isError = true;
+                }
+            }
+        }
+        return isError;
+    }
+
+    private boolean isBinaryData(Map metadata) throws IOException {
+        boolean isBinary = false;
+
+        if (metadata != null) {
+            // need to get the content type
+            Object value = metadata.get("Content-Type");
+            if (value == null) {
+                value = metadata.get("content-type");
+            }
+            if (value != null) {
+                if (value instanceof List) {
+                    List valueList = (List) value;
+                    if (valueList != null && valueList.size() > 0) {
+                        value = valueList.get(0);
+                    }
+                }
+                isBinary = WebUtil.isBinary((String) value);
+            }
+        }
+        return isBinary;
+    }
+}


Property changes on: labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/remoting/HttpUnmarshaller.java
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/gateway/JBossRemotingGatewayListener.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/gateway/JBossRemotingGatewayListener.java	2007-09-25 14:32:12 UTC (rev 15360)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/gateway/JBossRemotingGatewayListener.java	2007-09-25 14:41:15 UTC (rev 15361)
@@ -35,6 +35,8 @@
 import org.jboss.remoting.InvokerLocator;
 import org.jboss.remoting.ServerInvocationHandler;
 import org.jboss.remoting.ServerInvoker;
+import org.jboss.remoting.marshal.MarshalFactory;
+import org.jboss.remoting.marshal.http.HTTPMarshaller;
 import org.jboss.remoting.callback.InvokerCallbackHandler;
 import org.jboss.remoting.transport.Connector;
 import org.jboss.soa.esb.ConfigurationException;
@@ -52,6 +54,7 @@
 import org.jboss.soa.esb.message.Properties;
 import org.jboss.soa.esb.services.registry.RegistryException;
 import org.jboss.soa.esb.services.registry.RegistryFactory;
+import org.jboss.internal.soa.esb.remoting.HttpUnmarshaller;
 
 /**
  * JBoss Remoting listener implementation for receiving ESB unaware messages
@@ -140,6 +143,16 @@
     private boolean synchronous = true;
 
     /**
+     * Install our own unmarshaller for HTTP.  One that doesn't
+     * use a BufferedReader and strip away CRLF chars.
+     */
+    static {
+        MarshalFactory.addMarshaller(HttpUnmarshaller.DATATYPE,
+                MarshalFactory.getMarshaller(HttpUnmarshaller.DATATYPE),
+                new HttpUnmarshaller());
+    }
+
+    /**
      * Construct the threaded managed lifecycle.
      *
      * @param config The configuration associated with this instance.

Modified: labs/jbossesb/trunk/product/samples/quickstarts/webservice_wssecurity/images/esb-console.png
===================================================================
(Binary files differ)

Modified: labs/jbossesb/trunk/product/samples/quickstarts/webservice_wssecurity/src/META-INF/jboss-wsse-client.xml
===================================================================
--- labs/jbossesb/trunk/product/samples/quickstarts/webservice_wssecurity/src/META-INF/jboss-wsse-client.xml	2007-09-25 14:32:12 UTC (rev 15360)
+++ labs/jbossesb/trunk/product/samples/quickstarts/webservice_wssecurity/src/META-INF/jboss-wsse-client.xml	2007-09-25 14:41:15 UTC (rev 15361)
@@ -4,10 +4,10 @@
                    xsi:schemaLocation="http://www.jboss.com/ws-security/config http://www.jboss.com/ws-security/schema/jboss-ws-security_1_0.xsd">
     <config>
         <encrypt type="x509v3" alias="wsse"/>
-        <!-- sign type="x509v3" alias="wsse"/ -->
+        <sign type="x509v3" alias="wsse"/>
         <requires>
             <encryption/>
-            <!-- signature/ -->
+            <signature/>
         </requires>
     </config>
 </jboss-ws-security>
\ No newline at end of file

Modified: labs/jbossesb/trunk/product/samples/quickstarts/webservice_wssecurity/war/resources/WEB-INF/jboss-wsse-server.xml
===================================================================
--- labs/jbossesb/trunk/product/samples/quickstarts/webservice_wssecurity/war/resources/WEB-INF/jboss-wsse-server.xml	2007-09-25 14:32:12 UTC (rev 15360)
+++ labs/jbossesb/trunk/product/samples/quickstarts/webservice_wssecurity/war/resources/WEB-INF/jboss-wsse-server.xml	2007-09-25 14:41:15 UTC (rev 15361)
@@ -8,10 +8,10 @@
     <trust-store-password>jbossws</trust-store-password>
     <config>
         <encrypt type="x509v3" alias="wsse"/>
-        <!-- sign type="x509v3" alias="wsse"/ -->
+        <sign type="x509v3" alias="wsse"/>
         <requires>
             <encryption/>
-            <!-- signature/ -->
+            <signature/>
         </requires>
     </config>
 </jboss-ws-security>
\ No newline at end of file




More information about the jboss-svn-commits mailing list