[jboss-svn-commits] JBossWS SVN: r821 - in tags/jbossws-1.0.3.GA/src: main/java/org/jboss/ws/metadata/wsse main/java/org/jboss/ws/soap main/java/org/jboss/ws/wsse main/resources/schema test/ant test/java/org/jboss/test/ws/wsse test/resources/wsse test/resources/wsse/rpc/WEB-INF test/resources/wsse/rpc/WEB-INF/wsdl test/resources/wsse/sign-encrypt-fault test/resources/wsse/sign-fault

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Thu Aug 24 04:16:14 EDT 2006


Author: jason.greene at jboss.com
Date: 2006-08-24 04:16:06 -0400 (Thu, 24 Aug 2006)
New Revision: 821

Added:
   tags/jbossws-1.0.3.GA/src/test/java/org/jboss/test/ws/wsse/HelloException.java
   tags/jbossws-1.0.3.GA/src/test/java/org/jboss/test/ws/wsse/SignEncryptFaultTestCase.java
   tags/jbossws-1.0.3.GA/src/test/java/org/jboss/test/ws/wsse/SignFaultTestCase.java
   tags/jbossws-1.0.3.GA/src/test/resources/wsse/sign-encrypt-fault/
   tags/jbossws-1.0.3.GA/src/test/resources/wsse/sign-encrypt-fault/jboss-wsse-client.xml
   tags/jbossws-1.0.3.GA/src/test/resources/wsse/sign-encrypt-fault/jboss-wsse-server.xml
   tags/jbossws-1.0.3.GA/src/test/resources/wsse/sign-fault/
   tags/jbossws-1.0.3.GA/src/test/resources/wsse/sign-fault/jboss-wsse-client.xml
   tags/jbossws-1.0.3.GA/src/test/resources/wsse/sign-fault/jboss-wsse-server.xml
Removed:
   tags/jbossws-1.0.3.GA/src/test/resources/wsse/sign-encrypt-fault/jboss-wsse-client.xml
   tags/jbossws-1.0.3.GA/src/test/resources/wsse/sign-encrypt-fault/jboss-wsse-server.xml
   tags/jbossws-1.0.3.GA/src/test/resources/wsse/sign-fault/jboss-wsse-client.xml
   tags/jbossws-1.0.3.GA/src/test/resources/wsse/sign-fault/jboss-wsse-server.xml
Modified:
   tags/jbossws-1.0.3.GA/src/main/java/org/jboss/ws/metadata/wsse/Config.java
   tags/jbossws-1.0.3.GA/src/main/java/org/jboss/ws/metadata/wsse/Encrypt.java
   tags/jbossws-1.0.3.GA/src/main/java/org/jboss/ws/metadata/wsse/RequireEncryption.java
   tags/jbossws-1.0.3.GA/src/main/java/org/jboss/ws/metadata/wsse/RequireSignature.java
   tags/jbossws-1.0.3.GA/src/main/java/org/jboss/ws/metadata/wsse/Requires.java
   tags/jbossws-1.0.3.GA/src/main/java/org/jboss/ws/metadata/wsse/Sign.java
   tags/jbossws-1.0.3.GA/src/main/java/org/jboss/ws/metadata/wsse/WSSecurityConfigurationFactory.java
   tags/jbossws-1.0.3.GA/src/main/java/org/jboss/ws/soap/SOAPBodyImpl.java
   tags/jbossws-1.0.3.GA/src/main/java/org/jboss/ws/soap/SOAPFaultImpl.java
   tags/jbossws-1.0.3.GA/src/main/java/org/jboss/ws/soap/SOAPMessageImpl.java
   tags/jbossws-1.0.3.GA/src/main/java/org/jboss/ws/wsse/WSSecurityDispatcher.java
   tags/jbossws-1.0.3.GA/src/main/java/org/jboss/ws/wsse/WSSecurityHandler.java
   tags/jbossws-1.0.3.GA/src/main/java/org/jboss/ws/wsse/WSSecurityHandlerInbound.java
   tags/jbossws-1.0.3.GA/src/main/java/org/jboss/ws/wsse/WSSecurityHandlerOutbound.java
   tags/jbossws-1.0.3.GA/src/main/resources/schema/jboss-ws-security_1_0.xsd
   tags/jbossws-1.0.3.GA/src/test/ant/build-jars.xml
   tags/jbossws-1.0.3.GA/src/test/java/org/jboss/test/ws/wsse/Hello.java
   tags/jbossws-1.0.3.GA/src/test/java/org/jboss/test/ws/wsse/HelloJavaBean.java
   tags/jbossws-1.0.3.GA/src/test/java/org/jboss/test/ws/wsse/RoundTripTestCase.java
   tags/jbossws-1.0.3.GA/src/test/java/org/jboss/test/ws/wsse/RpcTestCase.java
   tags/jbossws-1.0.3.GA/src/test/resources/wsse/rpc/WEB-INF/jaxrpc-mapping.xml
   tags/jbossws-1.0.3.GA/src/test/resources/wsse/rpc/WEB-INF/wsdl/HelloService.wsdl
Log:
Merge JBWS-1145, JBWS-1147, JBWS-1119


Modified: tags/jbossws-1.0.3.GA/src/main/java/org/jboss/ws/metadata/wsse/Config.java
===================================================================
--- tags/jbossws-1.0.3.GA/src/main/java/org/jboss/ws/metadata/wsse/Config.java	2006-08-24 06:28:13 UTC (rev 820)
+++ tags/jbossws-1.0.3.GA/src/main/java/org/jboss/ws/metadata/wsse/Config.java	2006-08-24 08:16:06 UTC (rev 821)
@@ -78,6 +78,11 @@
       return username;
    }
 
+   public boolean includesFaults()
+   {
+      return (sign != null && sign.isIncludeFaults()) || (encrypt != null && encrypt.isIncludeFaults());
+   }
+
    public void setUsername(Username username)
    {
       this.username = username;

Modified: tags/jbossws-1.0.3.GA/src/main/java/org/jboss/ws/metadata/wsse/Encrypt.java
===================================================================
--- tags/jbossws-1.0.3.GA/src/main/java/org/jboss/ws/metadata/wsse/Encrypt.java	2006-08-24 06:28:13 UTC (rev 820)
+++ tags/jbossws-1.0.3.GA/src/main/java/org/jboss/ws/metadata/wsse/Encrypt.java	2006-08-24 08:16:06 UTC (rev 821)
@@ -35,16 +35,16 @@
    private static final long serialVersionUID = -2802677183149218760L;
 
    private String type;
-
    private String alias;
-
    private String algorithm;
+   private boolean includeFaults;
 
-   public Encrypt(String type, String alias, String algorithm)
+   public Encrypt(String type, String alias, String algorithm, boolean includeFaults)
    {
       this.type = type;
       this.alias = alias;
       this.algorithm = algorithm;
+      this.includeFaults = includeFaults;
    }
 
    public String getAlias()
@@ -76,4 +76,14 @@
    {
       this.algorithm = algorithm;
    }
+
+   public boolean isIncludeFaults()
+   {
+      return includeFaults;
+   }
+
+   public void setIncludeFaults(boolean includeFaults)
+   {
+      this.includeFaults = includeFaults;
+   }
 }
\ No newline at end of file

Modified: tags/jbossws-1.0.3.GA/src/main/java/org/jboss/ws/metadata/wsse/RequireEncryption.java
===================================================================
--- tags/jbossws-1.0.3.GA/src/main/java/org/jboss/ws/metadata/wsse/RequireEncryption.java	2006-08-24 06:28:13 UTC (rev 820)
+++ tags/jbossws-1.0.3.GA/src/main/java/org/jboss/ws/metadata/wsse/RequireEncryption.java	2006-08-24 08:16:06 UTC (rev 821)
@@ -31,4 +31,21 @@
 public class RequireEncryption extends Targetable
 {
    private static final long serialVersionUID = 3765798680988205647L;
+
+   private boolean includeFaults;
+
+   public RequireEncryption(boolean includeFaults)
+   {
+      this.includeFaults = includeFaults;
+   }
+
+   public boolean isIncludeFaults()
+   {
+      return includeFaults;
+   }
+
+   public void setIncludeFaults(boolean includeFaults)
+   {
+      this.includeFaults = includeFaults;
+   }
 }

