use of org.apache.shiro.util.AntPathMatcher in project pmph by BCSquad.
the class UrlPermission method implies.
/**
* 一个很重要的方法,用户判断 Realm 中设置的权限和从数据库或者配置文件中传递进来的权限信息是否匹配 如果 Realm
* 的授权方法中,一个认证主体有多个权限,会进行遍历,直到匹配成功为止 this.url 是在遍历状态中变化的
*
* urlPermission.url 是从 subject.isPermitted(url) 传递到 UrlPermissionResolver 中传递过来的,就一个固定值
*
* @param permission
* @return
*/
@Override
public boolean implies(Permission permission) {
if (!(permission instanceof UrlPermission)) {
return false;
}
//
UrlPermission urlPermission = (UrlPermission) permission;
PatternMatcher patternMatcher = new AntPathMatcher();
logger.info("this.url(来自数据库中存放的通配符数据),在 Realm 的授权方法中注入的 => " + this.url);
logger.info("urlPermission.url(来自浏览器正在访问的链接) => " + urlPermission.url);
boolean matches = patternMatcher.matches(this.url, urlPermission.url);
logger.info("matches => " + matches);
return matches;
}
use of org.apache.shiro.util.AntPathMatcher in project shiro by apache.
the class PathMatchingFilterChainResolverTest method testSetters.
@Test
public void testSetters() {
resolver.setPathMatcher(new AntPathMatcher());
assertNotNull(resolver.getPathMatcher());
assertTrue(resolver.getPathMatcher() instanceof AntPathMatcher);
resolver.setFilterChainManager(new DefaultFilterChainManager());
assertNotNull(resolver.getFilterChainManager());
assertTrue(resolver.getFilterChainManager() instanceof DefaultFilterChainManager);
}
use of org.apache.shiro.util.AntPathMatcher in project shiro by apache.
the class PathMatchingFilterChainResolverTest method testNewInstanceWithFilterConfig.
@Test
public void testNewInstanceWithFilterConfig() {
FilterConfig mock = createNiceMockFilterConfig();
replay(mock);
resolver = new PathMatchingFilterChainResolver(mock);
assertNotNull(resolver.getPathMatcher());
assertTrue(resolver.getPathMatcher() instanceof AntPathMatcher);
assertNotNull(resolver.getFilterChainManager());
assertTrue(resolver.getFilterChainManager() instanceof DefaultFilterChainManager);
assertEquals(((DefaultFilterChainManager) resolver.getFilterChainManager()).getFilterConfig(), mock);
verify(mock);
}
Aggregations