From 078c390b48016792a5198fc81275bbfd7418919a Mon Sep 17 00:00:00 2001 From: Arjen Poutsma Date: Wed, 18 May 2011 14:51:14 +0000 Subject: [PATCH] SWS-708 - PayloadValidatingInterceptor errors not clearing SecurityContextHolder, backported to 1.5 branch --- .../ws/server/EndpointInterceptor.java | 6 +- .../ws/server/MessageDispatcher.java | 72 ++++- .../endpoint/AbstractLoggingInterceptor.java | 20 +- .../AbstractValidatingInterceptor.java | 10 +- .../EndpointInterceptorAdapter.java | 15 +- .../PayloadTransformingInterceptor.java | 18 +- .../server/AddressingEndpointInterceptor.java | 13 +- .../ws/server/MessageDispatcherTest.java | 16 +- parent/pom.xml | 2 +- .../AbstractWsSecurityInterceptor.java | 16 +- ...terceptorAcegiCallbackHandlerTestCase.java | 16 +- ...SpringSecurityCallbackHandlerTestCase.java | 8 +- .../org/springframework/xml/xsd/xml.xsd | 287 ++++++++++++++++++ .../springframework/xml/xsd/xmlNamespace.xsd | 2 +- 14 files changed, 436 insertions(+), 65 deletions(-) create mode 100644 xml/src/test/resources/org/springframework/xml/xsd/xml.xsd diff --git a/core/src/main/java/org/springframework/ws/server/EndpointInterceptor.java b/core/src/main/java/org/springframework/ws/server/EndpointInterceptor.java index c6f197c1..bd38b08e 100644 --- a/core/src/main/java/org/springframework/ws/server/EndpointInterceptor.java +++ b/core/src/main/java/org/springframework/ws/server/EndpointInterceptor.java @@ -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); } diff --git a/core/src/main/java/org/springframework/ws/server/MessageDispatcher.java b/core/src/main/java/org/springframework/ws/server/MessageDispatcher.java index 731b7ba7..94a3a483 100644 --- a/core/src/main/java/org/springframework/ws/server/MessageDispatcher.java +++ b/core/src/main/java/org/springframework/ws/server/MessageDispatcher.java @@ -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. *

* 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.

* * @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 EndpointAdapters 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 false. + * + * @param mappedEndpoint the mapped EndpointInvocationChain + * @param interceptorIndex index of last interceptor that successfully completed + * @param ex Exception thrown on handler execution, or null 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 EndpointAdapters used by this class. If no adapter beans are explicitly set by using * the endpointAdapters property, we use the default strategies. * * @see #setEndpointAdapters(java.util.List) diff --git a/core/src/main/java/org/springframework/ws/server/endpoint/AbstractLoggingInterceptor.java b/core/src/main/java/org/springframework/ws/server/endpoint/AbstractLoggingInterceptor.java index 62444d7e..a6db110f 100644 --- a/core/src/main/java/org/springframework/ws/server/endpoint/AbstractLoggingInterceptor.java +++ b/core/src/main/java/org/springframework/ws/server/endpoint/AbstractLoggingInterceptor.java @@ -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 EndpointInterceptor instances that log a part of a * WebServiceMessage. 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 logRequest is set to true, + * Logs the request message payload. Logging only occurs if logRequest is set to true, * 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 logResponse is set to true, + * Logs the response message payload. Logging only occurs if logResponse is set to true, * 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. *

@@ -152,7 +156,7 @@ public abstract class AbstractLoggingInterceptor extends TransformerObjectSuppor * Logs the given string message. *