Modified: tags/jbossws-1.0.3.GA/src/main/java/org/jboss/ws/metadata/wsse/RequireSignature.java
===================================================================
--- tags/jbossws-1.0.3.GA/src/main/java/org/jboss/ws/metadata/wsse/RequireSignature.java	2006-08-24 06:28:13 UTC (rev 820)
+++ tags/jbossws-1.0.3.GA/src/main/java/org/jboss/ws/metadata/wsse/RequireSignature.java	2006-08-24 08:16:06 UTC (rev 821)
@@ -22,8 +22,7 @@
 package org.jboss.ws.metadata.wsse;
 
 /**
- * <code>Sign</code> represents the sign tag, which declares that a message
- * should be signed.
+ * <code>RequireSignature</code> indicates that a message received from a peer must be signed.
  *
  * @author <a href="mailto:jason.greene at jboss.com">Jason T. Greene</a>
  * @version $Revision$
@@ -31,4 +30,21 @@
 public class RequireSignature extends Targetable
 {
    private static final long serialVersionUID = -3854930944550152309L;
-}
+
+   private boolean includeFaults;
+
+   public RequireSignature(boolean includeFaults)
+   {
+      this.includeFaults = includeFaults;
+   }
+
+   public boolean isIncludeFaults()
+   {
+      return includeFaults;
+   }
+
+   public void setIncludeFaults(boolean includeFaults)
+   {
+      this.includeFaults = includeFaults;
+   }
+}
\ No newline at end of file

Modified: tags/jbossws-1.0.3.GA/src/main/java/org/jboss/ws/metadata/wsse/Requires.java
===================================================================
--- tags/jbossws-1.0.3.GA/src/main/java/org/jboss/ws/metadata/wsse/Requires.java	2006-08-24 06:28:13 UTC (rev 820)
+++ tags/jbossws-1.0.3.GA/src/main/java/org/jboss/ws/metadata/wsse/Requires.java	2006-08-24 08:16:06 UTC (rev 821)
@@ -68,4 +68,10 @@
    {
       this.requireTimestamp = requireTimestamp;
    }
+
+   public boolean includesFaults()
+   {
+      return (requireSignature != null && requireSignature.isIncludeFaults())
+         || (requireEncryption != null && requireEncryption.isIncludeFaults());
+   }
 }

Modified: tags/jbossws-1.0.3.GA/src/main/java/org/jboss/ws/metadata/wsse/Sign.java
===================================================================
--- tags/jbossws-1.0.3.GA/src/main/java/org/jboss/ws/metadata/wsse/Sign.java	2006-08-24 06:28:13 UTC (rev 820)
+++ tags/jbossws-1.0.3.GA/src/main/java/org/jboss/ws/metadata/wsse/Sign.java	2006-08-24 08:16:06 UTC (rev 821)
@@ -33,16 +33,17 @@
    private static final long serialVersionUID = -2645745357707804441L;
 
    private String type;
-
    private String alias;
-
    private boolean includeTimestamp;
+   private boolean includeFaults;
 
-   public Sign(String type, String alias, boolean includeTimestamp)
+
+   public Sign(String type, String alias, boolean includeTimestamp, boolean includeFaults)
    {
       this.type = type;
       this.alias = alias;
       this.includeTimestamp = includeTimestamp;
+      this.includeFaults = includeFaults;
    }
 
    public String getAlias()
@@ -60,6 +61,16 @@
       return type;
    }
 
+   public boolean isIncludeFaults()
+   {
+      return includeFaults;
+   }
+
+   public void setIncludeFaults(boolean includeFaults)
+   {
+      this.includeFaults = includeFaults;
+   }
+
    public void setType(String type)
    {
       this.type = type;

Modified: tags/jbossws-1.0.3.GA/src/main/java/org/jboss/ws/metadata/wsse/WSSecurityConfigurationFactory.java
===================================================================
--- tags/jbossws-1.0.3.GA/src/main/java/org/jboss/ws/metadata/wsse/WSSecurityConfigurationFactory.java	2006-08-24 06:28:13 UTC (rev 820)
+++ tags/jbossws-1.0.3.GA/src/main/java/org/jboss/ws/metadata/wsse/WSSecurityConfigurationFactory.java	2006-08-24 08:16:06 UTC (rev 821)
@@ -49,7 +49,7 @@
 
    public static String CLIENT_RESOURCE_NAME = "jboss-wsse-client.xml";
 
-   private static HashMap options = new HashMap(6);
+   private static HashMap<String, String> options = new HashMap<String, String>(6);
 
    static
    {
@@ -97,6 +97,7 @@
       }
       catch (JBossXBException e)
       {
+         log.error("Could not parse " + configurationFile + ":", e);
          IOException ioex = new IOException("Cannot parse: " + configurationFile);
          Throwable cause = e.getCause();
          if (cause != null)
@@ -189,16 +190,26 @@
       if ("sign".equals(localName))
       {
          // By default, we alwyas include a timestamp
-         Boolean include = new Boolean(true);
-         String timestamp = attrs.getValue("", "includeTimestamp");
-         if (timestamp != null)
-            include = (Boolean) SimpleTypeBindings.unmarshal(timestamp, SimpleTypeBindings.XS_BOOLEAN_NAME, null);
+         boolean includeTimestamp = true;
+         String value = attrs.getValue("", "includeTimestamp");
+         if (value != null)
+            includeTimestamp = (Boolean) SimpleTypeBindings.unmarshal(SimpleTypeBindings.XS_BOOLEAN_NAME, value, null);
 
-         return new Sign(attrs.getValue("", "type"), attrs.getValue("", "alias"), include.booleanValue());
+         boolean includeFaults = false;
+         value = attrs.getValue("", "includeFaults");
+         if (value != null)
+            includeFaults = (Boolean) SimpleTypeBindings.unmarshal(SimpleTypeBindings.XS_BOOLEAN_NAME, value, null);
+
+         return new Sign(attrs.getValue("", "type"), attrs.getValue("", "alias"), includeTimestamp, includeFaults);
       }
       else if ("encrypt".equals(localName))
       {
-         return new Encrypt(attrs.getValue("", "type"), attrs.getValue("", "alias"), attrs.getValue("", "algorithm"));
+         boolean includeFaults = false;
+         String value = attrs.getValue("", "includeFaults");
+         if (value != null)
+            includeFaults = (Boolean) SimpleTypeBindings.unmarshal(SimpleTypeBindings.XS_BOOLEAN_NAME, value, null);
+
+         return new Encrypt(attrs.getValue("", "type"), attrs.getValue("", "alias"), attrs.getValue("", "algorithm"), includeFaults);
       }
       else if ("timestamp".equals(localName))
       {
@@ -300,11 +311,21 @@
       log.trace("newChild: " + localName);
       if ("signature".equals(localName))
       {
-         return new RequireSignature();
+         boolean includeFaults = false;
+         String value = attrs.getValue("", "includeFaults");
+         if (value != null)
+            includeFaults = (Boolean) SimpleTypeBindings.unmarshal(SimpleTypeBindings.XS_BOOLEAN_NAME, value, null);
+
+         return new RequireSignature(includeFaults);
       }
       else if ("encryption".equals(localName))
       {
-         return new RequireEncryption();
+         boolean includeFaults = false;
+         String value = attrs.getValue("", "includeFaults");
+         if (value != null)
+            includeFaults = (Boolean) SimpleTypeBindings.unmarshal(SimpleTypeBindings.XS_BOOLEAN_NAME, value, null);
+
+         return new RequireEncryption(includeFaults);
       }
       else if ("timestamp".equals(localName))
       {

Modified: tags/jbossws-1.0.3.GA/src/main/java/org/jboss/ws/soap/SOAPBodyImpl.java
===================================================================
--- tags/jbossws-1.0.3.GA/src/main/java/org/jboss/ws/soap/SOAPBodyImpl.java	2006-08-24 06:28:13 UTC (rev 820)
+++ tags/jbossws-1.0.3.GA/src/main/java/org/jboss/ws/soap/SOAPBodyImpl.java	2006-08-24 08:16:06 UTC (rev 821)
@@ -52,6 +52,7 @@
  * A SOAPFault object, which carries status and/or error information, is an example of a SOAPBodyElement object.
  *
  * @author Thomas.Diesler at jboss.org
+ * @author <a href="jason.greene at jboss.com">Jason T. Greene</a>
  */
 public class SOAPBodyImpl extends SOAPElementImpl implements SOAPBody
 {
@@ -65,13 +66,40 @@
    /** Convert the child into a SOAPBodyElement */
    public SOAPElement addChildElement(SOAPElement child) throws SOAPException
    {
-      if ((child instanceof SOAPBodyElement) == false)
-         child = convertToBodyElement(child);
+      if (!(child instanceof SOAPBodyElement))
+      {
+         child = isFault(child) ? convertToSOAPFault(child) : convertToBodyElement(child);
+      }
 
       child = super.addChildElement(child);
       return child;
    }
 
+   private boolean isFault(Node node)
+   {
+      return "Fault".equals(node.getLocalName()) && getNamespaceURI().equals(node.getNamespaceURI());
+   }
+
+   private SOAPElement convertToSOAPFault(Node node)
+   {
+      if (!(node instanceof SOAPElementImpl))
+         throw new IllegalArgumentException("SOAPElementImpl expected");
+
+      SOAPElementImpl element = (SOAPElementImpl) node;
+      element.detachNode();
+      return new SOAPFaultImpl(element);
+   }
+
+   private SOAPBodyElementDoc convertToBodyElement(Node node)
+   {
+      if (!(node instanceof SOAPElementImpl))
+         throw new IllegalArgumentException("SOAPElementImpl expected");
+
+      SOAPElementImpl element = (SOAPElementImpl) node;
+      element.detachNode();
+      return new SOAPBodyElementDoc(element);
+   }
+
    public SOAPBodyElement addBodyElement(Name name) throws SOAPException
    {
       SOAPBodyElement child = new SOAPBodyElementDoc(name);
@@ -131,42 +159,34 @@
 
    public Node appendChild(Node newChild) throws DOMException
    {
-      Node retNode;
-      if (! (newChild instanceof SOAPBodyElement || newChild instanceof DocumentFragment))
+      if (!(newChild instanceof SOAPBodyElement || newChild instanceof DocumentFragment))
       {
-         newChild = convertToBodyElement(newChild);
+         newChild = isFault(newChild) ? convertToSOAPFault(newChild) : convertToBodyElement(newChild);
       }
-      retNode = super.appendChild(newChild);
-      return retNode;
+
+      return super.appendChild(newChild);
    }
 
    public Node insertBefore(Node newChild, Node refChild) throws DOMException
    {
-      if (! (newChild instanceof SOAPBodyElement || newChild instanceof DocumentFragment))
-         newChild = convertToBodyElement(newChild);
+      if (!(newChild instanceof SOAPBodyElement || newChild instanceof DocumentFragment))
+      {
+         newChild = isFault(newChild) ? convertToSOAPFault(newChild) : convertToBodyElement(newChild);
+      }
 
       return super.insertBefore(newChild, refChild);
    }
 
    public Node replaceChild(Node newChild, Node oldChild) throws DOMException
    {
-      if (! (newChild instanceof SOAPBodyElement || newChild instanceof DocumentFragment))
+      if (!(newChild instanceof SOAPBodyElement || newChild instanceof DocumentFragment))
       {
-         newChild = convertToBodyElement(newChild);
+         newChild = isFault(newChild) ? convertToSOAPFault(newChild) : convertToBodyElement(newChild);
       }
 
       return super.replaceChild(newChild, oldChild);
    }
 
-   private SOAPBodyElementDoc convertToBodyElement(Node node)
-   {
-      if (!(node instanceof SOAPElementImpl))
-         throw new IllegalArgumentException("SOAPElement expected");
-
-      SOAPElementImpl element = (SOAPElementImpl) node;
-      element.detachNode();
-      return new SOAPBodyElementDoc(element);
-   }
    public String write(Writer writer, boolean pretty) {
       try
       {
@@ -203,5 +223,5 @@
       {
          throw new WSException(e.getMessage());
       }
-   }  
-}
+   }
+}
\ No newline at end of file

