CN108566433A - 一种集成了Shiro权限管理的SSM系统实现本地配置的方法 - Google Patents

一种集成了Shiro权限管理的SSM系统实现本地配置的方法 Download PDF

Info

Publication number
CN108566433A
CN108566433A CN201810413288.3A CN201810413288A CN108566433A CN 108566433 A CN108566433 A CN 108566433A CN 201810413288 A CN201810413288 A CN 201810413288A CN 108566433 A CN108566433 A CN 108566433A
Authority
CN
China
Prior art keywords
shiro
url
integrated
value
key
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN201810413288.3A
Other languages
English (en)
Inventor
陈林
张来卿
庞严冬
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Zhuhai Hengqin Shengda Zhaoye Technology Investment Co Ltd
Original Assignee
Zhuhai Hengqin Shengda Zhaoye Technology Investment Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Zhuhai Hengqin Shengda Zhaoye Technology Investment Co Ltd filed Critical Zhuhai Hengqin Shengda Zhaoye Technology Investment Co Ltd
Priority to CN201810413288.3A priority Critical patent/CN108566433A/zh
Publication of CN108566433A publication Critical patent/CN108566433A/zh
Pending legal-status Critical Current

Links

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/2866Architectures; Arrangements
    • H04L67/30Profiles
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L41/00Arrangements for maintenance, administration or management of data switching networks, e.g. of packet switching networks
    • H04L41/08Configuration management of networks or network elements
    • H04L41/0803Configuration setting

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Storage Device Security (AREA)

Abstract

本发明涉及基于Shiro权限管理平台的技术领域,特别涉及一种集成了Shiro权限管理的SSM系统实现本地配置的方法。本发明的方法是把需要经过Shiro权限控制的Url,通过Key与Value的模式存放在一个属性配置文件里,如果有多个Url要配置,用“,”分割进行存放。然后修改Shiro源码,加载这个配置文件,通过Key获取所有的Value值,经过一定的算法,把Value里的内容按不同的角色添加到权限控制的集合里。本发明解决了集成了Shiro权限管理的SSM系统不能方便地配置URL管控的问题。

Description

