org.springframework.util.AntPathMatcher Java Examples

The following examples show how to use org.springframework.util.AntPathMatcher. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RestfulMockDAOImpl.java    From smockin with Apache License 2.0 6 votes vote down vote up
@Override
public RestfulMock findActiveByMethodAndPathPatternAndTypesForSingleUser(final RestMethodEnum method, final String path, final List<RestMockTypeEnum> mockTypes) {

    final String part1 = StringUtils.split(path, AntPathMatcher.DEFAULT_PATH_SEPARATOR)[0];

    final List<RestfulMock> mocks = entityManager.createQuery("FROM RestfulMock rm "
            + " WHERE rm.method = :method "
            + " AND rm.mockType IN (:mockTypes) "
            + " AND (rm.path = :path1 OR rm.path LIKE '/'||:path2||'%')"
            + " AND rm.createdBy.role = :role "
            + " AND rm.status = 'ACTIVE'", RestfulMock.class)
            .setParameter("method", method)
            .setParameter("mockTypes", mockTypes)
            .setParameter("path1", path)
            .setParameter("path2", part1)
            .setParameter("role", SmockinUserRoleEnum.SYS_ADMIN)
            .getResultList();

    return matchPath(mocks, path, false);
}
 
Example #2
Source File: InterceptorRegistryTests.java    From spring-analysis-note with MIT License 6 votes vote down vote up
private List<HandlerInterceptor> getInterceptorsForPath(String lookupPath) {
	PathMatcher pathMatcher = new AntPathMatcher();
	List<HandlerInterceptor> result = new ArrayList<>();
	for (Object interceptor : this.registry.getInterceptors()) {
		if (interceptor instanceof MappedInterceptor) {
			MappedInterceptor mappedInterceptor = (MappedInterceptor) interceptor;
			if (mappedInterceptor.matches(lookupPath, pathMatcher)) {
				result.add(mappedInterceptor.getInterceptor());
			}
		}
		else if (interceptor instanceof HandlerInterceptor) {
			result.add((HandlerInterceptor) interceptor);
		}
		else {
			fail("Unexpected interceptor type: " + interceptor.getClass().getName());
		}
	}
	return result;
}
 
Example #3
Source File: PatternsRequestCondition.java    From spring-analysis-note with MIT License 6 votes vote down vote up
/**
 * Private constructor accepting a collection of patterns.
 */
private PatternsRequestCondition(Collection<String> patterns, @Nullable UrlPathHelper urlPathHelper,
		@Nullable PathMatcher pathMatcher, boolean useSuffixPatternMatch,
		boolean useTrailingSlashMatch, @Nullable List<String> fileExtensions) {

	this.patterns = Collections.unmodifiableSet(prependLeadingSlash(patterns));
	this.pathHelper = urlPathHelper != null ? urlPathHelper : new UrlPathHelper();
	this.pathMatcher = pathMatcher != null ? pathMatcher : new AntPathMatcher();
	this.useSuffixPatternMatch = useSuffixPatternMatch;
	this.useTrailingSlashMatch = useTrailingSlashMatch;

	if (fileExtensions != null) {
		for (String fileExtension : fileExtensions) {
			if (fileExtension.charAt(0) != '.') {
				fileExtension = "." + fileExtension;
			}
			this.fileExtensions.add(fileExtension);
		}
	}
}
 
Example #4
Source File: MvcNamespaceUtils.java    From spring-analysis-note with MIT License 6 votes vote down vote up
/**
 * Adds an alias to an existing well-known name or registers a new instance of a {@link PathMatcher}
 * under that well-known name, unless already registered.
 * @return a RuntimeBeanReference to this {@link PathMatcher} instance
 */