Modified: tags/jbossws-1.0.3.GA/src/main/java/org/jboss/ws/soap/SOAPFaultImpl.java
===================================================================
--- tags/jbossws-1.0.3.GA/src/main/java/org/jboss/ws/soap/SOAPFaultImpl.java	2006-08-24 06:28:13 UTC (rev 820)
+++ tags/jbossws-1.0.3.GA/src/main/java/org/jboss/ws/soap/SOAPFaultImpl.java	2006-08-24 08:16:06 UTC (rev 821)
@@ -55,6 +55,7 @@
  * goes only to the default actor, which is the final intended recipient.
  *
  * @author Thomas.Diesler at jboss.org
+ * @author <a href="jason.greene at jboss.com"/>Jason T. Greene</a>
  */
 public class SOAPFaultImpl extends SOAPBodyElementDoc implements SOAPFault
 {
@@ -69,11 +70,13 @@
    public SOAPFaultImpl(String namespaceURI) throws SOAPException
    {
       super(new NameImpl("Fault", Constants.PREFIX_ENV, namespaceURI));
-      SOAPFactoryImpl factory = new SOAPFactoryImpl();
-      addChildElement(faultcode = factory.createElement("faultcode"));
-      addChildElement(faultstring = factory.createElement("faultstring"));
    }
 
+   public SOAPFaultImpl(SOAPElementImpl element)
+   {
+      super(element);
+   }
+
    /** Creates an optional Detail object and sets it as the Detail object for this SOAPFault  object.
     */
    public Detail addDetail() throws SOAPException
@@ -131,13 +134,31 @@
     */
    public String getFaultActor()
    {
-      return (faultactor != null ? faultactor.getValue() : null);
+      if (faultactor == null)
+      {
+         Element domFaultCode = DOMUtils.getFirstChildElement(this, new QName("faultactor"));
+         if (domFaultCode instanceof SOAPElement)
+            faultactor = (SOAPElement)domFaultCode;
+         else
+            return null;
+      }
+
+      return faultactor.getValue();
    }
 
    /** Gets the fault code for this SOAPFault object.
     */
    public String getFaultCode()
    {
+      if (faultcode == null)
+      {
+         Element domFaultCode = DOMUtils.getFirstChildElement(this, new QName("faultcode"));
+         if (domFaultCode instanceof SOAPElement)
+            faultcode = (SOAPElement)domFaultCode;
+         else
+            return null;
+      }
+
       String value = faultcode.getValue();
       return value;
    }
@@ -147,7 +168,7 @@
     */
    public Name getFaultCodeAsName()
    {
-      QName qname = QNameBuilder.buildQName(this, faultcode.getValue());
+      QName qname = QNameBuilder.buildQName(this, getFaultCode());
       return new NameImpl(qname);
    }
 
@@ -155,6 +176,15 @@
     */
    public String getFaultString()
    {
+      if (faultstring == null)
+      {
+         Element domFaultCode = DOMUtils.getFirstChildElement(this, new QName("faultstring"));
+         if (domFaultCode instanceof SOAPElement)
+            faultstring = (SOAPElement)domFaultCode;
+         else
+            return null;
+      }
+
       String value = faultstring.getValue();
       return value;
    }
@@ -170,7 +200,7 @@
     */
    public void setFaultActor(String faultActor) throws SOAPException
    {
-      if (faultactor == null)
+      if (getFaultActor() == null)
       {
          SOAPFactoryImpl factory = new SOAPFactoryImpl();
          addChildElement(faultactor = factory.createElement("faultactor"));
@@ -199,7 +229,7 @@
       String prefix = faultName.getPrefix();
       String localName = faultName.getLocalName();
 
-      // For lazy folkes like the CTS that don't bother to give 
+      // For lazy folkes like the CTS that don't bother to give
       // a namesapce URI, assume they use a standard code
       if ("".equals(nsURI))
       {
@@ -215,6 +245,13 @@
          addNamespaceDeclaration(prefix, nsURI);
 
       String faultCode = prefix + ":" + localName;
+
+      if (getFaultCode() == null)
+      {
+         SOAPFactoryImpl factory = new SOAPFactoryImpl();
+         addChildElement(faultcode = factory.createElement("faultcode"));
+      }
+
       faultcode.setValue(faultCode);
    }
 
@@ -222,6 +259,12 @@
     */
    public void setFaultString(String faultString) throws SOAPException
    {
+      if (getFaultString() == null)
+      {
+         SOAPFactoryImpl factory = new SOAPFactoryImpl();
+         addChildElement(faultstring = factory.createElement("faultstring"));
+      }
+
       faultstring.setValue(faultString);
    }
 

Modified: tags/jbossws-1.0.3.GA/src/main/java/org/jboss/ws/soap/SOAPMessageImpl.java
===================================================================
--- tags/jbossws-1.0.3.GA/src/main/java/org/jboss/ws/soap/SOAPMessageImpl.java	2006-08-24 06:28:13 UTC (rev 820)
+++ tags/jbossws-1.0.3.GA/src/main/java/org/jboss/ws/soap/SOAPMessageImpl.java	2006-08-24 08:16:06 UTC (rev 821)
@@ -52,6 +52,7 @@
    private List<AttachmentPart> attachments = new LinkedList<AttachmentPart>();
    private CIDGenerator cidGenerator = new CIDGenerator();
    private boolean isXOPMessage;
+   private boolean faultMessage;
    private SOAPPartImpl soapPart;
    private MultipartRelatedEncoder multipartRelatedEncoder;
 
@@ -287,8 +288,23 @@
       return opMetaData;
    }
 
+   /**
+    * Marks this <code>SOAPMessage</code> as a fault. Otherwise, the message
+    * will be checked for a SOAPFault. The reason for this is to allow for
+    * faults to be encrypted, in which case there is no SOAPFault.
+    *
+    * @param faultMessage whether this message is a fault
+    */
+   public void setFaultMessage(boolean faultMessage)
+   {
+      this.faultMessage = faultMessage;
+   }
+
    public boolean isFaultMessage()
    {
+      if (faultMessage)
+         return true;
+
       SOAPFault soapFault = null;
       try
       {

Modified: tags/jbossws-1.0.3.GA/src/main/java/org/jboss/ws/wsse/WSSecurityDispatcher.java
===================================================================
--- tags/jbossws-1.0.3.GA/src/main/java/org/jboss/ws/wsse/WSSecurityDispatcher.java	2006-08-24 06:28:13 UTC (rev 820)
+++ tags/jbossws-1.0.3.GA/src/main/java/org/jboss/ws/wsse/WSSecurityDispatcher.java	2006-08-24 08:16:06 UTC (rev 821)
@@ -114,9 +114,7 @@
 
       if (secHeaderElement == null)
       {
-         // This is ok, we always allow faults to be received because WS-Security does not encrypt faults
-         if (soapMessage.getSOAPBody().getFault() != null)
-            return;
+         boolean fault = soapMessage.getSOAPBody().getFault() != null;
 
          OperationMetaData opMetaData = ctx.getOperationMetaData();
          if (opMetaData == null)
@@ -130,7 +128,7 @@
          String operation = opMetaData.getXmlName().toString();
          String port = opMetaData.getEndpointMetaData().getName().getLocalPart();
 
-         if (hasRequirements(config, operation, port))
+         if (hasRequirements(config, operation, port, fault))
             throw convertToFault(new InvalidSecurityHeaderException("This service requires <wsse:Security>, which is missing."));
 
          return;
@@ -143,7 +141,8 @@
          SecurityDecoder decoder = new SecurityDecoder(securityStore);
 
          decoder.decode(soapMessage.getSOAPPart(), secHeaderElement);
-         log.debug("Decoded WS-Security Encoded Message:\n" + DOMWriter.printNode(soapMessage.getSOAPPart(), true));
+         if (log.isDebugEnabled())
+            log.debug("Decoded WS-Security Encoded Message:\n" + DOMWriter.printNode(soapMessage.getSOAPPart(), true));
 
          OperationMetaData opMetaData = ctx.getOperationMetaData();
          if (opMetaData == null)
@@ -156,11 +155,13 @@
 
          String operation = opMetaData.getXmlName().toString();
          String port = opMetaData.getEndpointMetaData().getName().getLocalPart();
+         boolean fault = soapMessage.getSOAPBody().getFault() != null;
 
-         List<OperationDescription<RequireOperation>> operations = buildRequireOperations(config, operation, port);
+         List<OperationDescription<RequireOperation>> operations = buildRequireOperations(config, operation, port, fault);
 
          decoder.verify(operations);
-         log.debug("Verification is successful");
+         if (log.isDebugEnabled())
+            log.debug("Verification is successful");
 
          decoder.complete();
       }
@@ -183,13 +184,14 @@
       return config;
    }
 
-   private static boolean hasRequirements(WSSecurityConfiguration config, String operation, String port)
+   private static boolean hasRequirements(WSSecurityConfiguration config, String operation, String port, boolean fault)
    {
       Config operationConfig = getConfig(config, port, operation);
-      return (operationConfig != null && operationConfig.getRequires() != null);
+      Requires requires = (operationConfig != null) ? operationConfig.getRequires() : null;
+      return requires != null && (!fault || requires.includesFaults());
    }
 
-   private static List<OperationDescription<RequireOperation>> buildRequireOperations(WSSecurityConfiguration config, String operation, String port)
+   private static List<OperationDescription<RequireOperation>> buildRequireOperations(WSSecurityConfiguration config, String operation, String port, boolean fault)
    {
       Config operationConfig = getConfig(config, port, operation);
       if (operationConfig == null)
@@ -205,14 +207,14 @@
          operations.add(new OperationDescription<RequireOperation>(RequireTimestampOperation.class, null, requireTimestamp.getMaxAge(), null, null));
 
       RequireSignature requireSignature = requires.getRequireSignature();
-      if (requireSignature != null)
+      if (requireSignature != null && (!fault || requireSignature.isIncludeFaults()))
       {
          List<Target> targets = convertTargets(requireSignature.getTargets());
          operations.add(new OperationDescription<RequireOperation>(RequireSignatureOperation.class, targets, null, null, null));
       }
 
       RequireEncryption requireEncryption = requires.getRequireEncryption();
-      if (requireEncryption != null)
+      if (requireEncryption != null && (!fault || requireEncryption.isIncludeFaults()))
       {
          List<Target> targets = convertTargets(requireEncryption.getTargets());
          operations.add(new OperationDescription<RequireOperation>(RequireEncryptionOperation.class, targets, null, null, null));
@@ -225,6 +227,7 @@
    {
       WSSecurityConfiguration config = getSecurityConfig(ctx);
       SOAPMessageImpl soapMessage = (SOAPMessageImpl)ctx.getMessage();
+      boolean fault = soapMessage.getSOAPBody().getFault() != null;
 
       OperationMetaData opMetaData = ctx.getOperationMetaData();
       String operation = opMetaData.getXmlName().toString();
@@ -234,7 +237,7 @@
 
       log.debug("WS-Security config:" + operationConfig);
       // Nothing to process
-      if (operationConfig == null)
+      if (operationConfig == null || (fault && !operationConfig.includesFaults()))
          return;
 
       ArrayList<OperationDescription<EncodingOperation>> operations = new ArrayList<OperationDescription<EncodingOperation>>();
@@ -257,7 +260,7 @@
       }
 
       Sign sign = operationConfig.getSign();
-      if (sign != null)
+      if (sign != null && (!fault || sign.isIncludeFaults()))
       {
          List<Target> targets = convertTargets(sign.getTargets());
          if (sign.isIncludeTimestamp())
@@ -273,7 +276,7 @@
       }
 
       Encrypt encrypt = operationConfig.getEncrypt();
-      if (encrypt != null)
+      if (encrypt != null && (!fault || encrypt.isIncludeFaults()))
       {
          List<Target> targets = convertTargets(encrypt.getTargets());
          operations.add(new OperationDescription<EncodingOperation>(EncryptionOperation.class, targets, encrypt.getAlias(), null, encrypt.getAlgorithm()));
@@ -282,7 +285,8 @@
       if (operations.size() == 0)
          return;
 
-      log.debug("Encoding Message:\n" + DOMWriter.printNode(soapMessage.getSOAPPart(), true));
+      if (log.isDebugEnabled())
+         log.debug("Encoding Message:\n" + DOMWriter.printNode(soapMessage.getSOAPPart(), true));
 
       try
       {

Modified: tags/jbossws-1.0.3.GA/src/main/java/org/jboss/ws/wsse/WSSecurityHandler.java
===================================================================
--- tags/jbossws-1.0.3.GA/src/main/java/org/jboss/ws/wsse/WSSecurityHandler.java	2006-08-24 06:28:13 UTC (rev 820)
+++ tags/jbossws-1.0.3.GA/src/main/java/org/jboss/ws/wsse/WSSecurityHandler.java	2006-08-24 08:16:06 UTC (rev 821)
@@ -26,6 +26,7 @@
 import javax.xml.namespace.QName;
 import javax.xml.rpc.handler.GenericHandler;
 import javax.xml.rpc.handler.MessageContext;
+import javax.xml.rpc.soap.SOAPFaultException;
 import javax.xml.soap.SOAPException;
 
 import org.jboss.logging.Logger;
@@ -41,16 +42,25 @@
  */
 public abstract class WSSecurityHandler extends GenericHandler
 {
+   protected static String FAULT_THROWN = "org.jboss.ws.wsse.faultThrown";
+
    // provide logging
    private static Logger log = Logger.getLogger(WSSecurityHandler.class);
-   
+
    public QName[] getHeaders()
    {
       return null;
    }
 
+   protected boolean thrownByMe(MessageContext msgContext)
+   {
+      Boolean bool = (Boolean) msgContext.getProperty(FAULT_THROWN);
+      return bool != null && bool.booleanValue();
+   }
+
    protected boolean handleInboundSecurity(MessageContext msgContext)
    {
+      Exception exception = null;
       try
       {
          if (getSecurityConfiguration(msgContext) != null)
@@ -58,16 +68,28 @@
             WSSecurityDispatcher.handleInbound((SOAPMessageContextImpl)msgContext);
          }
       }
-      catch (SOAPException ex)
+      catch (Exception ex)
       {
-         log.error("Cannot handle inbound ws-security", ex);
+         exception = ex;
+      }
+
+      if (exception != null)
+      {
+         msgContext.setProperty(FAULT_THROWN, true);
+         if (exception instanceof SOAPFaultException)
+            throw (SOAPFaultException)exception;
+
+         // Unexpected exception, log it
+         log.error("Cannot handle inbound ws-security", exception);
          return false;
       }
+
       return true;
    }
 
    protected boolean handleOutboundSecurity(MessageContext msgContext)
    {
+      Exception exception = null;
       try
       {
          if (getSecurityConfiguration(msgContext) != null)
@@ -75,11 +97,22 @@
             WSSecurityDispatcher.handleOutbound((SOAPMessageContextImpl)msgContext);
          }
       }
-      catch (SOAPException ex)
+      catch (Exception ex)
       {
-         log.error("Cannot handle outbound ws-security", ex);
+         exception = ex;
+      }
+
+      if (exception != null)
+      {
+         msgContext.setProperty(FAULT_THROWN, true);
+         if (exception instanceof SOAPFaultException)
+            throw (SOAPFaultException)exception;
+
+         // Unexpected exception, log it
+         log.error("Cannot handle outbound ws-security", exception);
          return false;
       }
+
       return true;
    }
 
@@ -89,7 +122,7 @@
       WSSecurityConfiguration securityConfiguration = epMetaData.getServiceMetaData().getSecurityConfiguration();
       if (securityConfiguration == null)
          log.warn("Cannot obtain security configuration");
-      
+
       return securityConfiguration;
    }
-}
+}
\ No newline at end of file

Modified: tags/jbossws-1.0.3.GA/src/main/java/org/jboss/ws/wsse/WSSecurityHandlerInbound.java
===================================================================
--- tags/jbossws-1.0.3.GA/src/main/java/org/jboss/ws/wsse/WSSecurityHandlerInbound.java	2006-08-24 06:28:13 UTC (rev 820)
+++ tags/jbossws-1.0.3.GA/src/main/java/org/jboss/ws/wsse/WSSecurityHandlerInbound.java	2006-08-24 08:16:06 UTC (rev 821)
@@ -24,7 +24,10 @@
 // $Id$
 
 import javax.xml.rpc.handler.MessageContext;
+import javax.xml.rpc.handler.soap.SOAPMessageContext;
 
+import org.jboss.ws.soap.SOAPMessageImpl;
+
 /**
  * A JAXRPC handler that delegates to the WSSecurityDispatcher
  * where the request is an inbound message.
@@ -43,4 +46,16 @@
    {
       return handleOutboundSecurity(msgContext);
    }
-}
+
+   public boolean handleFault(MessageContext msgContext)
+   {
+      // Skip any WS-Security Faults
+      if (thrownByMe(msgContext))
+         return true;
+
+      // Mark the message as a fault, in case it ends up being encrypted
+      ((SOAPMessageImpl)((SOAPMessageContext)msgContext).getMessage()).setFaultMessage(true);
+
+      return handleOutboundSecurity(msgContext);
+   }
+}
\ No newline at end of file

Modified: tags/jbossws-1.0.3.GA/src/main/java/org/jboss/ws/wsse/WSSecurityHandlerOutbound.java
===================================================================
--- tags/jbossws-1.0.3.GA/src/main/java/org/jboss/ws/wsse/WSSecurityHandlerOutbound.java	2006-08-24 06:28:13 UTC (rev 820)
+++ tags/jbossws-1.0.3.GA/src/main/java/org/jboss/ws/wsse/WSSecurityHandlerOutbound.java	2006-08-24 08:16:06 UTC (rev 821)
@@ -42,4 +42,19 @@
    {
       return handleInboundSecurity(msgContext);
    }
+
+   /* Their is a potential problem that can't be avoided using the JAX-RPC handler framework.
+    * If a request handler (outbound for the client) throws an exception, this will get called,
+    * but it will be incorrectly treated as an inbound message.
+    *
+    * This is intended to be called when the response message from the server (inbound)
+    * is a fault message.
+    */
+   public boolean handleFault(MessageContext msgContext)
+   {
+      if (thrownByMe(msgContext))
+         return true;
+
+      return handleInboundSecurity(msgContext);
+   }
 }

Modified: tags/jbossws-1.0.3.GA/src/main/resources/schema/jboss-ws-security_1_0.xsd
===================================================================
--- tags/jbossws-1.0.3.GA/src/main/resources/schema/jboss-ws-security_1_0.xsd	2006-08-24 06:28:13 UTC (rev 820)
+++ tags/jbossws-1.0.3.GA/src/main/resources/schema/jboss-ws-security_1_0.xsd	2006-08-24 08:16:06 UTC (rev 821)
@@ -86,11 +86,13 @@
     <xs:sequence>
       <xs:element name="targets" type="targetsType" minOccurs="0"/>
     </xs:sequence>
+    <xs:attribute name="includeFaults" type="xs:boolean" use="optional" default="false"/>
   </xs:complexType>
   <xs:complexType name="requireSignatureType">
     <xs:sequence>
       <xs:element name="targets" type="targetsType" minOccurs="0"/>
     </xs:sequence>
+    <xs:attribute name="includeFaults" type="xs:boolean" use="optional" default="false"/>
   </xs:complexType>
   <xs:complexType name="requiresType">
     <xs:all>
@@ -144,7 +146,7 @@
         <xs:documentation>The name of the certificate to use.</xs:documentation>
       </xs:annotation>
     </xs:attribute>
-    <xs:attribute name="algorithm">
+    <xs:attribute name="algorithm" use="prohibited">
       <xs:annotation>
         <xs:documentation>The symmetric encryption algorithm to use.  If not specified aes-128 will be used.</xs:documentation>
       </xs:annotation>
@@ -157,6 +159,7 @@
         </xs:restriction>
       </xs:simpleType>
     </xs:attribute>
+    <xs:attribute name="includeFaults" type="xs:boolean" use="optional" default="false"/>
   </xs:complexType>
   <xs:complexType name="signType">
     <xs:sequence>
@@ -171,6 +174,7 @@
     </xs:attribute>
     <xs:attribute name="alias" type="xs:string" use="required"/>
     <xs:attribute name="includeTimestamp" type="xs:boolean" use="optional"/>
+    <xs:attribute name="includeFaults" type="xs:boolean" use="optional" default="false"/>
   </xs:complexType>
   <xs:complexType name="operationType">
     <xs:sequence>

Modified: tags/jbossws-1.0.3.GA/src/test/ant/build-jars.xml
===================================================================
--- tags/jbossws-1.0.3.GA/src/test/ant/build-jars.xml	2006-08-24 06:28:13 UTC (rev 820)
+++ tags/jbossws-1.0.3.GA/src/test/ant/build-jars.xml	2006-08-24 08:16:06 UTC (rev 821)
@@ -1848,6 +1848,7 @@
     <war warfile="${build.test.dir}/libs/jbossws-wsse-rpc.war" webxml="${build.test.dir}/resources/wsse/rpc/WEB-INF/web.xml">
       <classes dir="${build.test.dir}/classes">
         <include name="org/jboss/test/ws/wsse/Hello.class"/>
+        <include name="org/jboss/test/ws/wsse/HelloException.class"/>
         <include name="org/jboss/test/ws/wsse/HelloJavaBean.class"/>
         <include name="org/jboss/test/ws/wsse/UserType.class"/>
       </classes>
@@ -1868,6 +1869,7 @@
     <jar jarfile="${build.test.dir}/libs/jbossws-wsse-rpc-client.jar">
       <fileset dir="${build.test.dir}/classes">
         <include name="org/jboss/test/ws/wsse/Hello.class"/>
+        <include name="org/jboss/test/ws/wsse/HelloException.class"/>
         <include name="org/jboss/test/ws/wsse/UserType.class"/>
       </fileset>
       <metainf dir="${build.test.dir}/resources/wsse/rpc/META-INF">
@@ -1885,6 +1887,7 @@
     <jar jarfile="${build.test.dir}/libs/jbossws-wsse-rpc-noconfig-client.jar">
       <fileset dir="${build.test.dir}/classes">
         <include name="org/jboss/test/ws/wsse/Hello.class"/>
+        <include name="org/jboss/test/ws/wsse/HelloException.class"/>
         <include name="org/jboss/test/ws/wsse/UserType.class"/>
       </fileset>
       <metainf dir="${build.test.dir}/resources/wsse/rpc/META-INF">
@@ -1902,6 +1905,7 @@
       <classes dir="${build.test.dir}/classes">
         <include name="org/jboss/test/ws/wsse/Hello.class"/>
         <include name="org/jboss/test/ws/wsse/HelloJavaBean.class"/>
+        <include name="org/jboss/test/ws/wsse/HelloException.class"/>
         <include name="org/jboss/test/ws/wsse/UserType.class"/>
       </classes>
       <webinf dir="${build.test.dir}/resources/wsse/rpc/WEB-INF">
@@ -1923,6 +1927,7 @@
     <jar jarfile="${build.test.dir}/libs/jbossws-wsse-simple-sign-encrypt-client.jar">
       <fileset dir="${build.test.dir}/classes">
         <include name="org/jboss/test/ws/wsse/Hello.class"/>
+        <include name="org/jboss/test/ws/wsse/HelloException.class"/>
         <include name="org/jboss/test/ws/wsse/UserType.class"/>
       </fileset>
       <metainf dir="${build.test.dir}/resources/wsse/rpc/META-INF">
@@ -1938,12 +1943,99 @@
       </metainf>
     </jar>
     
+    <!-- jbossws-wsse-sign-fault.war -->
+    <war warfile="${build.test.dir}/libs/jbossws-wsse-sign-fault.war" webxml="${build.test.dir}/resources/wsse/rpc/WEB-INF/web.xml">
+      <classes dir="${build.test.dir}/classes">
+        <include name="org/jboss/test/ws/wsse/Hello.class"/>
+        <include name="org/jboss/test/ws/wsse/HelloException.class"/>
+        <include name="org/jboss/test/ws/wsse/HelloJavaBean.class"/>
+        <include name="org/jboss/test/ws/wsse/UserType.class"/>
+      </classes>
+      <webinf dir="${build.test.dir}/resources/wsse/rpc/WEB-INF">
+        <include name="jaxrpc-mapping.xml"/>
+        <include name="jboss-web.xml"/>
+        <include name="webservices.xml"/>
+        <include name="wsdl/**"/>
+      </webinf>
+      <webinf dir="${build.test.dir}/resources/wsse/sign-fault">
+        <include name="jboss-wsse-server.xml"/>
+      </webinf>
+      <webinf dir="${build.test.dir}/resources/wsse">
+        <include name="wsse.keystore"/>
+        <include name="wsse.truststore"/>
+      </webinf>
+    </war>
+   
+    <!-- jboss-wsse-sign-fault-client.jar -->
+    <jar jarfile="${build.test.dir}/libs/jbossws-wsse-sign-fault-client.jar">
+      <fileset dir="${build.test.dir}/classes">
+        <include name="org/jboss/test/ws/wsse/Hello.class"/>
+        <include name="org/jboss/test/ws/wsse/HelloException.class"/>
+        <include name="org/jboss/test/ws/wsse/UserType.class"/>
+      </fileset>
+      <metainf dir="${build.test.dir}/resources/wsse/rpc/META-INF">
+        <include name="application-client.xml"/>
+        <include name="jboss-client.xml"/>
+      </metainf>
+      <metainf dir="${build.test.dir}/resources/wsse/sign-fault">
+        <include name="jboss-wsse-client.xml"/>
+      </metainf>
+      <metainf dir="${build.test.dir}/resources/wsse/rpc/WEB-INF">
+        <include name="wsdl/**"/>
+        <include name="jaxrpc-mapping.xml"/>
+      </metainf>
+    </jar>
+
+    <!-- jbossws-wsse-sign-encrypt-fault.war -->
+    <war warfile="${build.test.dir}/libs/jbossws-wsse-sign-encrypt-fault.war" webxml="${build.test.dir}/resources/wsse/rpc/WEB-INF/web.xml">
+      <classes dir="${build.test.dir}/classes">
+        <include name="org/jboss/test/ws/wsse/Hello.class"/>
+        <include name="org/jboss/test/ws/wsse/HelloException.class"/>
+        <include name="org/jboss/test/ws/wsse/HelloJavaBean.class"/>
+        <include name="org/jboss/test/ws/wsse/UserType.class"/>
+      </classes>
+      <webinf dir="${build.test.dir}/resources/wsse/rpc/WEB-INF">
+        <include name="jaxrpc-mapping.xml"/>
+        <include name="jboss-web.xml"/>
+        <include name="webservices.xml"/>
+        <include name="wsdl/**"/>
+      </webinf>
+      <webinf dir="${build.test.dir}/resources/wsse/sign-encrypt-fault">
+        <include name="jboss-wsse-server.xml"/>
+      </webinf>
+      <webinf dir="${build.test.dir}/resources/wsse">
+        <include name="wsse.keystore"/>
+        <include name="wsse.truststore"/>
+      </webinf>
+    </war>
+   
+    <!-- jboss-wsse-sign-encrypt-fault-client.jar -->
+    <jar jarfile="${build.test.dir}/libs/jbossws-wsse-sign-encrypt-fault-client.jar">
+      <fileset dir="${build.test.dir}/classes">
+        <include name="org/jboss/test/ws/wsse/Hello.class"/>
+        <include name="org/jboss/test/ws/wsse/HelloException.class"/>
+        <include name="org/jboss/test/ws/wsse/UserType.class"/>
+      </fileset>
+      <metainf dir="${build.test.dir}/resources/wsse/rpc/META-INF">
+        <include name="application-client.xml"/>
+        <include name="jboss-client.xml"/>
+      </metainf>
+      <metainf dir="${build.test.dir}/resources/wsse/sign-encrypt-fault">
+        <include name="jboss-wsse-client.xml"/>
+      </metainf>
+      <metainf dir="${build.test.dir}/resources/wsse/rpc/WEB-INF">
+        <include name="wsdl/**"/>
+        <include name="jaxrpc-mapping.xml"/>
+      </metainf>
+    </jar>
+
     <!-- jbossws-wsse-store-pass-encrypt-class-cmd.war -->
     <replace file="${build.test.dir}/resources/wsse/store-pass-encrypt-class-cmd/jboss-wsse-server.xml" token="${buildpath}" value="${build.test.dir}"/>
     <war warfile="${build.test.dir}/libs/jbossws-wsse-store-pass-encrypt-class-cmd.war" webxml="${build.test.dir}/resources/wsse/rpc/WEB-INF/web.xml">
       <classes dir="${build.test.dir}/classes">
         <include name="org/jboss/test/ws/wsse/Hello.class"/>
         <include name="org/jboss/test/ws/wsse/HelloJavaBean.class"/>
+        <include name="org/jboss/test/ws/wsse/HelloException.class"/>
         <include name="org/jboss/test/ws/wsse/PasswordUtil.class"/>
         <include name="org/jboss/test/ws/wsse/UserType.class"/>
       </classes>
@@ -1967,6 +2059,7 @@
       <fileset dir="${build.test.dir}/classes">
         <include name="org/jboss/test/ws/wsse/Hello.class"/>
         <include name="org/jboss/test/ws/wsse/UserType.class"/>
+        <include name="org/jboss/test/ws/wsse/HelloException.class"/>
       </fileset>
       <metainf dir="${build.test.dir}/resources/wsse/rpc/META-INF">
         <include name="application-client.xml"/>
@@ -1986,6 +2079,7 @@
       <classes dir="${build.test.dir}/classes">
         <include name="org/jboss/test/ws/wsse/Hello.class"/>
         <include name="org/jboss/test/ws/wsse/HelloJavaBean.class"/>
+        <include name="org/jboss/test/ws/wsse/HelloException.class"/>
         <include name="org/jboss/test/ws/wsse/RpcTestClientServlet.class"/>
         <include name="org/jboss/test/ws/wsse/UserType.class"/>
       </classes>

Modified: tags/jbossws-1.0.3.GA/src/test/java/org/jboss/test/ws/wsse/Hello.java
===================================================================
--- tags/jbossws-1.0.3.GA/src/test/java/org/jboss/test/ws/wsse/Hello.java	2006-08-24 06:28:13 UTC (rev 820)
+++ tags/jbossws-1.0.3.GA/src/test/java/org/jboss/test/ws/wsse/Hello.java	2006-08-24 08:16:06 UTC (rev 821)
@@ -27,4 +27,5 @@
 public interface Hello extends Remote
 {
    public UserType echoUserType(UserType in0) throws RemoteException;
+   public void triggerException(String reason, int code) throws HelloException, RemoteException;
 }

Copied: tags/jbossws-1.0.3.GA/src/test/java/org/jboss/test/ws/wsse/HelloException.java (from rev 820, branches/jbossws-1.0/src/test/java/org/jboss/test/ws/wsse/HelloException.java)

Modified: tags/jbossws-1.0.3.GA/src/test/java/org/jboss/test/ws/wsse/HelloJavaBean.java
===================================================================
--- tags/jbossws-1.0.3.GA/src/test/java/org/jboss/test/ws/wsse/HelloJavaBean.java	2006-08-24 06:28:13 UTC (rev 820)
+++ tags/jbossws-1.0.3.GA/src/test/java/org/jboss/test/ws/wsse/HelloJavaBean.java	2006-08-24 08:16:06 UTC (rev 821)
@@ -32,4 +32,9 @@
       log.info(in0);
       return in0;
    }
+
+   public void triggerException(String reason, int code) throws HelloException
+   {
+      throw new HelloException("Error: " + reason + ":" + code, code, reason);
+   }
 }

