|
@@ -15,6 +15,7 @@
|
|
*/
|
|
*/
|
|
package org.springframework.security.config.annotation.web;
|
|
package org.springframework.security.config.annotation.web;
|
|
|
|
|
|
|
|
+import org.springframework.beans.factory.NoSuchBeanDefinitionException;
|
|
import org.springframework.context.ApplicationContext;
|
|
import org.springframework.context.ApplicationContext;
|
|
import org.springframework.http.HttpMethod;
|
|
import org.springframework.http.HttpMethod;
|
|
import org.springframework.security.config.annotation.ObjectPostProcessor;
|
|
import org.springframework.security.config.annotation.ObjectPostProcessor;
|
|
@@ -42,6 +43,8 @@ import java.util.List;
|
|
* @since 3.2
|
|
* @since 3.2
|
|
*/
|
|
*/
|
|
public abstract class AbstractRequestMatcherRegistry<C> {
|
|
public abstract class AbstractRequestMatcherRegistry<C> {
|
|
|
|
+ private static final String HANDLER_MAPPING_INTROSPECTOR_BEAN_NAME = "mvcHandlerMappingIntrospector";
|
|
|
|
+
|
|
private static final RequestMatcher ANY_REQUEST = AnyRequestMatcher.INSTANCE;
|
|
private static final RequestMatcher ANY_REQUEST = AnyRequestMatcher.INSTANCE;
|
|
|
|
|
|
private ApplicationContext context;
|
|
private ApplicationContext context;
|
|
@@ -160,8 +163,12 @@ public abstract class AbstractRequestMatcherRegistry<C> {
|
|
String... mvcPatterns) {
|
|
String... mvcPatterns) {
|
|
boolean isServlet30 = ClassUtils.isPresent("javax.servlet.ServletRegistration", getClass().getClassLoader());
|
|
boolean isServlet30 = ClassUtils.isPresent("javax.servlet.ServletRegistration", getClass().getClassLoader());
|
|
ObjectPostProcessor<Object> opp = this.context.getBean(ObjectPostProcessor.class);
|
|
ObjectPostProcessor<Object> opp = this.context.getBean(ObjectPostProcessor.class);
|
|
- HandlerMappingIntrospector introspector = new HandlerMappingIntrospector(
|
|
|
|
- this.context);
|
|
|
|
|
|
+ if(!this.context.containsBean(HANDLER_MAPPING_INTROSPECTOR_BEAN_NAME)) {
|
|
|
|
+ throw new NoSuchBeanDefinitionException("A Bean named " + HANDLER_MAPPING_INTROSPECTOR_BEAN_NAME +" of type " + HandlerMappingIntrospector.class.getName()
|
|
|
|
+ + " is required to use MvcRequestMatcher. Please ensure Spring Security & Spring MVC are configured in a shared ApplicationContext.");
|
|
|
|
+ }
|
|
|
|
+ HandlerMappingIntrospector introspector = this.context.getBean(HANDLER_MAPPING_INTROSPECTOR_BEAN_NAME,
|
|
|
|
+ HandlerMappingIntrospector.class);
|
|
List<MvcRequestMatcher> matchers = new ArrayList<MvcRequestMatcher>(
|
|
List<MvcRequestMatcher> matchers = new ArrayList<MvcRequestMatcher>(
|
|
mvcPatterns.length);
|
|
mvcPatterns.length);
|
|
for (String mvcPattern : mvcPatterns) {
|
|
for (String mvcPattern : mvcPatterns) {
|