Shiro报错:“通配符字符串不能为空或空。确保权限字符串被正确格式化。”
权限列表filterChainDefinitionMap
中Debug如下:
通过实现自定义filter,继承自org.apache.shiro.web.filter.AccessControlFilter
:
@Override
protected boolean isAccessAllowed(ServletRequest servletRequest, ServletResponse servletResponse, Object mappedValue) throws Exception {
log.info("PermissionAuthorizationFilter执行");
Subject subject = getSubject(servletRequest, servletResponse);
if(null != mappedValue){
String[] value = (String[])mappedValue;
for (String permission : value) {
if(subject.isPermitted(permission)){
return true;
}
}
}
return false;
}
在上述代码中执行到subject.isPermitted部分报错,Debug传入传输为:
错误信息:
java.lang.IllegalArgumentException: Wildcard string cannot be null or empty. Make sure permission strings are properly formatted.
shiro源码部分:
protected void setParts(String wildcardString, boolean caseSensitive) {
if (wildcardString != null && wildcardString.trim().length() != 0) {
wildcardString = wildcardString.trim();
List<String> parts = CollectionUtils.asList(wildcardString.split(":"));
this.parts = new ArrayList();
Iterator i$ = parts.iterator();
while(i$.hasNext()) {
String part = (String)i$.next();
Set<String> subparts = CollectionUtils.asSet(part.split(","));
if (!caseSensitive) {
subparts = this.lowercase(subparts);
}
if (subparts.isEmpty()) {
throw new IllegalArgumentException("Wildcard string cannot contain parts with only dividers. Make sure permission strings are properly formatted.");
}
this.parts.add(subparts);
}
if (this.parts.isEmpty()) {
throw new IllegalArgumentException("Wildcard string cannot contain only dividers. Make sure permission strings are properly formatted.");
}
} else {
throw new IllegalArgumentException("Wildcard string cannot be null or empty. Make sure permission strings are properly formatted."); //报出此异常
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
原因找到了,一直将着力点找错了,其错误的原因在获取个人权限的地方没有进行权限判断,只有在全局的权限添加进行了判断。