Esempio n. 1
0
 @Override
 protected boolean redirectMatches(String requestedRedirect, String redirectUri) {
   AntPathMatcher matcher = new AntPathMatcher("/");
   if (redirectUri != null
       && redirectUri.contains("*")
       && matcher.match(redirectUri, requestedRedirect)) {
     return true;
   } else {
     return super.redirectMatches(requestedRedirect, redirectUri);
   }
 }
  private static boolean matches(String path, String include, List<String> excludes) {
    if (excludes != null && !excludes.isEmpty()) {
      for (String exclude : excludes) {
        boolean match = antPathMatcher.match(exclude, path);
        if (match) {
          return false;
        }
      }
    }

    if (StringUtils.isNotBlank(include)) {
      boolean match = antPathMatcher.match(include, path);
      if (match) {
        return true;
      }
    } else {
      return true;
    }
    return false;
  }
 /** test matching the path */
 public void testMatchPath() throws Exception {
   AntPathMatcher matcher = new AntPathMatcher();
   matcher.isPattern("/hello*");
   assertTrue(matcher.match("/hello/**", "/hello/my/friend"));
   assertTrue(matcher.match("/hello/**", "/hello"));
   assertFalse(matcher.match("/hello*", "/hello/my/friend"));
   assertFalse(matcher.match("/hello**", "/hello/my/friend"));
 }
  // 返回所请求资源所需要的权限
  public Collection<ConfigAttribute> getAttributes(Object object) throws IllegalArgumentException {
    // 此处借助Spring的Cache机制避免每次查询数据库
    Map<String, Collection<ConfigAttribute>> resourceMap = privilegeService.loadResourceDefine();

    String url = null;
    if (object instanceof String) {
      url = (String) object;
    } else {
      url = ((FilterInvocation) object).getRequestUrl();
    }
    Assert.notNull(url);
    Iterator<String> ite = resourceMap.keySet().iterator();
    while (ite.hasNext()) {
      String resURL = ite.next();
      if (urlMatcher.match(resURL, url)) {
        return resourceMap.get(resURL);
      }
    }
    return Lists.newArrayList();
  }
Esempio n. 5
0
 public boolean matches(String path) {
   return antMatcher.match(pattern, path);
 }