SWS-708 - PayloadValidatingInterceptor errors not clearing SecurityContextHolder, backported to 1.5 branch
This commit is contained in:
@@ -1,11 +1,11 @@
|
||||
/*
|
||||
* Copyright 2005 the original author or authors.
|
||||
* Copyright 2005-2011 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
@@ -96,4 +96,6 @@ public interface EndpointInterceptor {
|
||||
* blocking of the response handler chain.
|
||||
*/
|
||||
boolean handleFault(MessageContext messageContext, Object endpoint) throws Exception;
|
||||
|
||||
void afterCompletion(MessageContext messageContext, Object endpoint, Exception ex);
|
||||
}
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
/*
|
||||
* Copyright 2002-2009 the original author or authors.
|
||||
* Copyright 2005-2011 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
@@ -24,9 +24,6 @@ import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.beans.factory.BeanFactoryUtils;
|
||||
import org.springframework.beans.factory.BeanNameAware;
|
||||
@@ -45,27 +42,35 @@ import org.springframework.ws.context.MessageContext;
|
||||
import org.springframework.ws.server.endpoint.MessageEndpoint;
|
||||
import org.springframework.ws.server.endpoint.PayloadEndpoint;
|
||||
import org.springframework.ws.server.endpoint.adapter.MessageEndpointAdapter;
|
||||
import org.springframework.ws.server.endpoint.adapter.MessageMethodEndpointAdapter;
|
||||
import org.springframework.ws.server.endpoint.adapter.PayloadEndpointAdapter;
|
||||
import org.springframework.ws.server.endpoint.adapter.PayloadMethodEndpointAdapter;
|
||||
import org.springframework.ws.soap.server.SoapMessageDispatcher;
|
||||
import org.springframework.ws.support.DefaultStrategiesHelper;
|
||||
import org.springframework.ws.transport.WebServiceMessageReceiver;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
/**
|
||||
* Central dispatcher for use within Spring-WS, dispatching Web service messages to registered endpoints.
|
||||
* <p/>
|
||||
* This dispatcher is quite similar to Spring MVCs {@link DispatcherServlet}. Just like its counterpart, this dispatcher
|
||||
* is very flexible. This class is SOAP agnostic; in typical SOAP Web Services, the {@link SoapMessageDispatcher}
|
||||
* subclass is used. <ul> <li>It can use any {@link EndpointMapping} implementation - whether standard, or provided as
|
||||
* subclass is used.
|
||||
* <ul>
|
||||
* <li>It can use any {@link EndpointMapping} implementation - whether standard, or provided as
|
||||
* part of an application - to control the routing of request messages to endpoint objects. Endpoint mappings can be
|
||||
* registered using the <code>endpointMappings</code> property.</li> <li>It can use any {@link EndpointAdapter}; this
|
||||
* allows one to use any endpoint interface or form. Defaults to the {@link MessageEndpointAdapter} and {@link
|
||||
* PayloadEndpointAdapter}, for {@link MessageEndpoint} and {@link PayloadEndpoint}, respectively, and the {@link
|
||||
* MessageMethodEndpointAdapter} and {@link PayloadMethodEndpointAdapter}. Additional endpoint adapters can be added
|
||||
* through the <code>endpointAdapters</code> property.</li> <li>Its exception resolution strategy can be specified via a
|
||||
* registered using the {@link #setEndpointMappings(List) endpointMappings} property.</li>
|
||||
* <li>It can use any {@link EndpointAdapter}; this allows one to use any endpoint interface or form. Defaults to
|
||||
* the {@link MessageEndpointAdapter} and {@link PayloadEndpointAdapter}, for {@link MessageEndpoint} and
|
||||
* {@link PayloadEndpoint}, respectively, and the
|
||||
* {@link org.springframework.ws.server.endpoint.adapter.MessageMethodEndpointAdapter MessageMethodEndpointAdapter} and
|
||||
* {@link org.springframework.ws.server.endpoint.adapter.PayloadMethodEndpointAdapter PayloadMethodEndpointAdapter}.
|
||||
* Additional endpoint adapters can be added through the {@link #setEndpointAdapters(List) endpointAdapters} property.</li>
|
||||
* <li>Its exception resolution strategy can be specified via a
|
||||
* {@link EndpointExceptionResolver}, for example mapping certain exceptions to SOAP Faults. Default is none. Additional
|
||||
* exception resolvers can be added through the <code>endpointExceptionResolvers</code> property.</li> </ul>
|
||||
* exception resolvers can be added through the {@link #setEndpointExceptionResolvers(List) endpointExceptionResolvers}
|
||||
* property.</li>
|
||||
* </ul>
|
||||
*
|
||||
* @author Arjen Poutsma
|
||||
* @see EndpointMapping
|
||||
@@ -221,6 +226,7 @@ public class MessageDispatcher implements WebServiceMessageReceiver, BeanNameAwa
|
||||
interceptorIndex = i;
|
||||
if (!interceptor.handleRequest(messageContext, mappedEndpoint.getEndpoint())) {
|
||||
triggerHandleResponse(mappedEndpoint, interceptorIndex, messageContext);
|
||||
triggerAfterCompletion(mappedEndpoint, interceptorIndex, messageContext, null);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -231,6 +237,7 @@ public class MessageDispatcher implements WebServiceMessageReceiver, BeanNameAwa
|
||||
|
||||
// Apply handleResponse methods of registered interceptors
|
||||
triggerHandleResponse(mappedEndpoint, interceptorIndex, messageContext);
|
||||
triggerAfterCompletion(mappedEndpoint, interceptorIndex, messageContext, null);
|
||||
}
|
||||
catch (NoEndpointFoundException ex) {
|
||||
// No triggering of interceptors if no endpoint is found
|
||||
@@ -243,6 +250,7 @@ public class MessageDispatcher implements WebServiceMessageReceiver, BeanNameAwa
|
||||
Object endpoint = mappedEndpoint != null ? mappedEndpoint.getEndpoint() : null;
|
||||
processEndpointException(messageContext, endpoint, ex);
|
||||
triggerHandleResponse(mappedEndpoint, interceptorIndex, messageContext);
|
||||
triggerAfterCompletion(mappedEndpoint, interceptorIndex, messageContext, ex);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -363,7 +371,41 @@ public class MessageDispatcher implements WebServiceMessageReceiver, BeanNameAwa
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize the <code>EndpointAdapters</code> used by this class. If no adapter beans are explictely set by using
|
||||
* Trigger afterCompletion callbacks on the mapped EndpointInterceptors.
|
||||
* Will just invoke afterCompletion for all interceptors whose handleRequest invocation
|
||||
* has successfully completed and returned true, in addition to the last interceptor who
|
||||
* returned <code>false</code>.
|
||||
*
|
||||
* @param mappedEndpoint the mapped EndpointInvocationChain
|
||||
* @param interceptorIndex index of last interceptor that successfully completed
|
||||
* @param ex Exception thrown on handler execution, or <code>null</code> if none
|
||||
* @see EndpointInterceptor#afterCompletion
|
||||
*/
|
||||
private void triggerAfterCompletion(EndpointInvocationChain mappedEndpoint,
|
||||
int interceptorIndex,
|
||||
MessageContext messageContext,
|
||||
Exception ex) throws Exception {
|
||||
|
||||
// Apply afterCompletion methods of registered interceptors.
|
||||
if (mappedEndpoint != null) {
|
||||
EndpointInterceptor[] interceptors = mappedEndpoint.getInterceptors();
|
||||
if (interceptors != null) {
|
||||
for (int i = interceptorIndex; i >= 0; i--) {
|
||||
EndpointInterceptor interceptor = interceptors[i];
|
||||
try {
|
||||
interceptor.afterCompletion(messageContext, mappedEndpoint.getEndpoint(), ex);
|
||||
}
|
||||
catch (Throwable ex2) {
|
||||
logger.error("EndpointInterceptor.afterCompletion threw exception", ex2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Initialize the <code>EndpointAdapters</code> used by this class. If no adapter beans are explicitly set by using
|
||||
* the <code>endpointAdapters</code> property, we use the default strategies.
|
||||
*
|
||||
* @see #setEndpointAdapters(java.util.List)
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
/*
|
||||
* Copyright 2006 the original author or authors.
|
||||
* Copyright 2005-2011 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
@@ -24,14 +24,14 @@ import javax.xml.transform.TransformerConfigurationException;
|
||||
import javax.xml.transform.TransformerException;
|
||||
import javax.xml.transform.stream.StreamResult;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import org.springframework.ws.WebServiceMessage;
|
||||
import org.springframework.ws.context.MessageContext;
|
||||
import org.springframework.ws.server.EndpointInterceptor;
|
||||
import org.springframework.xml.transform.TransformerObjectSupport;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
/**
|
||||
* Abstract base class for <code>EndpointInterceptor</code> instances that log a part of a
|
||||
* <code>WebServiceMessage</code>. By default, both request and response messages are logged, but this behaviour can be
|
||||
@@ -77,7 +77,7 @@ public abstract class AbstractLoggingInterceptor extends TransformerObjectSuppor
|
||||
}
|
||||
|
||||
/**
|
||||
* Logs the request message payload. Logging only ocurs if <code>logRequest</code> is set to <code>true</code>,
|
||||
* Logs the request message payload. Logging only occurs if <code>logRequest</code> is set to <code>true</code>,
|
||||
* which is the default.
|
||||
*
|
||||
* @param messageContext the message context
|
||||
@@ -92,7 +92,7 @@ public abstract class AbstractLoggingInterceptor extends TransformerObjectSuppor
|
||||
}
|
||||
|
||||
/**
|
||||
* Logs the response message payload. Logging only ocurs if <code>logResponse</code> is set to <code>true</code>,
|
||||
* Logs the response message payload. Logging only occurs if <code>logResponse</code> is set to <code>true</code>,
|
||||
* which is the default.
|
||||
*
|
||||
* @param messageContext the message context
|
||||
@@ -111,6 +111,10 @@ public abstract class AbstractLoggingInterceptor extends TransformerObjectSuppor
|
||||
return true;
|
||||
}
|
||||
|
||||
/** Does nothing by default*/
|
||||
public void afterCompletion(MessageContext messageContext, Object endpoint, Exception ex) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the {@link #logger} field is enabled.
|
||||
* <p/>
|
||||
@@ -152,7 +156,7 @@ public abstract class AbstractLoggingInterceptor extends TransformerObjectSuppor
|
||||
* Logs the given string message.
|
||||
* <p/>
|
||||
* By default, this method uses a "debug" level of logging. Subclasses can override this method to change the level
|
||||
* of loging used by the logger.
|
||||
* of logging used by the logger.
|
||||
*
|
||||
* @param message the message
|
||||
*/
|
||||
|
||||
@@ -20,9 +20,6 @@ import java.io.IOException;
|
||||
import javax.xml.transform.Source;
|
||||
import javax.xml.transform.TransformerException;
|
||||
|
||||
import org.xml.sax.SAXException;
|
||||
import org.xml.sax.SAXParseException;
|
||||
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.util.Assert;
|
||||
@@ -39,6 +36,9 @@ import org.springframework.xml.validation.XmlValidatorFactory;
|
||||
import org.springframework.xml.xsd.XsdSchema;
|
||||
import org.springframework.xml.xsd.XsdSchemaCollection;
|
||||
|
||||
import org.xml.sax.SAXException;
|
||||
import org.xml.sax.SAXParseException;
|
||||
|
||||
/**
|
||||
* Abstract base class for <code>EndpointInterceptor</code> implementations that validate part of the message using a
|
||||
* schema. The exact message part is determined by the <code>getValidationRequestSource</code> and
|
||||
@@ -245,6 +245,10 @@ public abstract class AbstractValidatingInterceptor extends TransformerObjectSup
|
||||
return true;
|
||||
}
|
||||
|
||||
/** Does nothing by default.*/
|
||||
public void afterCompletion(MessageContext messageContext, Object endpoint, Exception ex) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Abstract template method that returns the part of the request message that is to be validated.
|
||||
*
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
/*
|
||||
* Copyright 2005 the original author or authors.
|
||||
* Copyright 2005-2011 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
@@ -16,10 +16,11 @@
|
||||
|
||||
package org.springframework.ws.server.endpoint.interceptor;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.ws.context.MessageContext;
|
||||
import org.springframework.ws.server.EndpointInterceptor;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.w3c.dom.Element;
|
||||
|
||||
/**
|
||||
@@ -65,4 +66,10 @@ public class EndpointInterceptorAdapter implements EndpointInterceptor {
|
||||
public boolean handleFault(MessageContext messageContext, Object endpoint) {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Does nothing by default.
|
||||
*/
|
||||
public void afterCompletion(MessageContext messageContext, Object endpoint, Exception ex) {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
/*
|
||||
* Copyright 2006 the original author or authors.
|
||||
* Copyright 2005-2011 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
@@ -26,11 +26,6 @@ import javax.xml.transform.TransformerFactory;
|
||||
import javax.xml.transform.stream.StreamResult;
|
||||
import javax.xml.transform.stream.StreamSource;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.xml.sax.XMLReader;
|
||||
import org.xml.sax.helpers.XMLReaderFactory;
|
||||
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.util.Assert;
|
||||
@@ -40,6 +35,11 @@ import org.springframework.ws.server.EndpointInterceptor;
|
||||
import org.springframework.xml.transform.ResourceSource;
|
||||
import org.springframework.xml.transform.TransformerObjectSupport;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.xml.sax.XMLReader;
|
||||
import org.xml.sax.helpers.XMLReaderFactory;
|
||||
|
||||
/**
|
||||
* Interceptor that transforms the payload of <code>WebServiceMessage</code>s using XSLT stylesheet. Allows for seperate
|
||||
* stylesheets for request and response. This interceptor is especially useful when supporting with multiple version of
|
||||
@@ -125,6 +125,10 @@ public class PayloadTransformingInterceptor extends TransformerObjectSupport
|
||||
return true;
|
||||
}
|
||||
|
||||
/** Does nothing by default.*/
|
||||
public void afterCompletion(MessageContext messageContext, Object endpoint, Exception ex) {
|
||||
}
|
||||
|
||||
public void afterPropertiesSet() throws Exception {
|
||||
if (requestXslt == null && responseXslt == null) {
|
||||
throw new IllegalArgumentException("Setting either 'requestXslt' or 'responseXslt' is required");
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
/*
|
||||
* Copyright 2007 the original author or authors.
|
||||
* Copyright 2005-2011 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
@@ -19,9 +19,6 @@ package org.springframework.ws.soap.addressing.server;
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.ws.context.MessageContext;
|
||||
import org.springframework.ws.soap.SoapHeaderElement;
|
||||
@@ -34,6 +31,9 @@ import org.springframework.ws.soap.server.SoapEndpointInterceptor;
|
||||
import org.springframework.ws.transport.WebServiceConnection;
|
||||
import org.springframework.ws.transport.WebServiceMessageSender;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
/**
|
||||
* {@link SoapEndpointInterceptor} implementation that deals with WS-Addressing headers. Stateful, and instatiated by
|
||||
* the {@link AbstractAddressingEndpointMapping}.
|
||||
@@ -178,6 +178,9 @@ class AddressingEndpointInterceptor implements SoapEndpointInterceptor {
|
||||
return responseMessageId;
|
||||
}
|
||||
|
||||
public void afterCompletion(MessageContext messageContext, Object endpoint, Exception ex) {
|
||||
}
|
||||
|
||||
public boolean understands(SoapHeaderElement header) {
|
||||
return version.understands(header);
|
||||
}
|
||||
|
||||
@@ -18,8 +18,6 @@ package org.springframework.ws.server;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
import org.easymock.MockControl;
|
||||
import org.springframework.context.support.StaticApplicationContext;
|
||||
import org.springframework.ws.MockWebServiceMessage;
|
||||
import org.springframework.ws.NoEndpointFoundException;
|
||||
@@ -30,6 +28,9 @@ import org.springframework.ws.server.endpoint.adapter.PayloadEndpointAdapter;
|
||||
import org.springframework.ws.server.endpoint.mapping.PayloadRootQNameEndpointMapping;
|
||||
import org.springframework.ws.soap.server.endpoint.SimpleSoapExceptionResolver;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
import org.easymock.MockControl;
|
||||
|
||||
public class MessageDispatcherTest extends TestCase {
|
||||
|
||||
private MessageDispatcher dispatcher;
|
||||
@@ -171,6 +172,8 @@ public class MessageDispatcherTest extends TestCase {
|
||||
adapterMock.invoke(messageContext, endpoint);
|
||||
interceptorControl.expectAndReturn(interceptorMock2.handleResponse(messageContext, endpoint), true);
|
||||
interceptorControl.expectAndReturn(interceptorMock1.handleResponse(messageContext, endpoint), true);
|
||||
interceptorMock2.afterCompletion(messageContext, endpoint, null);
|
||||
interceptorMock1.afterCompletion(messageContext, endpoint, null);
|
||||
|
||||
EndpointInvocationChain chain =
|
||||
new EndpointInvocationChain(endpoint, new EndpointInterceptor[]{interceptorMock1, interceptorMock2});
|
||||
@@ -215,6 +218,8 @@ public class MessageDispatcherTest extends TestCase {
|
||||
interceptorControl.expectAndReturn(interceptorMock1.handleRequest(messageContext, endpoint), true);
|
||||
interceptorControl.expectAndReturn(interceptorMock2.handleRequest(messageContext, endpoint), true);
|
||||
adapterMock.invoke(messageContext, endpoint);
|
||||
interceptorMock2.afterCompletion(messageContext, endpoint, null);
|
||||
interceptorMock1.afterCompletion(messageContext, endpoint, null);
|
||||
|
||||
mappingControl.replay();
|
||||
interceptorControl.replay();
|
||||
@@ -246,6 +251,8 @@ public class MessageDispatcherTest extends TestCase {
|
||||
interceptorControl.expectAndReturn(interceptorMock1.handleRequest(messageContext, endpoint), false);
|
||||
interceptorControl.expectAndReturn(interceptorMock1.handleResponse(messageContext, endpoint), true);
|
||||
|
||||
interceptorMock1.afterCompletion(messageContext, endpoint, null);
|
||||
|
||||
EndpointInvocationChain chain =
|
||||
new EndpointInvocationChain(endpoint, new EndpointInterceptor[]{interceptorMock1, interceptorMock2});
|
||||
|
||||
@@ -286,6 +293,9 @@ public class MessageDispatcherTest extends TestCase {
|
||||
interceptorControl.expectAndReturn(interceptorMock2.handleRequest(messageContext, endpoint), false);
|
||||
interceptorControl.expectAndReturn(interceptorMock2.handleResponse(messageContext, endpoint), false);
|
||||
|
||||
interceptorMock2.afterCompletion(messageContext, endpoint, null);
|
||||
interceptorMock1.afterCompletion(messageContext, endpoint, null);
|
||||
|
||||
EndpointInvocationChain chain =
|
||||
new EndpointInvocationChain(endpoint, new EndpointInterceptor[]{interceptorMock1, interceptorMock2});
|
||||
|
||||
@@ -326,6 +336,8 @@ public class MessageDispatcherTest extends TestCase {
|
||||
adapterMock.invoke(messageContext, endpoint);
|
||||
interceptorControl.expectAndReturn(interceptorMock.handleFault(messageContext, endpoint), true);
|
||||
|
||||
interceptorMock.afterCompletion(messageContext, endpoint, null);
|
||||
|
||||
EndpointInvocationChain chain =
|
||||
new EndpointInvocationChain(endpoint, new EndpointInterceptor[]{interceptorMock});
|
||||
|
||||
|
||||
@@ -375,7 +375,7 @@
|
||||
<dependency>
|
||||
<groupId>org.apache.ws.commons.schema</groupId>
|
||||
<artifactId>XmlSchema</artifactId>
|
||||
<version>1.4.3</version>
|
||||
<version>1.4.5</version>
|
||||
</dependency>
|
||||
<!-- O/X Mapping dependencies -->
|
||||
<!-- Castor -->
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
/*
|
||||
* Copyright 2002-2009 the original author or authors.
|
||||
* Copyright 2005-2011 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
@@ -19,9 +19,6 @@ package org.springframework.ws.soap.security;
|
||||
import java.util.Locale;
|
||||
import javax.xml.namespace.QName;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.ws.client.WebServiceClientException;
|
||||
import org.springframework.ws.client.support.interceptor.ClientInterceptor;
|
||||
@@ -34,6 +31,9 @@ import org.springframework.ws.soap.SoapMessage;
|
||||
import org.springframework.ws.soap.server.SoapEndpointInterceptor;
|
||||
import org.springframework.ws.soap.soap11.Soap11Body;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
/**
|
||||
* Interceptor base class for interceptors that handle WS-Security. Can be used on the server side, registered in a
|
||||
* {@link org.springframework.ws.server.endpoint.mapping.AbstractEndpointMapping#setInterceptors(org.springframework.ws.server.EndpointInterceptor[])
|
||||
@@ -153,17 +153,19 @@ public abstract class AbstractWsSecurityInterceptor implements SoapEndpointInter
|
||||
if (!result) {
|
||||
messageContext.clearResponse();
|
||||
}
|
||||
cleanUp();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/** Returns <code>true</code>, i.e. fault responses are not secured. */
|
||||
public boolean handleFault(MessageContext messageContext, Object endpoint) throws Exception {
|
||||
cleanUp();
|
||||
return true;
|
||||
}
|
||||
|
||||
public void afterCompletion(MessageContext messageContext, Object endpoint, Exception ex) {
|
||||
cleanUp();
|
||||
}
|
||||
|
||||
public boolean understands(SoapHeaderElement headerElement) {
|
||||
return WS_SECURITY_NAME.equals(headerElement.getName());
|
||||
}
|
||||
|
||||
@@ -18,6 +18,13 @@ package org.springframework.ws.soap.security.wss4j;
|
||||
|
||||
import java.util.Properties;
|
||||
|
||||
import org.springframework.ws.context.DefaultMessageContext;
|
||||
import org.springframework.ws.context.MessageContext;
|
||||
import org.springframework.ws.server.EndpointInterceptor;
|
||||
import org.springframework.ws.soap.SoapMessage;
|
||||
import org.springframework.ws.soap.security.wss4j.callback.acegi.AcegiDigestPasswordValidationCallbackHandler;
|
||||
import org.springframework.ws.soap.security.wss4j.callback.acegi.AcegiPlainTextPasswordValidationCallbackHandler;
|
||||
|
||||
import org.acegisecurity.Authentication;
|
||||
import org.acegisecurity.AuthenticationManager;
|
||||
import org.acegisecurity.GrantedAuthority;
|
||||
@@ -28,13 +35,6 @@ import org.acegisecurity.userdetails.memory.InMemoryDaoImpl;
|
||||
import org.apache.ws.security.WSConstants;
|
||||
import org.easymock.MockControl;
|
||||
|
||||
import org.springframework.ws.context.DefaultMessageContext;
|
||||
import org.springframework.ws.context.MessageContext;
|
||||
import org.springframework.ws.server.EndpointInterceptor;
|
||||
import org.springframework.ws.soap.SoapMessage;
|
||||
import org.springframework.ws.soap.security.wss4j.callback.acegi.AcegiDigestPasswordValidationCallbackHandler;
|
||||
import org.springframework.ws.soap.security.wss4j.callback.acegi.AcegiPlainTextPasswordValidationCallbackHandler;
|
||||
|
||||
public abstract class Wss4jMessageInterceptorAcegiCallbackHandlerTestCase extends Wss4jTestCase {
|
||||
|
||||
private Properties users = new Properties();
|
||||
@@ -64,6 +64,7 @@ public abstract class Wss4jMessageInterceptorAcegiCallbackHandlerTestCase extend
|
||||
// test clean up
|
||||
messageContext.getResponse();
|
||||
interceptor.handleResponse(messageContext, null);
|
||||
interceptor.afterCompletion(messageContext, null, null);
|
||||
assertNull("Authentication created", SecurityContextHolder.getContext().getAuthentication());
|
||||
}
|
||||
|
||||
@@ -77,6 +78,7 @@ public abstract class Wss4jMessageInterceptorAcegiCallbackHandlerTestCase extend
|
||||
// test clean up
|
||||
messageContext.getResponse();
|
||||
interceptor.handleResponse(messageContext, null);
|
||||
interceptor.afterCompletion(messageContext, null, null);
|
||||
assertNull("Authentication created", SecurityContextHolder.getContext().getAuthentication());
|
||||
}
|
||||
|
||||
|
||||
@@ -18,9 +18,6 @@ package org.springframework.ws.soap.security.wss4j;
|
||||
|
||||
import java.util.Properties;
|
||||
|
||||
import org.apache.ws.security.WSConstants;
|
||||
import org.easymock.MockControl;
|
||||
|
||||
import org.springframework.security.Authentication;
|
||||
import org.springframework.security.AuthenticationManager;
|
||||
import org.springframework.security.GrantedAuthority;
|
||||
@@ -35,6 +32,9 @@ import org.springframework.ws.soap.SoapMessage;
|
||||
import org.springframework.ws.soap.security.wss4j.callback.SpringDigestPasswordValidationCallbackHandler;
|
||||
import org.springframework.ws.soap.security.wss4j.callback.SpringPlainTextPasswordValidationCallbackHandler;
|
||||
|
||||
import org.apache.ws.security.WSConstants;
|
||||
import org.easymock.MockControl;
|
||||
|
||||
public abstract class Wss4jMessageInterceptorSpringSecurityCallbackHandlerTestCase extends Wss4jTestCase {
|
||||
|
||||
private Properties users = new Properties();
|
||||
@@ -64,6 +64,7 @@ public abstract class Wss4jMessageInterceptorSpringSecurityCallbackHandlerTestCa
|
||||
// test clean up
|
||||
messageContext.getResponse();
|
||||
interceptor.handleResponse(messageContext, null);
|
||||
interceptor.afterCompletion(messageContext, null, null);
|
||||
assertNull("Authentication created", SecurityContextHolder.getContext().getAuthentication());
|
||||
}
|
||||
|
||||
@@ -77,6 +78,7 @@ public abstract class Wss4jMessageInterceptorSpringSecurityCallbackHandlerTestCa
|
||||
// test clean up
|
||||
messageContext.getResponse();
|
||||
interceptor.handleResponse(messageContext, null);
|
||||
interceptor.afterCompletion(messageContext, null, null);
|
||||
assertNull("Authentication created", SecurityContextHolder.getContext().getAuthentication());
|
||||
}
|
||||
|
||||
|
||||
287
xml/src/test/resources/org/springframework/xml/xsd/xml.xsd
Normal file
287
xml/src/test/resources/org/springframework/xml/xsd/xml.xsd
Normal file
@@ -0,0 +1,287 @@
|
||||
<?xml version='1.0'?>
|
||||
<?xml-stylesheet href="../2008/09/xsd.xsl" type="text/xsl"?>
|
||||
<xs:schema targetNamespace="http://www.w3.org/XML/1998/namespace"
|
||||
xmlns:xs="http://www.w3.org/2001/XMLSchema"
|
||||
xmlns ="http://www.w3.org/1999/xhtml"
|
||||
xml:lang="en">
|
||||
|
||||
<xs:annotation>
|
||||
<xs:documentation>
|
||||
<div>
|
||||
<h1>About the XML namespace</h1>
|
||||
|
||||
<div class="bodytext">
|
||||
<p>
|
||||
This schema document describes the XML namespace, in a form
|
||||
suitable for import by other schema documents.
|
||||
</p>
|
||||
<p>
|
||||
See <a href="http://www.w3.org/XML/1998/namespace.html">
|
||||
http://www.w3.org/XML/1998/namespace.html</a> and
|
||||
<a href="http://www.w3.org/TR/REC-xml">
|
||||
http://www.w3.org/TR/REC-xml</a> for information
|
||||
about this namespace.
|
||||
</p>
|
||||
<p>
|
||||
Note that local names in this namespace are intended to be
|
||||
defined only by the World Wide Web Consortium or its subgroups.
|
||||
The names currently defined in this namespace are listed below.
|
||||
They should not be used with conflicting semantics by any Working
|
||||
Group, specification, or document instance.
|
||||
</p>
|
||||
<p>
|
||||
See further below in this document for more information about <a
|
||||
href="#usage">how to refer to this schema document from your own
|
||||
XSD schema documents</a> and about <a href="#nsversioning">the
|
||||
namespace-versioning policy governing this schema document</a>.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</xs:documentation>
|
||||
</xs:annotation>
|
||||
|
||||
<xs:attribute name="lang">
|
||||
<xs:annotation>
|
||||
<xs:documentation>
|
||||
<div>
|
||||
|
||||
<h3>lang (as an attribute name)</h3>
|
||||
<p>
|
||||
denotes an attribute whose value
|
||||
is a language code for the natural language of the content of
|
||||
any element; its value is inherited. This name is reserved
|
||||
by virtue of its definition in the XML specification.</p>
|
||||
|
||||
</div>
|
||||
<div>
|
||||
<h4>Notes</h4>
|
||||
<p>
|
||||
Attempting to install the relevant ISO 2- and 3-letter
|
||||
codes as the enumerated possible values is probably never
|
||||
going to be a realistic possibility.
|
||||
</p>
|
||||
<p>
|
||||
See BCP 47 at <a href="http://www.rfc-editor.org/rfc/bcp/bcp47.txt">
|
||||
http://www.rfc-editor.org/rfc/bcp/bcp47.txt</a>
|
||||
and the IANA language subtag registry at
|
||||
<a href="http://www.iana.org/assignments/language-subtag-registry">
|
||||
http://www.iana.org/assignments/language-subtag-registry</a>
|
||||
for further information.
|
||||
</p>
|
||||
<p>
|
||||
The union allows for the 'un-declaration' of xml:lang with
|
||||
the empty string.
|
||||
</p>
|
||||
</div>
|
||||
</xs:documentation>
|
||||
</xs:annotation>
|
||||
<xs:simpleType>
|
||||
<xs:union memberTypes="xs:language">
|
||||
<xs:simpleType>
|
||||
<xs:restriction base="xs:string">
|
||||
<xs:enumeration value=""/>
|
||||
</xs:restriction>
|
||||
</xs:simpleType>
|
||||
</xs:union>
|
||||
</xs:simpleType>
|
||||
</xs:attribute>
|
||||
|
||||
<xs:attribute name="space">
|
||||
<xs:annotation>
|
||||
<xs:documentation>
|
||||
<div>
|
||||
|
||||
<h3>space (as an attribute name)</h3>
|
||||
<p>
|
||||
denotes an attribute whose
|
||||
value is a keyword indicating what whitespace processing
|
||||
discipline is intended for the content of the element; its
|
||||
value is inherited. This name is reserved by virtue of its
|
||||
definition in the XML specification.</p>
|
||||
|
||||
</div>
|
||||
</xs:documentation>
|
||||
</xs:annotation>
|
||||
<xs:simpleType>
|
||||
<xs:restriction base="xs:NCName">
|
||||
<xs:enumeration value="default"/>
|
||||
<xs:enumeration value="preserve"/>
|
||||
</xs:restriction>
|
||||
</xs:simpleType>
|
||||
</xs:attribute>
|
||||
|
||||
<xs:attribute name="base" type="xs:anyURI"> <xs:annotation>
|
||||
<xs:documentation>
|
||||
<div>
|
||||
|
||||
<h3>base (as an attribute name)</h3>
|
||||
<p>
|
||||
denotes an attribute whose value
|
||||
provides a URI to be used as the base for interpreting any
|
||||
relative URIs in the scope of the element on which it
|
||||
appears; its value is inherited. This name is reserved
|
||||
by virtue of its definition in the XML Base specification.</p>
|
||||
|
||||
<p>
|
||||
See <a
|
||||
href="http://www.w3.org/TR/xmlbase/">http://www.w3.org/TR/xmlbase/</a>
|
||||
for information about this attribute.
|
||||
</p>
|
||||
</div>
|
||||
</xs:documentation>
|
||||
</xs:annotation>
|
||||
</xs:attribute>
|
||||
|
||||
<xs:attribute name="id" type="xs:ID">
|
||||
<xs:annotation>
|
||||
<xs:documentation>
|
||||
<div>
|
||||
|
||||
<h3>id (as an attribute name)</h3>
|
||||
<p>
|
||||
denotes an attribute whose value
|
||||
should be interpreted as if declared to be of type ID.
|
||||
This name is reserved by virtue of its definition in the
|
||||
xml:id specification.</p>
|
||||
|
||||
<p>
|
||||
See <a
|
||||
href="http://www.w3.org/TR/xml-id/">http://www.w3.org/TR/xml-id/</a>
|
||||
for information about this attribute.
|
||||
</p>
|
||||
</div>
|
||||
</xs:documentation>
|
||||
</xs:annotation>
|
||||
</xs:attribute>
|
||||
|
||||
<xs:attributeGroup name="specialAttrs">
|
||||
<xs:attribute ref="xml:base"/>
|
||||
<xs:attribute ref="xml:lang"/>
|
||||
<xs:attribute ref="xml:space"/>
|
||||
<xs:attribute ref="xml:id"/>
|
||||
</xs:attributeGroup>
|
||||
|
||||
<xs:annotation>
|
||||
<xs:documentation>
|
||||
<div>
|
||||
|
||||
<h3>Father (in any context at all)</h3>
|
||||
|
||||
<div class="bodytext">
|
||||
<p>
|
||||
denotes Jon Bosak, the chair of
|
||||
the original XML Working Group. This name is reserved by
|
||||
the following decision of the W3C XML Plenary and
|
||||
XML Coordination groups:
|
||||
</p>
|
||||
<blockquote>
|
||||
<p>
|
||||
In appreciation for his vision, leadership and
|
||||
dedication the W3C XML Plenary on this 10th day of
|
||||
February, 2000, reserves for Jon Bosak in perpetuity
|
||||
the XML name "xml:Father".
|
||||
</p>
|
||||
</blockquote>
|
||||
</div>
|
||||
</div>
|
||||
</xs:documentation>
|
||||
</xs:annotation>
|
||||
|
||||
<xs:annotation>
|
||||
<xs:documentation>
|
||||
<div xml:id="usage" id="usage">
|
||||
<h2><a name="usage">About this schema document</a></h2>
|
||||
|
||||
<div class="bodytext">
|
||||
<p>
|
||||
This schema defines attributes and an attribute group suitable
|
||||
for use by schemas wishing to allow <code>xml:base</code>,
|
||||
<code>xml:lang</code>, <code>xml:space</code> or
|
||||
<code>xml:id</code> attributes on elements they define.
|
||||
</p>
|
||||
<p>
|
||||
To enable this, such a schema must import this schema for
|
||||
the XML namespace, e.g. as follows:
|
||||
</p>
|
||||
<pre>
|
||||
<schema . . .>
|
||||
. . .
|
||||
<import namespace="http://www.w3.org/XML/1998/namespace"
|
||||
schemaLocation="http://www.w3.org/2001/xml.xsd"/>
|
||||
</pre>
|
||||
<p>
|
||||
or
|
||||
</p>
|
||||
<pre>
|
||||
<import namespace="http://www.w3.org/XML/1998/namespace"
|
||||
schemaLocation="http://www.w3.org/2009/01/xml.xsd"/>
|
||||
</pre>
|
||||
<p>
|
||||
Subsequently, qualified reference to any of the attributes or the
|
||||
group defined below will have the desired effect, e.g.
|
||||
</p>
|
||||
<pre>
|
||||
<type . . .>
|
||||
. . .
|
||||
<attributeGroup ref="xml:specialAttrs"/>
|
||||
</pre>
|
||||
<p>
|
||||
will define a type which will schema-validate an instance element
|
||||
with any of those attributes.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</xs:documentation>
|
||||
</xs:annotation>
|
||||
|
||||
<xs:annotation>
|
||||
<xs:documentation>
|
||||
<div id="nsversioning" xml:id="nsversioning">
|
||||
<h2><a name="nsversioning">Versioning policy for this schema document</a></h2>
|
||||
<div class="bodytext">
|
||||
<p>
|
||||
In keeping with the XML Schema WG's standard versioning
|
||||
policy, this schema document will persist at
|
||||
<a href="http://www.w3.org/2009/01/xml.xsd">
|
||||
http://www.w3.org/2009/01/xml.xsd</a>.
|
||||
</p>
|
||||
<p>
|
||||
At the date of issue it can also be found at
|
||||
<a href="http://www.w3.org/2001/xml.xsd">
|
||||
http://www.w3.org/2001/xml.xsd</a>.
|
||||
</p>
|
||||
<p>
|
||||
The schema document at that URI may however change in the future,
|
||||
in order to remain compatible with the latest version of XML
|
||||
Schema itself, or with the XML namespace itself. In other words,
|
||||
if the XML Schema or XML namespaces change, the version of this
|
||||
document at <a href="http://www.w3.org/2001/xml.xsd">
|
||||
http://www.w3.org/2001/xml.xsd
|
||||
</a>
|
||||
will change accordingly; the version at
|
||||
<a href="http://www.w3.org/2009/01/xml.xsd">
|
||||
http://www.w3.org/2009/01/xml.xsd
|
||||
</a>
|
||||
will not change.
|
||||
</p>
|
||||
<p>
|
||||
Previous dated (and unchanging) versions of this schema
|
||||
document are at:
|
||||
</p>
|
||||
<ul>
|
||||
<li><a href="http://www.w3.org/2009/01/xml.xsd">
|
||||
http://www.w3.org/2009/01/xml.xsd</a></li>
|
||||
<li><a href="http://www.w3.org/2007/08/xml.xsd">
|
||||
http://www.w3.org/2007/08/xml.xsd</a></li>
|
||||
<li><a href="http://www.w3.org/2004/10/xml.xsd">
|
||||
http://www.w3.org/2004/10/xml.xsd</a></li>
|
||||
<li><a href="http://www.w3.org/2001/03/xml.xsd">
|
||||
http://www.w3.org/2001/03/xml.xsd</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</xs:documentation>
|
||||
</xs:annotation>
|
||||
|
||||
</xs:schema>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
xmlns="http://www.springframework.org/spring-ws/xmlNamespace" elementFormDefault="qualified"
|
||||
attributeFormDefault="unqualified">
|
||||
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" schemaLocation="http://www.w3.org/2001/xml.xsd"/>
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" schemaLocation="xml.xsd"/>
|
||||
|
||||
<xsd:element name="GetOrderRequest">
|
||||
<xsd:complexType>
|
||||
|
||||
Reference in New Issue
Block a user