Author: ay
Date: Thu Oct 25 10:47:43 2012
New Revision: 1402092
URL: http://svn.apache.org/viewvc?rev=1402092&view=rev
Log:
Merged revisions 1402084 via svn merge from
https://svn.apache.org/repos/asf/cxf/trunk
........
r1402084 | ay | 2012-10-25 12:29:56 +0200 (Thu, 25 Oct 2012) | 1 line
[CXF-4601] invlaid WS-RM messages to a robust WS-RM endpoint may lead to NPE
........
Modified:
cxf/branches/2.6.x-fixes/ (props changed)
cxf/branches/2.6.x-fixes/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RMInInterceptor.java
cxf/branches/2.6.x-fixes/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/RMInInterceptorTest.java
Propchange: cxf/branches/2.6.x-fixes/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.
Modified:
cxf/branches/2.6.x-fixes/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RMInInterceptor.java
URL:
http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RMInInterceptor.java?rev=1402092&r1=1402091&r2=1402092&view=diff
==============================================================================
---
cxf/branches/2.6.x-fixes/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RMInInterceptor.java
(original)
+++
cxf/branches/2.6.x-fixes/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RMInInterceptor.java
Thu Oct 25 10:47:43 2012
@@ -47,6 +47,9 @@ public class RMInInterceptor extends Abs
@Override
public void handleFault(Message message) {
message.put(MAPAggregator.class.getName(), true);
+ if (null == RMContextUtils.getProtocolVariation(message)) {
+ return;
+ }
if
(MessageUtils.isTrue(message.get(RMMessageConstants.DELIVERING_ROBUST_ONEWAY)))
{
// revert the delivering entry from the destination sequence
try {
Modified:
cxf/branches/2.6.x-fixes/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/RMInInterceptorTest.java
URL:
http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/RMInInterceptorTest.java?rev=1402092&r1=1402091&r2=1402092&view=diff
==============================================================================
---
cxf/branches/2.6.x-fixes/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/RMInInterceptorTest.java
(original)
+++
cxf/branches/2.6.x-fixes/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/RMInInterceptorTest.java
Thu Oct 25 10:47:43 2012
@@ -282,7 +282,89 @@ public class RMInInterceptorTest extends
control.replay();
// TODO
}
+
+ @Test
+ public void testProcessInvalidMessage() throws SequenceFault, RMException {
+ interceptor = new RMInInterceptor();
+
+ Message message = control.createMock(Message.class);
+ Exchange exchange = control.createMock(Exchange.class);
+ org.apache.cxf.transport.Destination destination =
+ control.createMock(org.apache.cxf.transport.Destination.class);
+ EasyMock.expect(message.getExchange()).andReturn(exchange).anyTimes();
+
EasyMock.expect(exchange.getDestination()).andReturn(destination).anyTimes();
+ EasyMock.expect(exchange.getOutMessage()).andReturn(null).anyTimes();
+
EasyMock.expect(exchange.getOutFaultMessage()).andReturn(null).anyTimes();
+ control.replay();
+
+ try {
+ interceptor.handle(message);
+ fail("must reject the invalid rm message");
+ } catch (Exception e) {
+ assertTrue(e instanceof RMException);
+ // verify a partial error text match to exclude an unexpected
exception
+ // (see WSA_REQUIRED_EXC in Messages.properties)
+ final String text = "WS-Addressing is required";
+ assertTrue(e.getMessage() != null
+ && e.getMessage().indexOf(text) >= 0);
+ }
+
+ control.reset();
+ EasyMock.expect(message.getExchange()).andReturn(exchange).anyTimes();
+ AddressingPropertiesImpl maps =
control.createMock(AddressingPropertiesImpl.class);
+
EasyMock.expect(maps.getNamespaceURI()).andReturn(Names200408.WSA_NAMESPACE_NAME).anyTimes();
+
EasyMock.expect(message.get(JAXWSAConstants.SERVER_ADDRESSING_PROPERTIES_INBOUND)).andReturn(maps);
+ AttributedURIType actionURI =
control.createMock(AttributedURIType.class);
+ EasyMock.expect(maps.getAction()).andReturn(actionURI).times(2);
+ EasyMock.expect(actionURI.getValue()).andReturn("foo");
+
EasyMock.expect(message.get(RMMessageConstants.RM_PROPERTIES_INBOUND)).andReturn(rmps);
+
EasyMock.expect(exchange.getDestination()).andReturn(destination).anyTimes();
+ EasyMock.expect(exchange.getOutMessage()).andReturn(null).anyTimes();
+
EasyMock.expect(exchange.getOutFaultMessage()).andReturn(null).anyTimes();
+
+ control.replay();
+
+ try {
+ interceptor.handle(message);
+ fail("must reject the invalid rm message");
+ } catch (Exception e) {
+ System.out.println(e);
+ assertTrue(e instanceof RMException);
+ // verify a partial error text match to exclude an unexpected
exception
+ // (see WSRM_REQUIRED_EXC in Messages.properties)
+ final String text = "WS-ReliableMessaging is required";
+ assertTrue(e.getMessage() != null
+ && e.getMessage().indexOf(text) >= 0);
+ }
+ }
+ @Test
+ public void testProcessInvalidMessageOnFault() throws SequenceFault,
RMException {
+ interceptor = new RMInInterceptor();
+
+ Message message = control.createMock(Message.class);
+ Exchange exchange = control.createMock(Exchange.class);
+ EasyMock.expect(message.getExchange()).andReturn(exchange).anyTimes();
+ control.replay();
+
+ try {
+ interceptor.handleFault(message);
+ } catch (Exception e) {
+ fail("unexpected exception thrown from handleFault: " + e);
+ }
+
+ control.reset();
+ EasyMock.expect(message.getExchange()).andReturn(exchange).anyTimes();
+
EasyMock.expect(message.get(RMMessageConstants.DELIVERING_ROBUST_ONEWAY)).andReturn(true).anyTimes();
+ control.replay();
+
+ try {
+ interceptor.handleFault(message);
+ } catch (Exception e) {
+ fail("unexpected exception thrown from handleFault: " + e);
+ }
+ }
+
private Message setupInboundMessage(String action, boolean serverSide)
throws RMException {
Message message = control.createMock(Message.class);
Exchange exchange = control.createMock(Exchange.class);