|
1 | 1 | /*
|
2 |
| - * Copyright 2012-2016 the original author or authors. |
| 2 | + * Copyright 2012-2019 the original author or authors. |
3 | 3 | *
|
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
5 | 5 | * you may not use this file except in compliance with the License.
|
|
16 | 16 |
|
17 | 17 | package org.springframework.security.web.servlet.util.matcher;
|
18 | 18 |
|
19 |
| -import java.util.Collections; |
20 | 19 | import java.util.Map;
|
21 | 20 |
|
22 | 21 | import javax.servlet.http.HttpServletRequest;
|
|
43 | 42 | * </p>
|
44 | 43 | *
|
45 | 44 | * @author Rob Winch
|
| 45 | + * @author Eddú Meléndez |
46 | 46 | * @since 4.1.1
|
47 | 47 | */
|
48 | 48 | public class MvcRequestMatcher implements RequestMatcher, RequestVariablesExtractor {
|
@@ -93,13 +93,18 @@ private MatchableHandlerMapping getMapping(HttpServletRequest request) {
|
93 | 93 | */
|
94 | 94 | @Override
|
95 | 95 | public Map<String, String> extractUriTemplateVariables(HttpServletRequest request) {
|
| 96 | + return matcher(request).getVariables(); |
| 97 | + } |
| 98 | + |
| 99 | + @Override |
| 100 | + public MatchResult matcher(HttpServletRequest request) { |
96 | 101 | MatchableHandlerMapping mapping = getMapping(request);
|
97 | 102 | if (mapping == null) {
|
98 |
| - return this.defaultMatcher.extractUriTemplateVariables(request); |
| 103 | + return this.defaultMatcher.matcher(request); |
99 | 104 | }
|
100 | 105 | RequestMatchResult result = mapping.match(request, this.pattern);
|
101 |
| - return result == null ? Collections.<String, String>emptyMap() |
102 |
| - : result.extractUriTemplateVariables(); |
| 106 | + return result == null ? MatchResult.notMatch() |
| 107 | + : MatchResult.match(result.extractUriTemplateVariables()); |
103 | 108 | }
|
104 | 109 |
|
105 | 110 | /**
|
@@ -160,12 +165,18 @@ private boolean matches(String lookupPath) {
|
160 | 165 | @Override
|
161 | 166 | public Map<String, String> extractUriTemplateVariables(
|
162 | 167 | HttpServletRequest request) {
|
| 168 | + return matcher(request).getVariables(); |
| 169 | + } |
| 170 | + |
| 171 | + @Override |
| 172 | + public MatchResult matcher(HttpServletRequest request) { |
163 | 173 | String lookupPath = this.pathHelper.getLookupPathForRequest(request);
|
164 | 174 | if (matches(lookupPath)) {
|
165 |
| - return this.pathMatcher.extractUriTemplateVariables( |
| 175 | + Map<String, String> variables = this.pathMatcher.extractUriTemplateVariables( |
166 | 176 | MvcRequestMatcher.this.pattern, lookupPath);
|
| 177 | + return MatchResult.match(variables); |
167 | 178 | }
|
168 |
| - return Collections.emptyMap(); |
| 179 | + return MatchResult.notMatch(); |
169 | 180 | }
|
170 | 181 | }
|
171 | 182 | }
|
0 commit comments