public static RuntimeBeanReference registerPathMatcher(@Nullable RuntimeBeanReference pathMatcherRef,
		ParserContext parserContext, @Nullable Object source) {

	if (pathMatcherRef != null) {
		if (parserContext.getRegistry().isAlias(PATH_MATCHER_BEAN_NAME)) {
			parserContext.getRegistry().removeAlias(PATH_MATCHER_BEAN_NAME);
		}
		parserContext.getRegistry().registerAlias(pathMatcherRef.getBeanName(), PATH_MATCHER_BEAN_NAME);
	}
	else if (!parserContext.getRegistry().isAlias(PATH_MATCHER_BEAN_NAME) &&
			!parserContext.getRegistry().containsBeanDefinition(PATH_MATCHER_BEAN_NAME)) {
		RootBeanDefinition pathMatcherDef = new RootBeanDefinition(AntPathMatcher.class);
		pathMatcherDef.setSource(source);
		pathMatcherDef.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);
		parserContext.getRegistry().registerBeanDefinition(PATH_MATCHER_BEAN_NAME, pathMatcherDef);
		parserContext.registerComponent(new BeanComponentDefinition(pathMatcherDef, PATH_MATCHER_BEAN_NAME));
	}
	return new RuntimeBeanReference(PATH_MATCHER_BEAN_NAME);
}
 
Example #5
Source File: MvcNamespaceUtils.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Adds an alias to an existing well-known name or registers a new instance of a {@link PathMatcher}
 * under that well-known name, unless already registered.
 * @return a RuntimeBeanReference to this {@link PathMatcher} instance
 */
public static RuntimeBeanReference registerPathMatcher(
		RuntimeBeanReference pathMatcherRef, ParserContext parserContext, Object source) {

	if (pathMatcherRef != null) {
		if (parserContext.getRegistry().isAlias(PATH_MATCHER_BEAN_NAME)) {
			parserContext.getRegistry().removeAlias(PATH_MATCHER_BEAN_NAME);
		}
		parserContext.getRegistry().registerAlias(pathMatcherRef.getBeanName(), PATH_MATCHER_BEAN_NAME);
	}
	else if (!parserContext.getRegistry().isAlias(PATH_MATCHER_BEAN_NAME)
			&& !parserContext.getRegistry().containsBeanDefinition(PATH_MATCHER_BEAN_NAME)) {
		RootBeanDefinition pathMatcherDef = new RootBeanDefinition(AntPathMatcher.class);
		pathMatcherDef.setSource(source);
		pathMatcherDef.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);
		parserContext.getRegistry().registerBeanDefinition(PATH_MATCHER_BEAN_NAME, pathMatcherDef);
		parserContext.registerComponent(new BeanComponentDefinition(pathMatcherDef, PATH_MATCHER_BEAN_NAME));
	}
	return new RuntimeBeanReference(PATH_MATCHER_BEAN_NAME);
}
 
Example #6
Source File: SwaggerIndexPageTransformer.java    From springdoc-openapi with Apache License 2.0 6 votes vote down vote up
@Override
public Mono<Resource> transform(ServerWebExchange serverWebExchange, Resource resource, ResourceTransformerChain resourceTransformerChain) {
	final AntPathMatcher antPathMatcher = new AntPathMatcher();

	try {
		boolean isIndexFound = antPathMatcher.match("**/swagger-ui/**/index.html", resource.getURL().toString());
		if (isIndexFound && hasDefaultTransformations()) {
			String html = defaultTransformations(resource.getInputStream());
			return Mono.just(new TransformedResource(resource, html.getBytes()));
		}
		else {
			return Mono.just(resource);
		}
	}
	catch (Exception e) {
		throw new SpringDocUIException("Failed to transform Index", e);
	}
}
 
Example #7
Source File: DynamicSecurityMetadataSource.java    From mall-swarm with Apache License 2.0 6 votes vote down vote up
@Override
public Collection<ConfigAttribute> getAttributes(Object o) throws IllegalArgumentException {
    if (configAttributeMap == null) this.loadDataSource();
    List<ConfigAttribute>  configAttributes = new ArrayList<>();
    //获取当前访问的路径
    String url = ((FilterInvocation) o).getRequestUrl();
    String path = URLUtil.getPath(url);
    PathMatcher pathMatcher = new AntPathMatcher();
    Iterator<String> iterator = configAttributeMap.keySet().iterator();
    //获取访问该路径所需资源
    while (iterator.hasNext()) {
        String pattern = iterator.next();
        if (pathMatcher.match(pattern, path)) {
            configAttributes.add(configAttributeMap.get(pattern));
        }
    }
    // 未设置操作请求权限,返回空集合
    return configAttributes;
}
 
Example #8
Source File: PatternsRequestCondition.java    From java-technology-stack with MIT License 6 votes vote down vote up
/**
 * Private constructor accepting a collection of patterns.
 */
