Search in sources :

Example 1 with TbShiroFilter

use of cn.exrick.manager.pojo.TbShiroFilter in project xmall by Exrick.

the class MyShiroFilterFactoryBean method setFilterChainDefinitions.

/**
 * 从数据库动态读取权限
 */
@Override
public void setFilterChainDefinitions(String definitions) {
    MyShiroFilterFactoryBean.definitions = definitions;
    // 数据库动态权限
    List<TbShiroFilter> list = systemService.getShiroFilter();
    for (TbShiroFilter tbShiroFilter : list) {
        // 字符串拼接权限
        definitions = definitions + tbShiroFilter.getName() + " = " + tbShiroFilter.getPerms() + "\n";
    }
    log.info(definitions);
    // 从配置文件加载权限配置
    Ini ini = new Ini();
    ini.load(definitions);
    Ini.Section section = ini.getSection("urls");
    if (CollectionUtils.isEmpty(section)) {
        section = ini.getSection("");
    }
    this.setFilterChainDefinitionMap(section);
}
Also used : Ini(org.apache.shiro.config.Ini) TbShiroFilter(cn.exrick.manager.pojo.TbShiroFilter)

Example 2 with TbShiroFilter

use of cn.exrick.manager.pojo.TbShiroFilter in project xmall by Exrick.

the class SystemController method getShiroList.

@RequestMapping(value = "/sys/shiro/list", method = RequestMethod.GET)
@ApiOperation(value = "获取shiro过滤链配置")
public DataTablesResult getShiroList(@ModelAttribute TbUser tbUser) {
    DataTablesResult result = new DataTablesResult();
    List<TbShiroFilter> list = systemService.getShiroFilter();
    result.setData(list);
    result.setSuccess(true);
    return result;
}
Also used : DataTablesResult(cn.exrick.common.pojo.DataTablesResult) TbShiroFilter(cn.exrick.manager.pojo.TbShiroFilter) ApiOperation(io.swagger.annotations.ApiOperation)

Aggregations

TbShiroFilter (cn.exrick.manager.pojo.TbShiroFilter)2 DataTablesResult (cn.exrick.common.pojo.DataTablesResult)1 ApiOperation (io.swagger.annotations.ApiOperation)1 Ini (org.apache.shiro.config.Ini)1