1 package org.springframework.security.util;
2
3 import org.springframework.util.PathMatcher;
4 import org.springframework.util.AntPathMatcher;
5
6
7
8
9
10
11
12 public class AntUrlPathMatcher implements UrlMatcher {
13 private boolean requiresLowerCaseUrl = true;
14 private PathMatcher pathMatcher = new AntPathMatcher();
15
16 public AntUrlPathMatcher() {
17 this(true);
18 }
19
20 public AntUrlPathMatcher(boolean requiresLowerCaseUrl) {
21 this.requiresLowerCaseUrl = requiresLowerCaseUrl;
22 }
23
24 public Object compile(String path) {
25 if (requiresLowerCaseUrl) {
26 return path.toLowerCase();
27 }
28
29 return path;
30 }
31
32 public void setRequiresLowerCaseUrl(boolean requiresLowerCaseUrl) {
33 this.requiresLowerCaseUrl = requiresLowerCaseUrl;
34 }
35
36 public boolean pathMatchesUrl(Object path, String url) {
37 return pathMatcher.match((String)path, url);
38 }
39
40 public String getUniversalMatchPattern() {
41 return "/**";
42 }
43
44 public boolean requiresLowerCaseUrl() {
45 return requiresLowerCaseUrl;
46 }
47
48 public String toString() {
49 return getClass().getName() + "[requiresLowerCase='" + requiresLowerCaseUrl + "']";
50 }
51 }