private PatternsRequestCondition(Collection<String> patterns, @Nullable UrlPathHelper urlPathHelper,
		@Nullable PathMatcher pathMatcher, boolean useSuffixPatternMatch,
		boolean useTrailingSlashMatch, @Nullable List<String> fileExtensions) {

	this.patterns = Collections.unmodifiableSet(prependLeadingSlash(patterns));
	this.pathHelper = (urlPathHelper != null ? urlPathHelper : new UrlPathHelper());
	this.pathMatcher = (pathMatcher != null ? pathMatcher : new AntPathMatcher());
	this.useSuffixPatternMatch = useSuffixPatternMatch;
	this.useTrailingSlashMatch = useTrailingSlashMatch;

	if (fileExtensions != null) {
		for (String fileExtension : fileExtensions) {
			if (fileExtension.charAt(0) != '.') {
				fileExtension = "." + fileExtension;
			}
			this.fileExtensions.add(fileExtension);
		}
	}
}
 
Example #9
Source File: InterceptorRegistryTests.java    From spring4-understanding with Apache License 2.0 6 votes vote down vote up
private List<HandlerInterceptor> getInterceptorsForPath(String lookupPath) {
	PathMatcher pathMatcher = new AntPathMatcher();
	List<HandlerInterceptor> result = new ArrayList<HandlerInterceptor>();
	for (Object interceptor : this.registry.getInterceptors()) {
		if (interceptor instanceof MappedInterceptor) {
			MappedInterceptor mappedInterceptor = (MappedInterceptor) interceptor;
			if (mappedInterceptor.matches(lookupPath, pathMatcher)) {
				result.add(mappedInterceptor.getInterceptor());
			}
		}
		else if (interceptor instanceof HandlerInterceptor) {
			result.add((HandlerInterceptor) interceptor);
		}
		else {
			fail("Unexpected interceptor type: " + interceptor.getClass().getName());
		}
	}
	return result;
}
 
Example #10
Source File: ClientRSocketRequesterTests.java    From spring-cloud-rsocket with Apache License 2.0 6 votes vote down vote up
@Test
public void forwardingWorks() {
	RouteMatcher routeMatcher = new SimpleRouteMatcher(new AntPathMatcher("."));
	RouteMatcher.Route route = routeMatcher.parseRoute("myroute.foo1.bar1");
	LinkedHashMap<TagKey, String> tags = new LinkedHashMap<>();
	tags.put(TagKey.of(SERVICE_NAME), "{foo}");
	tags.put(TagKey.of(ROUTE_ID), "22");
	tags.put(TagKey.of("mycustomkey"), "{foo}-{bar}");
	Forwarding fwd = (Forwarding) forwarding(routeMatcher, route,
			new BigInteger("11"), "myroute.{foo}.{bar}", tags).build();

	assertThat(fwd).isNotNull();
	assertThat(fwd.getEnrichedTagsMetadata().getTags()).isNotEmpty()
			.containsEntry(new Key(SERVICE_NAME), "foo1")
			.containsEntry(new Key(ROUTE_ID), "22")
			.containsEntry(new Key("mycustomkey"), "foo1-bar1");
}
 
Example #11
Source File: HdfsResourceLoader.java    From ambiverse-nlu with Apache License 2.0 6 votes vote down vote up
public HdfsResourceLoader(Configuration config, URI uri, String user) {
    this.pathMatcher = new AntPathMatcher();
    this.internalFS = true;
    FileSystem tempFS = null;

    try {
        if (uri == null) {
            uri = FileSystem.getDefaultUri(config);
        }

        tempFS = user != null ? FileSystem.get(uri, config, user) : FileSystem.get(uri, config);
    } catch (Exception var9) {
        tempFS = null;
        throw new IllegalStateException("Cannot create filesystem", var9);
    } finally {
        this.fs = tempFS;
    }

}
 
Example #12
Source File: DynamicSecurityMetadataSource.java    From mall with Apache License 2.0 6 votes vote down vote up
@Override
public Collection<ConfigAttribute> getAttributes(Object o) throws IllegalArgumentException {
    if (configAttributeMap == null) this.loadDataSource();
    List<ConfigAttribute>  configAttributes = new ArrayList<>();
    //获取当前访问的路径
    String url = ((FilterInvocation) o).getRequestUrl();
    String path = URLUtil.getPath(url);
    PathMatcher pathMatcher = new AntPathMatcher();
    Iterator<String> iterator = configAttributeMap.keySet().iterator();
    //获取访问该路径所需资源
    while (iterator.hasNext()) {
        String pattern = iterator.next();
        if (pathMatcher.match(pattern, path)) {
            configAttributes.add(configAttributeMap.get(pattern));
        }
    }
    // 未设置操作请求权限,返回空集合
    return configAttributes;
}
 
