jdbcRealm 获取permission subject.isPermitted("user:delete")总是false
//权限查询 String permissionSql="SELECT t1.permission FROM roles_permissions t1 INNER JOIN test_user_role t2 " + "ON t1.rolename= t2.rolename " + "AND t2.username= ?"; jdbcRealm.setPermissionsQuery(permissionSql); //1. 构建securityManager环境 DefaultSecurityManager defaultSecurityManager=new DefaultSecurityManager(); defaultSecurityManager.setRealm(jdbcRealm); //2. 主体提交认证请求 SecurityUtils.setSecurityManager(defaultSecurityManager); Subject subject=SecurityUtils.getSubject(); UsernamePasswordToken token =new UsernamePasswordToken("xiaoming","123"); //subject.login(token); //System.out.println("loginresult:"+subject.isAuthenticated()); //System.out.println("++++"); //subject.checkRole("user"); //System.out.println("roleresult:"+subject.hasRole("user")); //System.out.println("====="); System.out.println("permissionresult:"+subject.isPermitted("user:delete"));
输出结果:
permissionresult:false
这个permission结果怎么总是false?数据库中执行这个sql 结果就是 user:delete 。但是这里执行就是false
求讲解