Author: alessio.soldano(a)jboss.com
Date: 2010-03-15 09:18:17 -0400 (Mon, 15 Mar 2010)
New Revision: 11780
Modified:
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/soap/SOAPMessageImpl.java
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/extensions/security/WSSecurityDispatcher.java
Log:
[JBWS-2962] Move to DOM_VALID state of soap content model when performing encryption/sign
Modified:
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/soap/SOAPMessageImpl.java
===================================================================
---
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/soap/SOAPMessageImpl.java 2010-03-15
12:47:09 UTC (rev 11779)
+++
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/soap/SOAPMessageImpl.java 2010-03-15
13:18:17 UTC (rev 11780)
@@ -51,6 +51,7 @@
import org.jboss.ws.WSException;
import org.jboss.ws.core.CommonMessageContext;
import org.jboss.ws.core.SOAPMessageAbstraction;
+import org.jboss.ws.core.soap.SOAPContent.State;
import org.jboss.ws.core.soap.attachment.AttachmentPartImpl;
import org.jboss.ws.core.soap.attachment.CIDGenerator;
import org.jboss.ws.core.soap.attachment.MimeConstants;
@@ -60,6 +61,8 @@
import org.jboss.ws.extensions.xop.XOPContext;
import org.jboss.ws.metadata.umdm.EndpointMetaData;
import org.jboss.ws.metadata.umdm.OperationMetaData;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
/**
* The root class for all SOAP messages. As transmitted on the "wire", a SOAP
message is an XML document or a
@@ -567,7 +570,7 @@
if (attachment == null)
{
- // autogenerated CID based on part name
+ // auto-generated CID based on part name
attachment = getAttachmentByPartName(ref);
}
@@ -601,4 +604,41 @@
while (attachmentItr.next() != null)
attachmentItr.remove();
}
+
+ public void prepareForDOMAccess() throws SOAPException
+ {
+ prepareForSpecificAccess(State.DOM_VALID);
+ }
+
+ private void prepareForSpecificAccess(State state) throws SOAPException
+ {
+ List<SOAPContentElement> contentElements = new
LinkedList<SOAPContentElement>();
+ SOAPBody soapBody = this.getSOAPBody();
+ NodeList nodes = soapBody.getChildNodes();
+ for (int i = 0; i < nodes.getLength(); i++)
+ {
+ Node current = nodes.item(i);
+ if (current instanceof SOAPContentElement)
+ {
+ contentElements.add((SOAPContentElement)current);
+ break;
+ }
+ }
+ SOAPHeader soapHeader = this.getSOAPHeader();
+ nodes = soapHeader.getChildNodes();
+ for (int i = 0; i < nodes.getLength(); i++)
+ {
+ Node current = nodes.item(i);
+ if (current instanceof SOAPContentElement)
+ {
+ contentElements.add((SOAPContentElement)current);
+ break;
+ }
+ }
+ for (SOAPContentElement sce : contentElements)
+ {
+ sce.transitionTo(state);
+ }
+ }
+
}
Modified:
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/extensions/security/WSSecurityDispatcher.java
===================================================================
---
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/extensions/security/WSSecurityDispatcher.java 2010-03-15
12:47:09 UTC (rev 11779)
+++
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/extensions/security/WSSecurityDispatcher.java 2010-03-15
13:18:17 UTC (rev 11780)
@@ -215,6 +215,11 @@
SecurityStore securityStore = new SecurityStore(configuration.getKeyStoreURL(),
configuration.getKeyStoreType(), configuration.getKeyStorePassword(),
configuration.getKeyPasswords(), configuration.getTrustStoreURL(),
configuration.getTrustStoreType(), configuration.getTrustStorePassword());
SecurityEncoder encoder = new SecurityEncoder(operations, securityStore);
+
+ if ((sign != null || encrypt != null) && message instanceof
SOAPMessageImpl)
+ {
+ ((SOAPMessageImpl)message).prepareForDOMAccess();
+ }
encoder.encode(message.getSOAPPart());
}
catch (WSSecurityException e)
Show replies by date