Example #13
Source File: DynamicSecurityFilter.java    From mall with Apache License 2.0 6 votes vote down vote up
@Override
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
    HttpServletRequest request = (HttpServletRequest) servletRequest;
    FilterInvocation fi = new FilterInvocation(servletRequest, servletResponse, filterChain);
    //OPTIONS请求直接放行
    if(request.getMethod().equals(HttpMethod.OPTIONS.toString())){
        fi.getChain().doFilter(fi.getRequest(), fi.getResponse());
        return;
    }
    //白名单请求直接放行
    PathMatcher pathMatcher = new AntPathMatcher();
    for (String path : ignoreUrlsConfig.getUrls()) {
        if(pathMatcher.match(path,request.getRequestURI())){
            fi.getChain().doFilter(fi.getRequest(), fi.getResponse());
            return;
        }
    }
    //此处会调用AccessDecisionManager中的decide方法进行鉴权操作
    InterceptorStatusToken token = super.beforeInvocation(fi);
    try {
        fi.getChain().doFilter(fi.getRequest(), fi.getResponse());
    } finally {
        super.afterInvocation(token, null);
    }
}
 
Example #14
Source File: WildcardLogsSource.java    From logsniffer with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public List<Log> getLogs() throws IOException {
	final PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
	resolver.setPathMatcher(new AntPathMatcher());
	final Resource[] resources = resolver.getResources("file:" + getPattern());
	final ArrayList<Log> logs = new ArrayList<Log>(resources.length);
	// TODO Decouple direct file log association
	for (int i = 0; i < resources.length; i++) {
		if (resources[i].exists()) {
			if (resources[i].getFile().isFile()) {
				logs.add(new FileLog(resources[i].getFile()));
			}
		} else {
			logger.info("Ignore not existent file: {}", resources[i].getFile());
		}
	}
	return logs;
}
 
Example #15
Source File: PatternsRequestCondition.java    From spring4-understanding with Apache License 2.0 6 votes vote down vote up
/**
 * Private constructor accepting a collection of patterns.
 */
private PatternsRequestCondition(Collection<String> patterns, UrlPathHelper urlPathHelper,
		PathMatcher pathMatcher, boolean useSuffixPatternMatch, boolean useTrailingSlashMatch,
		List<String> fileExtensions) {

	this.patterns = Collections.unmodifiableSet(prependLeadingSlash(patterns));
	this.pathHelper = (urlPathHelper != null ? urlPathHelper : new UrlPathHelper());
	this.pathMatcher = (pathMatcher != null ? pathMatcher : new AntPathMatcher());
	this.useSuffixPatternMatch = useSuffixPatternMatch;
	this.useTrailingSlashMatch = useTrailingSlashMatch;
	if (fileExtensions != null) {
		for (String fileExtension : fileExtensions) {
			if (fileExtension.charAt(0) != '.') {
				fileExtension = "." + fileExtension;
			}
			this.fileExtensions.add(fileExtension);
		}
	}
}
 
Example #16
Source File: DefaultLdapServiceMapper.java    From cas4.0.x-server-wechat with Apache License 2.0 5 votes vote down vote up
private AbstractRegisteredService getRegisteredService(@NotNull final String id) {
    if (isValidRegexPattern(id)) {
        return new RegexRegisteredService();
    }

    if (new AntPathMatcher().isPattern(id)) {
        return new RegisteredServiceImpl();
    }
    return null;
}
 
Example #17
Source File: SecureResourceFilterInvocationDefinitionSource.java    From Auth-service with MIT License 5 votes vote down vote up
@Override
public void afterPropertiesSet() throws Exception {
    logger.info("afterPropertiesSet");
    //用来匹配访问资源路径
    this.matcher = new AntPathMatcher();
    //可以有多个权限
    Collection<ConfigAttribute> atts = new ArrayList<>();
    ConfigAttribute c1 = new SecurityConfig("ROLE_USER");
    atts.add(c1);
    map.put("/api/permission/apiPermissions", atts);
}
 
