Wildcard string cannot be null or empty. Make sure permission strings are properly formatted.

点击jsp页面时shiro报错:“Wildcard string cannot be null or empty. Make sure permission strings are properly formatted.

30-May-2019 11:22:04.974 严重 [http-nio-8085-exec-3] org.apache.catalina.core.ApplicationDispatcher.invoke Servlet.service() for servlet [jsp] threw exception
 java.lang.IllegalArgumentException: Wildcard string cannot be null or empty. Make sure permission strings are properly formatted.
    at org.apache.shiro.authz.permission.WildcardPermission.setParts(WildcardPermission.java:155)
    at org.apache.shiro.authz.permission.WildcardPermission.(WildcardPermission.java:144)
    at org.apache.shiro.authz.permission.WildcardPermission.(WildcardPermission.java:140)
    at org.apache.shiro.authz.permission.WildcardPermissionResolver.resolvePermission(WildcardPermissionResolver.java:41)
    at org.apache.shiro.realm.AuthorizingRealm.resolvePermissions(AuthorizingRealm.java:434)
    at org.apache.shiro.realm.AuthorizingRealm.getPermissions(AuthorizingRealm.java:410)
    at org.apache.shiro.realm.AuthorizingRealm.isPermitted(AuthorizingRealm.java:468)
    at org.apache.shiro.realm.AuthorizingRealm.isPermitted(AuthorizingRealm.java:463)
    at org.apache.shiro.realm.AuthorizingRealm.isPermitted(AuthorizingRealm.java:458)
    .......

参考原因:

当执行jsp中

       验证“是否有name中的资源的权限”,对所有权限进行遍历时,当执行到shiro以下源码时,有权限为null或者空字符串,请仔细查找下,或者确保权限集合Set urlSet 中无null或空字符串

if (wildcardString == null || wildcardString.isEmpty()) {
            throw new IllegalArgumentException("Wildcard string cannot be null or empty. Make sure permission strings are properly formatted.");
}


shiro 中WildcardPermission源码部分:

protected void setParts(String wildcardString, boolean caseSensitive) {
        wildcardString = StringUtils.clean(wildcardString);

        if (wildcardString == null || wildcardString.isEmpty()) {
            throw new IllegalArgumentException("Wildcard string cannot be null or empty. Make sure permission strings are properly formatted.");
        }

        if (!caseSensitive) {
            wildcardString = wildcardString.toLowerCase();
        }

        List parts = CollectionUtils.asList(wildcardString.split(PART_DIVIDER_TOKEN));

        this.parts = new ArrayList>();
        for (String part : parts) {
            Set subparts = CollectionUtils.asSet(part.split(SUBPART_DIVIDER_TOKEN));

            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.");
        }
    }

你可能感兴趣的:(java,shiro)