The main part of this piece of configuration is the secureResourceFilter, this is a class that implements FilterInvocationDefinitionSource and is called when Spring Security needs to check the Authorities for a requested page.
Here is the code for MySecureResourceFilter:
- package org.security.SecureFilter;
-
- import java.util.Collection;
- import java.util.List;
-
- import org.springframework.security.ConfigAttributeDefinition;
- import org.springframework.security.ConfigAttributeEditor;
- import org.springframework.security.intercept.web.FilterInvocation;
- import org.springframework.security.intercept.web.FilterInvocationDefinitionSource;
-
-
- public class MySecureResourceFilter implements FilterInvocationDefinitionSource {
-
- public ConfigAttributeDefinition getAttributes(Object filter) throws IllegalArgumentException {
-
- FilterInvocation filterInvocation = (FilterInvocation) filter;
-
- String url = filterInvocation.getRequestUrl();
-
-
- Resource resource = new Resource(url);
-
- if (resource == null) return null;
- else{
- ConfigAttributeEditor configAttrEditor = new ConfigAttributeEditor();
-
- List<Role> roles = resource.getRoles();
- StringBuffer rolesList = new StringBuffer();
- for (Role role : roles){
- rolesList.append(role.getName());
- rolesList.append(",");
- }
-
- if (rolesList.length() > 0)
- rolesList.replace(rolesList.length()-1, rolesList.length()+1, "");
- configAttrEditor.setAsText(rolesList.toString());
- return (ConfigAttributeDefinition) configAttrEditor.getValue();
- }
- }
-
- public Collection getConfigAttributeDefinitions() {
- return null;
- }
-
- public boolean supports(Class arg0) {
- return true;
- }
-
- }
package org.security.SecureFilter;
import java.util.Collection;
import java.util.List;
import org.springframework.security.ConfigAttributeDefinition;
import org.springframework.security.ConfigAttributeEditor;
import org.springframework.security.intercept.web.FilterInvocation;
import org.springframework.security.intercept.web.FilterInvocationDefinitionSource;
public class MySecureResourceFilter implements FilterInvocationDefinitionSource {
public ConfigAttributeDefinition getAttributes(Object filter) throws IllegalArgumentException {
FilterInvocation filterInvocation = (FilterInvocation) filter;
String url = filterInvocation.getRequestUrl();
// create a resource object that represents this Url object
Resource resource = new Resource(url);
if (resource == null) return null;
else{
ConfigAttributeEditor configAttrEditor = new ConfigAttributeEditor();
// get the Roles that can access this Url
List<Role> roles = resource.getRoles();
StringBuffer rolesList = new StringBuffer();
for (Role role : roles){
rolesList.append(role.getName());
rolesList.append(",");
}
// don't want to end with a "," so remove the last ","
if (rolesList.length() > 0)
rolesList.replace(rolesList.length()-1, rolesList.length()+1, "");
configAttrEditor.setAsText(rolesList.toString());
return (ConfigAttributeDefinition) configAttrEditor.getValue();
}
}
public Collection getConfigAttributeDefinitions() {
return null;
}
public boolean supports(Class arg0) {
return true;
}
}
This getAttributes() method above essentially returns the name of Authorities (which I call Roles) that are allowed access to the current Url.
相关推荐
`z-pathway-acegi-spring-security.html`可能涉及Acegi安全系统的过渡信息,因为Spring Security最初是作为Acegi的后续项目发展起来的。这部分内容可能帮助那些从Acegi迁移到Spring Security的开发者理解两者之间的...
"Portable Pathway Builder Tool 2.0"版本在前一版本的基础上进行了优化升级,可能包括更丰富的图形库、增强的编辑功能、以及更好的兼容性。用户可以预设或自定义各种通路元素的形状、颜色和大小,以适应不同的展示...
IPA(Ingenuity Pathway Analysis)是一款在生物信息学领域广泛应用的通路分析工具,它专为研究人员提供了一整套分析方案,以理解基因表达数据、蛋白质组学数据或其他分子交互数据背后的生物学意义。这款软件的强大...
利用基因芯片分析TuMV侵染对白菜分泌途径基因的影响,李彦肖,张昌伟,前人研究发现病毒的复制复合体(viral RNP complex)和病毒RNA通过分泌途径移动到胞间连丝。本研究通过拟南芥基因芯片鉴定病原物侵染引�
软件名字叫做 pathway builder tool 官网是http: www proteinlounge com PathwayBuilder aspx(官网可以7天试用) 软件自带几乎所有分子生物学会用到的元素 如不同的细胞 细胞器 分子 老鼠模型 另外 这个软件自带...
标题“Notch1 signaling pathway”(Notch1信号通道)直接指出了本文研究的核心对象——Notch1信号通路。Notch信号通路是一种高度保守的细胞间通讯系统,在多种生物体中发挥着重要作用,特别是在发育过程中调控细胞...
from pathway2cyjs import Pathway2CyJS # 加载生物通路数据 pathway_data = ... # 创建转换器对象 converter = Pathway2CyJS() # 转换数据并获取JSON cyjs_json = converter.convert(pathway_data) # 将JSON...
这款软件基于Pathway/Genome Database (PGDB) 数据库,提供了丰富的生物信息分析功能,包括基因功能注释、通路分析、基因集富集分析以及差异表达基因的可视化。 PathwayTool的核心功能: 1. **通路分析**:...
《蛋白质网络与途径分析》(Protein Networks and Pathway Analysis)是分子生物学方法系列书籍中的一部,由尤里·尼科尔斯基(Yuri Nikolsky)和朱莉·布莱恩特(Julie Bryant)编辑,专注于蛋白质网络和生物途径的...
2. 视频无监督学习 视频无监督学习是指从视频数据中学习和检测前景对象的方法。这种方法可以检测单图像中的前景对象,从而实现对对象的识别和跟踪。视频无监督学习的优点在于可以检测到复杂场景中的前景对象,并且...
The AOX pathway is thought to act as a safety valve, preventing overreduction of the ETC and protecting cells from oxidative damage. 3. Mesophyll Protoplasts and Their Isolation Mesophyll ...
A histone methylation-dependent DNA methylation pathway is uniquely impaired by deficiency in S-adenosylhomocysteine hydrolase
Pathway是一款在DOS操作系统环境下使用的开发工具,它在80年代末至90年代初是程序员们进行软件开发的重要选择。标题中的“dos下的pathway开发包”指的是专为DOS系统设计的一套开发环境,它包含了编译器、链接器、...
2. **分析框架**:构建一个灵活的分析框架,能够处理多样化的Pathway数据。此框架应支持数据的深度挖掘,包括通路成员的识别、通路间的关系分析,以及基于通路的功能注释和预测。 3. **可视化工具**:设计直观的...
在Portable_Pathway_Builder_Tool_2.0这个压缩包文件中,很可能包含的是这款工艺流程绘图软件的便携版本。便携版软件的一大优点是无需安装,可以直接运行,不会在用户的电脑上留下任何痕迹,方便在不同设备间切换...
R. P. Burn的数论入门,非常好的一本数论指导书,影印版
convolution, spectral analysis and feature detection) and corresponds to the low level retinal image processing that happens in the eye in the human visual system pathway. The next part of the book ...