* 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 */ diff --git a/core/src/main/java/org/springframework/ws/server/endpoint/interceptor/AbstractValidatingInterceptor.java b/core/src/main/java/org/springframework/ws/server/endpoint/interceptor/AbstractValidatingInterceptor.java index 44290e52..f167c161 100644 --- a/core/src/main/java/org/springframework/ws/server/endpoint/interceptor/AbstractValidatingInterceptor.java +++ b/core/src/main/java/org/springframework/ws/server/endpoint/interceptor/AbstractValidatingInterceptor.java @@ -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 EndpointInterceptor implementations that validate part of the message using a * schema. The exact message part is determined by the getValidationRequestSource 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. * diff --git a/core/src/main/java/org/springframework/ws/server/endpoint/interceptor/EndpointInterceptorAdapter.java b/core/src/main/java/org/springframework/ws/server/endpoint/interceptor/EndpointInterceptorAdapter.java index 29545c9a..fc85e6a8 100644 --- a/core/src/main/java/org/springframework/ws/server/endpoint/interceptor/EndpointInterceptorAdapter.java +++ b/core/src/main/java/org/springframework/ws/server/endpoint/interceptor/EndpointInterceptorAdapter.java @@ -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) { + } } diff --git a/core/src/main/java/org/springframework/ws/server/endpoint/interceptor/PayloadTransformingInterceptor.java b/core/src/main/java/org/springframework/ws/server/endpoint/interceptor/PayloadTransformingInterceptor.java index 932c48d0..135c2551 100644 --- a/core/src/main/java/org/springframework/ws/server/endpoint/interceptor/PayloadTransformingInterceptor.java +++ b/core/src/main/java/org/springframework/ws/server/endpoint/interceptor/PayloadTransformingInterceptor.java @@ -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 WebServiceMessages 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"); diff --git a/core/src/main/java/org/springframework/ws/soap/addressing/server/AddressingEndpointInterceptor.java b/core/src/main/java/org/springframework/ws/soap/addressing/server/AddressingEndpointInterceptor.java index 6e0d8473..6e83662c 100644 --- a/core/src/main/java/org/springframework/ws/soap/addressing/server/AddressingEndpointInterceptor.java +++ b/core/src/main/java/org/springframework/ws/soap/addressing/server/AddressingEndpointInterceptor.java @@ -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); } diff --git a/core/src/test/java/org/springframework/ws/server/MessageDispatcherTest.java b/core/src/test/java/org/springframework/ws/server/MessageDispatcherTest.java index 107bbf20..c290f9e5 100644 --- a/core/src/test/java/org/springframework/ws/server/MessageDispatcherTest.java +++ b/core/src/test/java/org/springframework/ws/server/MessageDispatcherTest.java @@ -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}); diff --git a/parent/pom.xml b/parent/pom.xml index 70f43030..aa8610f2 100644 --- a/parent/pom.xml +++ b/parent/pom.xml @@ -375,7 +375,7 @@ org.apache.ws.commons.schema XmlSchema - 1.4.3 + 1.4.5 diff --git a/security/src/main/java/org/springframework/ws/soap/security/AbstractWsSecurityInterceptor.java b/security/src/main/java/org/springframework/ws/soap/security/AbstractWsSecurityInterceptor.java index 03d326f1..7c38c825 100644 --- a/security/src/main/java/org/springframework/ws/soap/security/AbstractWsSecurityInterceptor.java +++ b/security/src/main/java/org/springframework/ws/soap/security/AbstractWsSecurityInterceptor.java @@ -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 true, 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()); } diff --git a/security/src/test/java/org/springframework/ws/soap/security/wss4j/Wss4jMessageInterceptorAcegiCallbackHandlerTestCase.java b/security/src/test/java/org/springframework/ws/soap/security/wss4j/Wss4jMessageInterceptorAcegiCallbackHandlerTestCase.java index 2cac770f..c80d3472 100755 --- a/security/src/test/java/org/springframework/ws/soap/security/wss4j/Wss4jMessageInterceptorAcegiCallbackHandlerTestCase.java +++ b/security/src/test/java/org/springframework/ws/soap/security/wss4j/Wss4jMessageInterceptorAcegiCallbackHandlerTestCase.java @@ -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()); } diff --git a/security/src/test/java/org/springframework/ws/soap/security/wss4j/Wss4jMessageInterceptorSpringSecurityCallbackHandlerTestCase.java b/security/src/test/java/org/springframework/ws/soap/security/wss4j/Wss4jMessageInterceptorSpringSecurityCallbackHandlerTestCase.java index ff54f887..f316ebf8 100755 --- a/security/src/test/java/org/springframework/ws/soap/security/wss4j/Wss4jMessageInterceptorSpringSecurityCallbackHandlerTestCase.java +++ b/security/src/test/java/org/springframework/ws/soap/security/wss4j/Wss4jMessageInterceptorSpringSecurityCallbackHandlerTestCase.java @@ -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()); } diff --git a/xml/src/test/resources/org/springframework/xml/xsd/xml.xsd b/xml/src/test/resources/org/springframework/xml/xsd/xml.xsd new file mode 100644 index 00000000..aea7d0db --- /dev/null +++ b/xml/src/test/resources/org/springframework/xml/xsd/xml.xsd @@ -0,0 +1,287 @@ + + + + + + +

