无法查询权限问题 求大佬看看
我自定义sql 通过角色名查询不到权限 随后使用默认sql 并把默认sql查询 是可以获得权限
有没有大佬能说说这里面的流程是怎么样的 我把我知道的方案都试了 依然获取不到权限
setPermissionsLookupEnabled 已设置为true //这是我的测试方法 JdbcRealm jdbcRealm = new JdbcRealm(); jdbcRealm.setDataSource(dataSource); jdbcRealm.setPermissionsLookupEnabled(true); //自定义查询用户sql String sql = "select password from account where username = ?"; jdbcRealm.setAuthenticationQuery(sql); //查询角色sql String roleSql = "SELECT role_name FROM role WHERE role_id = (SELECT role_id FROM account WHERE username = ?)"; jdbcRealm.setUserRolesQuery(roleSql); //查询权限 // String permissionSql = "SELECT resource_name FROM resource WHERE resource_id in (SELECT resource_id FROM role_resource WHERE role_id = (SELECT role_id FROM role WHERE role_name = ?))"; // jdbcRealm.setPermissionsQuery(permissionSql); //构建Security环境 DefaultSecurityManager defaultSecurityManager = new DefaultSecurityManager(); defaultSecurityManager.setRealm(jdbcRealm); //主体提交认证请求 SecurityUtils.setSecurityManager(defaultSecurityManager); //获取主体 Subject subject = SecurityUtils.getSubject(); UsernamePasswordToken token = new UsernamePasswordToken("jack","123456"); subject.login(token); subject.checkRole("普通角色"); subject.checkPermission("客户管理"); System.out.println("是否认证:" + subject.isAuthenticated());