首页 > 其他分享 >IllegalArgumentException: Wildcard string cannot be null or empty. Make sure permission strings are

IllegalArgumentException: Wildcard string cannot be null or empty. Make sure permission strings are

时间:2022-12-23 14:35:38浏览次数:44  
标签:sure java string permission AuthorizingRealm apache org shiro


IllegalArgumentException: Wildcard string cannot be null or empty. Make sure permission strings are properly formatted异常解决办法

一. 异常现象

我在ssm项目中整合shiro时,配置了接口及资源与过滤器之间映射关系时,产生了如下异常信息:

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.<init>(WildcardPermission.java:144)
at org.apache.shiro.authz.permission.WildcardPermission.<init>(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)
at org.apache.shiro.authz.ModularRealmAuthorizer.isPermitted(ModularRealmAuthorizer.java:223)
at org.apache.shiro.mgt.AuthorizingSecurityManager.isPermitted(AuthorizingSecurityManager.java:113)
at org.apache.shiro.subject.support.DelegatingSubject.isPermitted(DelegatingSubject.java:162)
at ......

二. 异常原因

List<String> permissions = userService.selectPermissionsByUserId(user.getId());

根据用户id查询到的permissions集合中,存在null或者empty空值!

IllegalArgumentException: Wildcard string cannot be null or empty. Make sure permission strings are_apache

在shiro添加权限的方法addStringPermissions(list)中,集合中的元素不能是空值!

三. 解决办法

将集合中的空值过滤掉!

List<String> permissions = userService.selectPermissionsByUserId(user.getId());
List<String> collect = permissions.stream().filter(item -> item != null).collect(Collectors.toList());
info.addStringPermissions(collect);

 

标签:sure,java,string,permission,AuthorizingRealm,apache,org,shiro
From: https://blog.51cto.com/u_7044146/5965617

相关文章

  • 记录:去除list<Map<String,Object>>中主键重复的map
    /**mapKey 主键key**/publicstaticList<Map<String,Object>>removeRepeatMapByKey(List<Map<String,Object>>list,StringmapKey){List<Map<String,Object>......
  • Using Python to Check If List of Words in String
    TocheckifalistofwordsisinastringusingPython,theeasiestwayiswithlistcomprehension.>>>list_of_words=["this","words","string"]>>>string=......
  • Cstring转string
    //第一种方式:CStringstr=_T("CSDN");USES_CONVERSION;std::strings(W2A(str));//第二种方式:CStringstr=_T("CSDN");std::strings=(CT2A)str;string转CstringCS......
  • String和int互相转化
    String和int互相转化(java)1如何将字串String转换成整数int?A.有两个方法:1、 inti=Integer.parseInt([String]); 或 i=Integer.parseInt([String]......
  • 异常String不可以转换为Integer处理
    出现异常String不可以转换为Integerjava.lang.Stringcannotbecasttojava.lang.Integerjava.lang.Stringcannotbecasttojava.lang.Integer解决方案_「已注销」......
  • MFC中的CString类使用方法指南
    MFC中的CString类使用方法指南codeproject:CStringManagement【禾路:这是一篇比较老的资料了,但是对于MFC的程序设计很有帮助。我们在MFC中使用字符串的相关操作,首先想到的就......
  • String.contains空指针异常
    今天在写业务代码的时候,大致如下   然后a.contains报了空指针异常,让我很是诧异结果发现,是缓存获取到了一个nullnull.contains这种样子就会出现空指针......
  • 标准 C++ 中的 string 类的用法总结
     相信使用过MFC编程的朋友对CString这个类的印象应该非常深刻吧?的确,MFC中的CString类使用起来真的非常的方便好用。但是如果离开了MFC框架,还有没有这样使用起来......
  • XAMPP里tomcat启动报错:Make sure you have Java JDK or JRE installed and the requir
    ​​参考博客​​**1.运行命令行win+R在cmd中输入regedit出现下面的界面**2.在注册表中添加HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft/JavaDevelopmentKit3.成功界......
  • Generates Regular Expressions That Match A Set of Strings
    GitHub-devongovett/regexgen:GenerateregularexpressionsthatmatchasetofstringsHowdoesitwork?GenerateaTriecontainingalloftheinputstrings.......