+

About the XML namespace

+ +
+

+ This schema document describes the XML namespace, in a form + suitable for import by other schema documents. +

+

+ See + http://www.w3.org/XML/1998/namespace.html and + + http://www.w3.org/TR/REC-xml for information + about this namespace. +

+

+ 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. +

+

+ See further below in this document for more information about how to refer to this schema document from your own + XSD schema documents and about the + namespace-versioning policy governing this schema document. +

+
+
+ + + + + + +
+ +

lang (as an attribute name)

+

+ 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.

+ +
+
+

Notes

+

+ 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. +

+

+ See BCP 47 at + http://www.rfc-editor.org/rfc/bcp/bcp47.txt + and the IANA language subtag registry at + + http://www.iana.org/assignments/language-subtag-registry + for further information. +

+

+ The union allows for the 'un-declaration' of xml:lang with + the empty string. +

+
+
+
+ + + + + + + + + +
+ + + + +
+ +

space (as an attribute name)

+

+ 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.

+ +
+
+
+ + + + + + +
+ + + +
+ +

base (as an attribute name)

+

+ 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.

+ +

+ See http://www.w3.org/TR/xmlbase/ + for information about this attribute. +

+
+
+
+
+ + + + +
+ +

id (as an attribute name)

+

+ 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.

+ +

+ See http://www.w3.org/TR/xml-id/ + for information about this attribute. +

+
+
+
+
+ + + + + + + + + + +
+ +

Father (in any context at all)

+ +
+

+ 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: +

+
+

+ 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". +

+
+
+
+
+
+ + + +
+

About this schema document

+ +
+

+ This schema defines attributes and an attribute group suitable + for use by schemas wishing to allow xml:base, + xml:lang, xml:space or + xml:id attributes on elements they define. +

+

+ To enable this, such a schema must import this schema for + the XML namespace, e.g. as follows: +

+
+          <schema . . .>
+           . . .
+           <import namespace="http://www.w3.org/XML/1998/namespace"
+                      schemaLocation="http://www.w3.org/2001/xml.xsd"/>
+     
+

+ or +

+
+           <import namespace="http://www.w3.org/XML/1998/namespace"
+                      schemaLocation="http://www.w3.org/2009/01/xml.xsd"/>
+     
+

+ Subsequently, qualified reference to any of the attributes or the + group defined below will have the desired effect, e.g. +

+
+          <type . . .>
+           . . .
+           <attributeGroup ref="xml:specialAttrs"/>
+     
+

+ will define a type which will schema-validate an instance element + with any of those attributes. +

+
+
+
+
+ + + +
+

Versioning policy for this schema document

+
+

+ In keeping with the XML Schema WG's standard versioning + policy, this schema document will persist at + + http://www.w3.org/2009/01/xml.xsd. +

+

+ At the date of issue it can also be found at + + http://www.w3.org/2001/xml.xsd. +

+

+ 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 + http://www.w3.org/2001/xml.xsd + + will change accordingly; the version at + + http://www.w3.org/2009/01/xml.xsd + + will not change. +

+

+ Previous dated (and unchanging) versions of this schema + document are at: +

+ +
+
+
+
+ + + diff --git a/xml/src/test/resources/org/springframework/xml/xsd/xmlNamespace.xsd b/xml/src/test/resources/org/springframework/xml/xsd/xmlNamespace.xsd index eebd4bc5..a94f7491 100644 --- a/xml/src/test/resources/org/springframework/xml/xsd/xmlNamespace.xsd +++ b/xml/src/test/resources/org/springframework/xml/xsd/xmlNamespace.xsd @@ -4,7 +4,7 @@ xmlns="http://www.springframework.org/spring-ws/xmlNamespace" elementFormDefault="qualified" attributeFormDefault="unqualified"> - +