一种集成了Shiro权限管理的SSM系统实现本地配置的方法
技术领域
本发明涉及Shiro权限管理技术领域,特别涉及一种集成了Shiro权限管理的SSM系统实现本地配置的方法。
背景技术
在集成了Shiro权限管理的SSM系统中,官方没有提供一套易于理解的、可在本地属性文件中配置Url实现权限管控的功能,必须要求用户在提供的Shiro.xml文件中配置。此文件对于非专业开发人员来说,确实非常难懂,导致一般用户无法配置;为了解决这些问题,需要实现一种简单易懂的权限配置功能。
发明内容
本发明解决的技术问题在于提供一种集成了Shiro权限管理的SSM系统实现本地配置的方法;解决了集成了Shiro权限管理的SSM系统不能方便地配置URL管控的问题。
本发明解决上述技术问题的技术方案是:
把需要经过Shiro权限控制的Url,通过Key与Value的模式存放在一个属性配置文件里,如果有多个Url要配置,用“,”分割进行存放。然后修改Shiro源码,加载这个配置文件,通过Key获取所有的Value值,经过一定的算法,把Value里的内容按不同的角色添加到权限控制的集合里。从而解决了集成了Shiro权限管理的SSM系统不能方便地配置URL管控的问题。
所述的方法具体包括如下步骤:
步骤一、打开系统中的config.propertis文件,写入需要权限管控的Url,以Key与Value的方式存放,如果有多个Url,以“,”分割;
步骤二、在项目中重新创建一个类,复制Shiro提供的ShiroFilterFactoryBean类的内容到里面;
步骤三、找到setFilterChainDefinitions(String definitions)方法,在方法内部加载config.propertis文件;
步骤四、通过定义的Key找到所有的Value值,经过一定的算法,把其按不同的角色添加到权限管控集合中;
步骤五、把这个新类替换Shiro.xml文件中的过滤器选项即可。
本发明的有益效果:实现了一种集成了Shiro权限管理的SSM系统实现可本地配置的方法。本发明的方法是是把需要经过Shiro权限控制的Url,通过Key与Value的模式存放在一个属性配置文件里,如果有多个Url要配置,用“,”分割进行存放。然后修改Shiro源码,加载这个配置文件,通过Key获取所有的Value值,经过一定的算法,把Value里的内容按不同的角色添加到权限控制的集合里,从而达到可以在属性文件里方便地配置Url管控的目的。有效解决了集成了Shiro权限管理的SSM系统不能方便地配置URL管控的问题。
附图说明
下面结合附图对本发明进一步说明:
图1为本发明的流程图。
具体实施方式
如图1所示,本发明采用如下步骤:
步骤一、打开系统中的config.propertis文件,写入需要权限管控的Url,以Key与Value的方式存放,如果有多个Url,以“,”分割;如:
//放行url
open.url=/open/url1, /open/url2
//不放行url
close.url=/close/url1,/close/url2
步骤二、在项目中重新创建一个类,复制Shiro提供的ShiroFilterFactoryBean类的内容到里面; 如:
public class ShiroFilterFactoryBean implements FactoryBean,BeanPostProcessor {
private SecurityManager securityManager;
private Map<String, Filter> filters;
private Map<String, String> filterChainDefinitionMap;
……
}
步骤三、找到setFilterChainDefinitions(String definitions)方法,在方法内部加载config.propertis文件;如:
public void setFilterChainDefinitions(String definitions) {
String config = ProFileConfig.getFile(“config”);
……
}
步骤四、通过定义的Key找到所有的Value值,经过一定的算法,把其按不同的角色添加到权限管控集合中;如:
//读取open.url
String openUrl = PropFileConfig.load(config).get("open.url");
//读取不入行url
String closeUrl = PropFileConfig. load(config).get ("close.url");
//添加放行url
String anons = "";
if (StringUtil.isNotEmpty(openUrl)) {//判断不为空
if (openUrl.endsWith(",")) {//判断以,结尾
openUrl = openUrl.substring(0, openUrl.length() - 1);
}
if (openUrl.contains(",")) {
String[] strs = openUrl.split(",");
for (String str : strs) {
anons += ("\t\t\t\t" + str + "=anon\n");
}
} else {
anons += ("\t\t\t\t" + openUrl + "=anon\n");
}
}
definitions = anons + definitions;
//添加不放行url
……
Ini ini = new Ini();
ini.load(definitions);
Ini.Section section = ini.getSection(IniFilterChainResolverFactory.URLS);
if (CollectionUtils.isEmpty(section)) {
section = ini.getSection(Ini.DEFAULT_SECTION_NAME);
}
//添加到集合中
setFilterChainDefinitionMap(section);
步骤五、把这个新类替换Shiro.xml文件中的过滤器选项即可;如:
<bean id="shiroFilter" class="com.sdzy.utils.ShiroFilterFactoryBean">
<property name="securityManager" ref="securityManager"/>
……
</bean >。

Claims (2)

1.一种集成了Shiro权限管理的SSM系统实现本地配置的方法,其特征在于:是把需要经过Shiro权限控制的Url,通过Key与Value的模式存放在一个属性配置文件里,如果有多个Url要配置,用“,”分割进行存放;然后修改Shiro源码,加载这个配置文件,通过Key获取所有的Value值,经过一定的算法,把Value里的内容按不同的角色添加到权限控制的集合里;从而解决了集成了Shiro权限管理的SSM系统不能方便地配置URL管控的问题。
2.根据权利要求1所述的集成了Shiro权限管理的SSM系统实现本地配置的方法,其特征在于:通过本地配置代替官方提供的配置方案;所述的方法具体包括如下步骤:
步骤一、打开系统中的config.propertis文件,写入需要权限管控的Url,以Key与Value的方式存放,如果有多个Url,以“,”分割;
步骤二、在项目中重新创建一个类,复制Shiro提供的ShiroFilterFactoryBean类的内容到里面;
步骤三、找到setFilterChainDefinitions(String definitions)方法,在方法内部加载config.propertis文件;
步骤四、通过定义的Key找到所有的Value值,经过一定的算法,把其按不同的角色添加到权限管控集合中;
步骤五、把这个新类替换Shiro.xml文件中的过滤器选项即可。
CN201810413288.3A 2018-05-03 2018-05-03 一种集成了Shiro权限管理的SSM系统实现本地配置的方法 Pending CN108566433A (zh)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201810413288.3A CN108566433A (zh) 2018-05-03 2018-05-03 一种集成了Shiro权限管理的SSM系统实现本地配置的方法

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201810413288.3A CN108566433A (zh) 2018-05-03 2018-05-03 一种集成了Shiro权限管理的SSM系统实现本地配置的方法