Modified: tags/jbossws-1.0.3.GA/src/test/java/org/jboss/test/ws/wsse/RoundTripTestCase.java
===================================================================
--- tags/jbossws-1.0.3.GA/src/test/java/org/jboss/test/ws/wsse/RoundTripTestCase.java	2006-08-24 06:28:13 UTC (rev 820)
+++ tags/jbossws-1.0.3.GA/src/test/java/org/jboss/test/ws/wsse/RoundTripTestCase.java	2006-08-24 08:16:06 UTC (rev 821)
@@ -40,13 +40,12 @@
 import java.util.List;
 
 /**
- * Test the SOAPEnvelope
+ * Simple WS-Security round trip test
  *
- * @author Thomas.Diesler at jboss.org
- * @since 14-Oct-2004
+ * @author <a href="mailto:jason.greene at jboss.com>Jason T. Greene</a>
  */
 public class RoundTripTestCase extends JBossWSTest
-{  
+{
    /** Test that we can build an envelope from InputStream */
    public void testRoundTrip() throws Exception
    {

Modified: tags/jbossws-1.0.3.GA/src/test/java/org/jboss/test/ws/wsse/RpcTestCase.java
===================================================================
--- tags/jbossws-1.0.3.GA/src/test/java/org/jboss/test/ws/wsse/RpcTestCase.java	2006-08-24 06:28:13 UTC (rev 820)
+++ tags/jbossws-1.0.3.GA/src/test/java/org/jboss/test/ws/wsse/RpcTestCase.java	2006-08-24 08:16:06 UTC (rev 821)
@@ -46,9 +46,6 @@
       return JBossWSTestSetup.newTestSetup(RpcTestCase.class, "jbossws-wsse-rpc.war, jbossws-wsse-rpc-client.jar");
    }
 
-   /**
-    * Test JSE endpoint
-    */
    public void testEndpoint() throws Exception
    {
       InitialContext iniCtx = getInitialContext();
@@ -59,4 +56,26 @@
       UserType retObj = hello.echoUserType(in0);
       assertEquals(in0, retObj);
    }
+
+   public void testFault() throws Exception
+   {
+      InitialContext iniCtx = getInitialContext();
+      Service service = (Service)iniCtx.lookup("java:comp/env/service/HelloService");
+      Hello hello = (Hello)service.getPort(Hello.class);
+
+      HelloException exception = null;
+
+      try
+      {
+         hello.triggerException("Fake Reason", 124);
+      }
+      catch (HelloException ex)
+      {
+         exception = ex;
+      }
+
+      assertNotNull("No exception thrown", exception);
+      assertEquals(exception.getReason(), "Fake Reason");
+      assertEquals(exception.getCode(), 124);
+   }
 }

Copied: tags/jbossws-1.0.3.GA/src/test/java/org/jboss/test/ws/wsse/SignEncryptFaultTestCase.java (from rev 820, branches/jbossws-1.0/src/test/java/org/jboss/test/ws/wsse/SignEncryptFaultTestCase.java)

Copied: tags/jbossws-1.0.3.GA/src/test/java/org/jboss/test/ws/wsse/SignFaultTestCase.java (from rev 820, branches/jbossws-1.0/src/test/java/org/jboss/test/ws/wsse/SignFaultTestCase.java)

Modified: tags/jbossws-1.0.3.GA/src/test/resources/wsse/rpc/WEB-INF/jaxrpc-mapping.xml
===================================================================
--- tags/jbossws-1.0.3.GA/src/test/resources/wsse/rpc/WEB-INF/jaxrpc-mapping.xml	2006-08-24 06:28:13 UTC (rev 820)
+++ tags/jbossws-1.0.3.GA/src/test/resources/wsse/rpc/WEB-INF/jaxrpc-mapping.xml	2006-08-24 08:16:06 UTC (rev 821)
@@ -1,4 +1,4 @@
-<?xml version='1.0' encoding='UTF-8'?><java-wsdl-mapping version='1.1' 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://www.ibm.com/webservices/xsd/j2ee_jaxrpc_mapping_1_1.xsd'>
+<?xml version='1.0' encoding='UTF-8'?><java-wsdl-mapping version='1.1' 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://www.ibm.com/webservices/xsd/j2ee_jaxrpc_mapping_1_1.xsd'>
  <package-mapping>
   <package-type>org.jboss.test.ws.wsse</package-type>
   <namespaceURI>http://org.jboss.test.ws/wsse/types</namespaceURI>
@@ -12,6 +12,32 @@
    <xml-element-name>msg</xml-element-name>
   </variable-mapping>
  </java-xml-type-mapping>
+ <java-xml-type-mapping>
+  <java-type>org.jboss.test.ws.wsse.HelloException</java-type>
+  <root-type-qname xmlns:typeNS='http://org.jboss.test.ws/wsse/types'>typeNS:HelloException</root-type-qname>
+  <qname-scope>complexType</qname-scope>
+  <variable-mapping>
+   <java-variable-name>message</java-variable-name>
+   <xml-element-name>message</xml-element-name>
+  </variable-mapping>
+  <variable-mapping>
+   <java-variable-name>code</java-variable-name>
+   <xml-element-name>code</xml-element-name>
+  </variable-mapping>
+  <variable-mapping>
+   <java-variable-name>reason</java-variable-name>
+   <xml-element-name>reason</xml-element-name>
+  </variable-mapping>
+ </java-xml-type-mapping>
+ <exception-mapping>
+  <exception-type>org.jboss.test.ws.wsse.HelloException</exception-type>
+  <wsdl-message xmlns:exMsgNS='http://org.jboss.test.ws/wsse'>exMsgNS:HelloException</wsdl-message>
+  <constructor-parameter-order>
+   <element-name>message</element-name>
+   <element-name>code</element-name>
+   <element-name>reason</element-name>
+  </constructor-parameter-order>
+ </exception-mapping>
  <service-interface-mapping>
   <service-interface>org.jboss.test.ws.wsse.HelloService</service-interface>
   <wsdl-service-name xmlns:serviceNS='http://org.jboss.test.ws/wsse'>serviceNS:HelloService</wsdl-service-name>
@@ -42,5 +68,27 @@
     <wsdl-message-part-name>result</wsdl-message-part-name>
    </wsdl-return-value-mapping>
   </service-endpoint-method-mapping>
+  <service-endpoint-method-mapping>
+   <java-method-name>triggerException</java-method-name>
+   <wsdl-operation>triggerException</wsdl-operation>
+   <method-param-parts-mapping>
+    <param-position>0</param-position>
+    <param-type>java.lang.String</param-type>
+    <wsdl-message-mapping>
+     <wsdl-message xmlns:wsdlMsgNS='http://org.jboss.test.ws/wsse'>wsdlMsgNS:Hello_triggerException</wsdl-message>
+     <wsdl-message-part-name>String_1</wsdl-message-part-name>
+     <parameter-mode>IN</parameter-mode>
+    </wsdl-message-mapping>
+   </method-param-parts-mapping>
+   <method-param-parts-mapping>
+    <param-position>1</param-position>
+    <param-type>int</param-type>
+    <wsdl-message-mapping>
+     <wsdl-message xmlns:wsdlMsgNS='http://org.jboss.test.ws/wsse'>wsdlMsgNS:Hello_triggerException</wsdl-message>
+     <wsdl-message-part-name>int_2</wsdl-message-part-name>
+     <parameter-mode>IN</parameter-mode>
+    </wsdl-message-mapping>
+   </method-param-parts-mapping>
+  </service-endpoint-method-mapping>
  </service-endpoint-interface-mapping>
 </java-wsdl-mapping>
\ No newline at end of file

Modified: tags/jbossws-1.0.3.GA/src/test/resources/wsse/rpc/WEB-INF/wsdl/HelloService.wsdl
===================================================================
--- tags/jbossws-1.0.3.GA/src/test/resources/wsse/rpc/WEB-INF/wsdl/HelloService.wsdl	2006-08-24 06:28:13 UTC (rev 820)
+++ tags/jbossws-1.0.3.GA/src/test/resources/wsse/rpc/WEB-INF/wsdl/HelloService.wsdl	2006-08-24 08:16:06 UTC (rev 821)
@@ -1,42 +1,74 @@
 <?xml version="1.0" encoding="UTF-8"?>
-
-<definitions name="HelloService" targetNamespace="http://org.jboss.test.ws/wsse" xmlns:tns="http://org.jboss.test.ws/wsse" xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:ns2="http://org.jboss.test.ws/wsse/types" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/">
-  <types>
-    <schema targetNamespace="http://org.jboss.test.ws/wsse/types" xmlns:tns="http://org.jboss.test.ws/wsse/types" xmlns:soap11-enc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns="http://www.w3.org/2001/XMLSchema">
-      <complexType name="UserType">
-        <sequence>
-          <element name="msg" type="string" nillable="true"/>
-        </sequence>
-      </complexType>
-    </schema>
-  </types>
-  <message name="Hello_echoUserType">
-    <part name="UserType_1" type="ns2:UserType"/>
-  </message>
-  <message name="Hello_echoUserTypeResponse">
-    <part name="result" type="ns2:UserType"/>
-  </message>
-  <portType name="Hello">
-    <operation name="echoUserType" parameterOrder="UserType_1">
-      <input message="tns:Hello_echoUserType"/>
-      <output message="tns:Hello_echoUserTypeResponse"/>
-    </operation>
-  </portType>
-  <binding name="HelloBinding" type="tns:Hello">
-    <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="rpc"/>
-    <operation name="echoUserType">
-      <soap:operation soapAction=""/>
-      <input>
-        <soap:body use="literal" namespace="http://org.jboss.test.ws/wsse"/>
-      </input>
-      <output>
-        <soap:body use="literal" namespace="http://org.jboss.test.ws/wsse"/>
-      </output>
-    </operation>
-  </binding>
-  <service name="HelloService">
-    <port name="HelloPort" binding="tns:HelloBinding">
-      <soap:address location="REPLACE_WITH_ACTUAL_URL"/>
-    </port>
-  </service>
-</definitions>
+<definitions name='HelloService' targetNamespace='http://org.jboss.test.ws/wsse' xmlns='http://schemas.xmlsoap.org/wsdl/' xmlns:ns1='http://org.jboss.test.ws/wsse/types' xmlns:soap='http://schemas.xmlsoap.org/wsdl/soap/' xmlns:tns='http://org.jboss.test.ws/wsse' xmlns:xsd='http://www.w3.org/2001/XMLSchema'>
+ <types>
+  <schema targetNamespace='http://org.jboss.test.ws/wsse/types' xmlns='http://www.w3.org/2001/XMLSchema' xmlns:soap11-enc='http://schemas.xmlsoap.org/soap/encoding/' xmlns:tns='http://org.jboss.test.ws/wsse/types' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'>
+   <complexType name='HelloException'>
+    <sequence>
+     <element name='message' nillable='true' type='string'/>
+     <element name='code' type='int'/>
+     <element name='reason' nillable='true' type='string'/>
+    </sequence>
+   </complexType>
+   <complexType name='UserType'>
+    <sequence>
+     <element name='msg' nillable='true' type='string'/>
+    </sequence>
+   </complexType>
+   <element name='HelloException' type='tns:HelloException'/>
+  </schema>
+ </types>
+ <message name='Hello_echoUserType'>
+  <part name='UserType_1' type='ns1:UserType'/>
+ </message>
+ <message name='Hello_echoUserTypeResponse'>
+  <part name='result' type='ns1:UserType'/>
+ </message>
+ <message name='Hello_triggerException'>
+  <part name='String_1' type='xsd:string'/>
+  <part name='int_2' type='xsd:int'/>
+ </message>
+ <message name='Hello_triggerExceptionResponse'/>
+ <message name='HelloException'>
+  <part element='ns1:HelloException' name='HelloException'/>
+ </message>
+ <portType name='Hello'>
+  <operation name='echoUserType' parameterOrder='UserType_1'>
+   <input message='tns:Hello_echoUserType'/>
+   <output message='tns:Hello_echoUserTypeResponse'/>
+  </operation>
+  <operation name='triggerException' parameterOrder='String_1 int_2'>
+   <input message='tns:Hello_triggerException'/>
+   <output message='tns:Hello_triggerExceptionResponse'/>
+   <fault message='tns:HelloException' name='HelloException'/>
+  </operation>
+ </portType>
+ <binding name='HelloBinding' type='tns:Hello'>
+  <soap:binding style='rpc' transport='http://schemas.xmlsoap.org/soap/http'/>
+  <operation name='echoUserType'>
+   <soap:operation soapAction=''/>
+   <input>
+    <soap:body namespace='http://org.jboss.test.ws/wsse' use='literal'/>
+   </input>
+   <output>
+    <soap:body namespace='http://org.jboss.test.ws/wsse' use='literal'/>
+   </output>
+  </operation>
+  <operation name='triggerException'>
+   <soap:operation soapAction=''/>
+   <input>
+    <soap:body namespace='http://org.jboss.test.ws/wsse' use='literal'/>
+   </input>
+   <output>
+    <soap:body namespace='http://org.jboss.test.ws/wsse' use='literal'/>
+   </output>
+   <fault name='HelloException'>
+    <soap:fault name='HelloException' use='literal'/>
+   </fault>
+  </operation>
+ </binding>
+ <service name='HelloService'>
+  <port binding='tns:HelloBinding' name='HelloPort'>
+   <soap:address location='REPLACE_WITH_ACTUAL_URL'/>
+  </port>
+ </service>
+</definitions>
\ No newline at end of file

Copied: tags/jbossws-1.0.3.GA/src/test/resources/wsse/sign-encrypt-fault (from rev 820, branches/jbossws-1.0/src/test/resources/wsse/sign-encrypt-fault)

Deleted: tags/jbossws-1.0.3.GA/src/test/resources/wsse/sign-encrypt-fault/jboss-wsse-client.xml
===================================================================
--- branches/jbossws-1.0/src/test/resources/wsse/sign-encrypt-fault/jboss-wsse-client.xml	2006-08-24 06:28:13 UTC (rev 820)
+++ tags/jbossws-1.0.3.GA/src/test/resources/wsse/sign-encrypt-fault/jboss-wsse-client.xml	2006-08-24 08:16:06 UTC (rev 821)
@@ -1,11 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<jboss-ws-security xmlns="http://www.jboss.com/ws-security/config" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.jboss.com/ws-security/config http://www.jboss.com/ws-security/schema/jboss-ws-security_1_0.xsd">
-  <config>
-    <sign type="x509v3" alias="wsse"/>
-    <encrypt type="x509v3" alias="wsse"/>
-    <requires>
-      <signature includeFaults="true"/>
-      <encryption includeFaults="true"/> 
-    </requires>
-  </config>
-</jboss-ws-security>

Copied: tags/jbossws-1.0.3.GA/src/test/resources/wsse/sign-encrypt-fault/jboss-wsse-client.xml (from rev 820, branches/jbossws-1.0/src/test/resources/wsse/sign-encrypt-fault/jboss-wsse-client.xml)

Deleted: tags/jbossws-1.0.3.GA/src/test/resources/wsse/sign-encrypt-fault/jboss-wsse-server.xml
===================================================================
--- branches/jbossws-1.0/src/test/resources/wsse/sign-encrypt-fault/jboss-wsse-server.xml	2006-08-24 06:28:13 UTC (rev 820)
+++ tags/jbossws-1.0.3.GA/src/test/resources/wsse/sign-encrypt-fault/jboss-wsse-server.xml	2006-08-24 08:16:06 UTC (rev 821)
@@ -1,15 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<jboss-ws-security xmlns="http://www.jboss.com/ws-security/config" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.jboss.com/ws-security/config http://www.jboss.com/ws-security/schema/jboss-ws-security_1_0.xsd">
-  <key-store-file>WEB-INF/wsse.keystore</key-store-file>
-  <key-store-password>jbossws</key-store-password>
-  <trust-store-file>WEB-INF/wsse.truststore</trust-store-file>
-  <trust-store-password>jbossws</trust-store-password>
-  <config>
-    <sign type="x509v3" alias="wsse" includeFaults="true"/>
-    <encrypt type="x509v3" alias="wsse" includeFaults="true"/>
-    <requires>
-      <signature/>
-      <encryption/>
-    </requires>
-  </config>
-</jboss-ws-security>

Copied: tags/jbossws-1.0.3.GA/src/test/resources/wsse/sign-encrypt-fault/jboss-wsse-server.xml (from rev 820, branches/jbossws-1.0/src/test/resources/wsse/sign-encrypt-fault/jboss-wsse-server.xml)

Copied: tags/jbossws-1.0.3.GA/src/test/resources/wsse/sign-fault (from rev 820, branches/jbossws-1.0/src/test/resources/wsse/sign-fault)

Deleted: tags/jbossws-1.0.3.GA/src/test/resources/wsse/sign-fault/jboss-wsse-client.xml
===================================================================
--- branches/jbossws-1.0/src/test/resources/wsse/sign-fault/jboss-wsse-client.xml	2006-08-24 06:28:13 UTC (rev 820)
+++ tags/jbossws-1.0.3.GA/src/test/resources/wsse/sign-fault/jboss-wsse-client.xml	2006-08-24 08:16:06 UTC (rev 821)
@@ -1,11 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<jboss-ws-security xmlns="http://www.jboss.com/ws-security/config" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.jboss.com/ws-security/config http://www.jboss.com/ws-security/schema/jboss-ws-security_1_0.xsd">
-  <config>
-    <sign type="x509v3" alias="wsse"/>
-    <encrypt type="x509v3" alias="wsse"/>
-    <requires>
-      <signature includeFaults="true"/>
-      <encryption/> 
-    </requires>
-  </config>
-</jboss-ws-security>

Copied: tags/jbossws-1.0.3.GA/src/test/resources/wsse/sign-fault/jboss-wsse-client.xml (from rev 820, branches/jbossws-1.0/src/test/resources/wsse/sign-fault/jboss-wsse-client.xml)

Deleted: tags/jbossws-1.0.3.GA/src/test/resources/wsse/sign-fault/jboss-wsse-server.xml
===================================================================
--- branches/jbossws-1.0/src/test/resources/wsse/sign-fault/jboss-wsse-server.xml	2006-08-24 06:28:13 UTC (rev 820)
+++ tags/jbossws-1.0.3.GA/src/test/resources/wsse/sign-fault/jboss-wsse-server.xml	2006-08-24 08:16:06 UTC (rev 821)
@@ -1,15 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<jboss-ws-security xmlns="http://www.jboss.com/ws-security/config" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.jboss.com/ws-security/config http://www.jboss.com/ws-security/schema/jboss-ws-security_1_0.xsd">
-  <key-store-file>WEB-INF/wsse.keystore</key-store-file>
-  <key-store-password>jbossws</key-store-password>
-  <trust-store-file>WEB-INF/wsse.truststore</trust-store-file>
-  <trust-store-password>jbossws</trust-store-password>
-  <config>
-    <sign type="x509v3" alias="wsse" includeFaults="true"/>
-    <encrypt type="x509v3" alias="wsse"/>
-    <requires>
-      <signature/>
-      <encryption/>
-    </requires>
-  </config>
-</jboss-ws-security>

Copied: tags/jbossws-1.0.3.GA/src/test/resources/wsse/sign-fault/jboss-wsse-server.xml (from rev 820, branches/jbossws-1.0/src/test/resources/wsse/sign-fault/jboss-wsse-server.xml)




More information about the jboss-svn-commits mailing list