|
|
|
@ -18,6 +18,7 @@ package org.springframework.security.config.annotation.web; |
|
|
|
|
|
|
|
|
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.Arrays; |
|
|
|
import java.util.Arrays; |
|
|
|
|
|
|
|
import java.util.LinkedHashMap; |
|
|
|
import java.util.List; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Map; |
|
|
|
import java.util.Map; |
|
|
|
|
|
|
|
|
|
|
|
@ -312,8 +313,8 @@ public abstract class AbstractRequestMatcherRegistry<C> { |
|
|
|
if (servletContext == null) { |
|
|
|
if (servletContext == null) { |
|
|
|
return requestMatchers(RequestMatchers.antMatchersAsArray(method, patterns)); |
|
|
|
return requestMatchers(RequestMatchers.antMatchersAsArray(method, patterns)); |
|
|
|
} |
|
|
|
} |
|
|
|
Map<String, ? extends ServletRegistration> registrations = servletContext.getServletRegistrations(); |
|
|
|
Map<String, ? extends ServletRegistration> registrations = mappableServletRegistrations(servletContext); |
|
|
|
if (registrations == null) { |
|
|
|
if (registrations.isEmpty()) { |
|
|
|
return requestMatchers(RequestMatchers.antMatchersAsArray(method, patterns)); |
|
|
|
return requestMatchers(RequestMatchers.antMatchersAsArray(method, patterns)); |
|
|
|
} |
|
|
|
} |
|
|
|
if (!hasDispatcherServlet(registrations)) { |
|
|
|
if (!hasDispatcherServlet(registrations)) { |
|
|
|
@ -324,6 +325,16 @@ public abstract class AbstractRequestMatcherRegistry<C> { |
|
|
|
return requestMatchers(createMvcMatchers(method, patterns).toArray(new RequestMatcher[0])); |
|
|
|
return requestMatchers(createMvcMatchers(method, patterns).toArray(new RequestMatcher[0])); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private Map<String, ? extends ServletRegistration> mappableServletRegistrations(ServletContext servletContext) { |
|
|
|
|
|
|
|
Map<String, ServletRegistration> mappable = new LinkedHashMap<>(); |
|
|
|
|
|
|
|
for (Map.Entry<String, ? extends ServletRegistration> entry : servletContext.getServletRegistrations().entrySet()) { |
|
|
|
|
|
|
|
if (!entry.getValue().getMappings().isEmpty()) { |
|
|
|
|
|
|
|
mappable.put(entry.getKey(), entry.getValue()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return mappable; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private boolean hasDispatcherServlet(Map<String, ? extends ServletRegistration> registrations) { |
|
|
|
private boolean hasDispatcherServlet(Map<String, ? extends ServletRegistration> registrations) { |
|
|
|
if (registrations == null) { |
|
|
|
if (registrations == null) { |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
|