Publications (1)

Publication Number Publication Date
CN108566433A true CN108566433A (zh) 2018-09-21

Family

ID=63537911

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201810413288.3A Pending CN108566433A (zh) 2018-05-03 2018-05-03 一种集成了Shiro权限管理的SSM系统实现本地配置的方法

Country Status (1)

Country Link
CN (1) CN108566433A (zh)

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105824619A (zh) * 2016-03-10 2016-08-03 四川交通职业技术学院 基于Spring MVC、Apache Shiro、MyBatis框架整合的代码生成器
CN106487744A (zh) * 2015-08-25 2017-03-08 北京京东尚科信息技术有限公司 一种基于Redis存储的Shiro验证方法
CN106657046A (zh) * 2016-12-13 2017-05-10 飞狐信息技术(天津)有限公司 可配置的细粒度权限控制方法及装置
CN107705079A (zh) * 2017-11-08 2018-02-16 厦门旺集信息科技有限公司 物流仓储管理系统处理方法以及跨境电商交易方法

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106487744A (zh) * 2015-08-25 2017-03-08 北京京东尚科信息技术有限公司 一种基于Redis存储的Shiro验证方法
CN105824619A (zh) * 2016-03-10 2016-08-03 四川交通职业技术学院 基于Spring MVC、Apache Shiro、MyBatis框架整合的代码生成器
CN106657046A (zh) * 2016-12-13 2017-05-10 飞狐信息技术(天津)有限公司 可配置的细粒度权限控制方法及装置
CN107705079A (zh) * 2017-11-08 2018-02-16 厦门旺集信息科技有限公司 物流仓储管理系统处理方法以及跨境电商交易方法

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
AINUSER: ""Shiro 权限动态加载与配置方法"", 《CSDN》 *

Similar Documents

Publication Publication Date Title
US7496910B2 (en) System for policy-based management of software updates
US6061692A (en) System and method for administering a meta database as an integral component of an information server
US8613108B1 (en) Method and apparatus for location-based digital rights management
EP1460565B1 (en) Method and system for uniformly accessing multiple directory services
US6810400B2 (en) Representing database permissions as associations in computer schema
US20060174320A1 (en) System and method for efficient configuration of group policies
US8776167B2 (en) Method and system for secure access policy migration
US20070043943A1 (en) Methods and systems for network-based management of application security
US9501656B2 (en) Mapping global policy for resource management to machines
US8117643B2 (en) Mathematical definition of roles and authorizations in RBAC system
US10089371B2 (en) Extensible extract, transform and load (ETL) framework
JP2007509414A (ja) 拡張型セキュリティ・モデルを提供するシステムおよび方法
US7885975B2 (en) Mechanism for implementing file access control using labeled containers
US7657925B2 (en) Method and system for managing security policies for databases in a distributed system
US6633870B1 (en) Protocols for locking sharable files and methods for carrying out the protocols
US9202080B2 (en) Method and system for policy driven data distribution
Laborde et al. Toward authorization as a service: a study of the XACML standard
US7962532B1 (en) Management of directory quotas for file systems
CN108566433A (zh) 一种集成了Shiro权限管理的SSM系统实现本地配置的方法
US8595805B2 (en) Method and system for policy driven data disclosure
CN106940765A (zh) 一种访问权限动态控制方法
MacMillan et al. Design and implementation of the SELinux policy management server
Welch et al. Policy-driven reflective enforcement of security policies
Morris Filesystem labeling in SELinux
Park et al. Configuring Personalized Directories in File Sharing Systems

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
RJ01 Rejection of invention patent application after publication

Application publication date: 20180921

RJ01 Rejection of invention patent application after publication