Example #18
Source File: RegisteredServiceEditBean.java    From springboot-shiro-cas-mybatis with MIT License 5 votes vote down vote up
/**
 * Determine service type by pattern.
 *
 * @param serviceId the service id
 * @return the abstract registered service
 */
private AbstractRegisteredService determineServiceTypeByPattern(final String serviceId) {
    try {
        Pattern.compile(serviceId);
        LOGGER.debug("Service id {} is a valid regex.", serviceId);
        return new RegexRegisteredService();
    } catch (final PatternSyntaxException exception) {
        LOGGER.debug("Service id {} is not a valid regex. Checking ant patterns...", serviceId);
        if (new AntPathMatcher().isPattern(serviceId)) {
            LOGGER.debug("Service id {} is a valid ant pattern.", serviceId);
            return new RegisteredServiceImpl();
        }
    }
    throw new RuntimeException("Service id " + serviceId + " cannot be resolve to a service type");
}
 
Example #19
Source File: CsrfFilter.java    From framework with Apache License 2.0 5 votes vote down vote up
/**
 * 过滤非认证URL
 * <p>和Spring Security的白名单类似</p>
 *
 * @param request req
 * @return 返回结果
 */
private boolean isExclusives(HttpServletRequest request) {
    List<String> exclusivePath = CHERRY.SPRING_CONTEXT.getBean(AdamProperties.class).getSecurity().getExclusivePath();
    AntPathMatcher antPathMatcher = new AntPathMatcher();
    String requestURI = request.getRequestURI();
    for (String exclusive : exclusivePath) {
        if (antPathMatcher.match(exclusive, requestURI)) {
            return true;
        }
    }
    return false;
}
 
Example #20
Source File: PermissionFilter.java    From framework with Apache License 2.0 5 votes vote down vote up
private boolean isExclusives(HttpServletRequest request) {
    List<String> exclusivePath = CHERRY.SPRING_CONTEXT.getBean(AdamProperties.class).getSecurity().getExclusivePath();
    AntPathMatcher antPathMatcher = new AntPathMatcher();
    String requestURI = request.getRequestURI();
    for (String exclusive : exclusivePath) {
        if (antPathMatcher.match(exclusive, requestURI)) {
            return true;
        }
    }
    return false;
}
 
Example #21
Source File: DefaultLdapRegisteredServiceMapper.java    From springboot-shiro-cas-mybatis with MIT License 5 votes vote down vote up
/**
 * Gets the registered service by id that would either match an ant or regex pattern.
 *
 * @param id the id
 * @return the registered service
 */
private AbstractRegisteredService getRegisteredService(@NotNull final String id) {
    if (isValidRegexPattern(id)) {
        return new RegexRegisteredService();
    }

    if (new AntPathMatcher().isPattern(id)) {
        return new RegisteredServiceImpl();
    }
    return null;
}
 
Example #22
Source File: ServiceMatcherTests.java    From spring-cloud-bus with Apache License 2.0 5 votes vote down vote up
private void initMatcher(String id) {
	BusProperties properties = new BusProperties();
	properties.setId(id);
	DefaultBusPathMatcher pathMatcher = new DefaultBusPathMatcher(
			new AntPathMatcher(":"));
	this.matcher = new ServiceMatcher(pathMatcher, properties.getId());
}
 
Example #23
Source File: MessageBrokerConfigurationTests.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Override
protected void configureMessageBroker(MessageBrokerRegistry registry) {
	registry.configureBrokerChannel().interceptors(this.interceptor, this.interceptor, this.interceptor);
	registry.configureBrokerChannel().taskExecutor()
			.corePoolSize(31).maxPoolSize(32).keepAliveSeconds(33).queueCapacity(34);
	registry.setPathMatcher(new AntPathMatcher(".")).enableSimpleBroker("/topic", "/queue");
	registry.setCacheLimit(8192);
	registry.setPreservePublishOrder(true);
	registry.setUserRegistryOrder(99);
}
 
Example #24
Source File: SecurityConfig.java    From Spring with Apache License 2.0 5 votes vote down vote up
@Bean
public FilterSecurityInterceptor filterSecurityInterceptor() throws Exception {
    final FilterSecurityInterceptor fSecInterceptor = new FilterSecurityInterceptor();
    //fSecInterceptor.setAccessDecisionManager(------);
    fSecInterceptor.setAuthenticationManager(super.authenticationManager());
    fSecInterceptor.setSecurityMetadataSource(
            new DefaultFilterInvocationSecurityMetadataSource(
                    (LinkedHashMap<RequestMatcher, Collection<ConfigAttribute>>) new LinkedHashMap().put(
                            new AntPathMatcher("/chief**"), new ArrayList().add("ROLE_CHIEF"))));
    return fSecInterceptor;
}
 
Example #25
Source File: WebMvcConfigurationSupportTests.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Test
public void defaultPathMatchConfiguration() throws Exception {
	ApplicationContext context = initContext(WebConfig.class);
	UrlPathHelper urlPathHelper = context.getBean(UrlPathHelper.class);
	PathMatcher pathMatcher = context.getBean(PathMatcher.class);

	assertNotNull(urlPathHelper);
	assertNotNull(pathMatcher);
	assertEquals(AntPathMatcher.class, pathMatcher.getClass());
}
 
Example #26
Source File: ImageBatchCompressor.java    From onetwo with Apache License 2.0 5 votes vote down vote up
public void initialize() {
	if (LangUtils.isEmpty(antPatterns)) {
		throw new IllegalArgumentException("antPatterns can not be empty!");
	}
	if (compressorConfig==null) {
		compressorConfig = ImageCompressorConfig.builder().scale(0.3).quality(0.3).build(); 
	}
	ImageCompressor compressor = new ImageCompressor();
	compressor.setConfig(compressorConfig);
	this.imageCompressor = compressor;
	this.antMatcher = new AntPathMatcher();
	this.compressThresholdSizeInBytes = LangOps.parseSize(compressThresholdSize, -1);
}
 
Example #27
Source File: WebMvcConfigurationSupportTests.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Test
public void defaultPathMatchConfiguration() throws Exception {
	ApplicationContext context = initContext(WebConfig.class);
	UrlPathHelper urlPathHelper = context.getBean(UrlPathHelper.class);
	PathMatcher pathMatcher = context.getBean(PathMatcher.class);

	assertNotNull(urlPathHelper);
	assertNotNull(pathMatcher);
	assertEquals(AntPathMatcher.class, pathMatcher.getClass());
}
 
Example #28
Source File: ControllerUtils.java    From genie with Apache License 2.0 5 votes vote down vote up
/**
 * Get the remaining path from a given request. e.g. if the request went to a method with the matching pattern of
 * /api/v3/jobs/{id}/output/** and the request was /api/v3/jobs/{id}/output/blah.txt the return value of this
 * method would be blah.txt.
 *
 * @param request The http servlet request.
 * @return The remaining path
 */
public static String getRemainingPath(final HttpServletRequest request) {
    String path = (String) request.getAttribute(HandlerMapping.PATH_WITHIN_HANDLER_MAPPING_ATTRIBUTE);
    if (path != null) {
        final String bestMatchPattern
            = (String) request.getAttribute(HandlerMapping.BEST_MATCHING_PATTERN_ATTRIBUTE);
        log.debug("bestMatchPattern = {}", bestMatchPattern);
        path = new AntPathMatcher().extractPathWithinPattern(bestMatchPattern, path);
    }
    path = path == null ? EMPTY_STRING : path;
    log.debug("Remaining path = {}", path);
    return path;
}
 
Example #29
Source File: NameBasedFilter.java    From gitlab-plugin with GNU General Public License v2.0 5 votes vote down vote up
private boolean isBranchIncluded(String branchName) {
    AntPathMatcher matcher = new AntPathMatcher();
    for (String includePattern : includedBranches) {
        if (matcher.match(includePattern, branchName)) {
            return true;
        }
    }
    return includedBranches.isEmpty();
}
 
Example #30
Source File: UrlResourceInfoParserTest.java    From onetwo with Apache License 2.0 5 votes vote down vote up
@Test
public void testAntMatcher(){
	AntPathMatcher path = new AntPathMatcher();
	boolean rs = path.match("/user.*", "/user.json?aaa=bbb&cc=ddd");
	Assert.assertTrue(rs);
	//后缀的点号变成可选的写法?
	rs = path.match("/user.*", "/user");
	Assert.assertFalse(rs);
}