Spring Security的解析处理器的载入
来源:互联网 发布:手绘动画制作软件 编辑:程序博客网 时间:2024/05/29 15:31
Spring Security通过在spring配置文件中引入SpringSecurity的命名空间,应用启动之后会载入SpringSecurity的命名空间对应的命名空间处理器进行初始化载入解析器的操作。
其对应的命名空间处理器是org.springframework.security.config.SecurityNamespaceHandler。
其载入解析器的方法是
private void loadParsers() { // Parsers parsers.put(Elements.LDAP_PROVIDER, new LdapProviderBeanDefinitionParser()); parsers.put(Elements.LDAP_SERVER, new LdapServerBeanDefinitionParser()); parsers.put(Elements.LDAP_USER_SERVICE, new LdapUserServiceBeanDefinitionParser()); parsers.put(Elements.USER_SERVICE, new UserServiceBeanDefinitionParser()); parsers.put(Elements.JDBC_USER_SERVICE, new JdbcUserServiceBeanDefinitionParser()); parsers.put(Elements.AUTHENTICATION_PROVIDER, new AuthenticationProviderBeanDefinitionParser()); parsers.put(Elements.GLOBAL_METHOD_SECURITY, new GlobalMethodSecurityBeanDefinitionParser()); parsers.put(Elements.AUTHENTICATION_MANAGER, new AuthenticationManagerBeanDefinitionParser()); parsers.put(Elements.METHOD_SECURITY_METADATA_SOURCE, new MethodSecurityMetadataSourceBeanDefinitionParser()); // Only load the web-namespace parsers if the web classes are available if(ClassUtils.isPresent(FILTER_CHAIN_PROXY_CLASSNAME, getClass().getClassLoader())) { parsers.put(Elements.DEBUG, new DebugBeanDefinitionParser()); parsers.put(Elements.HTTP, new HttpSecurityBeanDefinitionParser()); parsers.put(Elements.HTTP_FIREWALL, new HttpFirewallBeanDefinitionParser()); parsers.put(Elements.FILTER_INVOCATION_DEFINITION_SOURCE, new FilterInvocationSecurityMetadataSourceParser()); parsers.put(Elements.FILTER_SECURITY_METADATA_SOURCE, new FilterInvocationSecurityMetadataSourceParser()); parsers.put(Elements.FILTER_CHAIN, new FilterChainBeanDefinitionParser()); filterChainMapBDD = new FilterChainMapBeanDefinitionDecorator(); } }解析器的方法的入口
public BeanDefinition parse(Element element, ParserContext pc) { if (!namespaceMatchesVersion(element)) { pc.getReaderContext().fatal("You cannot use a spring-security-2.0.xsd or spring-security-3.0.xsd schema " + "with Spring Security 3.1. Please update your schema declarations to the 3.1 schema.", element); } //获得xml元素的名称 String name = pc.getDelegate().getLocalName(element); //通过名称获得对应的解析器 BeanDefinitionParser parser = parsers.get(name); if (parser == null) { // SEC-1455. Load parsers when required, not just on init(). loadParsers(); } if (parser == null) { if (Elements.HTTP.equals(name) || Elements.FILTER_SECURITY_METADATA_SOURCE.equals(name) || Elements.FILTER_CHAIN_MAP.equals(name) || Elements.FILTER_CHAIN.equals(name)) { reportMissingWebClasses(name, pc, element); } else { reportUnsupportedNodeType(name, pc, element); } return null; } //正式解析xml节点元素,一般配置http元素,之后会进行过滤器代理的实例化以及过滤器链的初始化注入到过滤器代理中 return parser.parse(element, pc); }
阅读全文
0 0
- Spring Security的解析处理器的载入
- 基于注解的Spring Security原理解析
- Spring Security处理器
- Spring源码浅析 -- XML配置文件的载入与解析
- Spring源码浅析 -- XML配置文件的载入与解析
- Spring的两种后处理器
- Spring 的两种后处理器
- 载入Spring配置文件的方式
- Spring Security的配置
- spring security的缓存
- Spring Security的使用
- Spring Security的见解
- spring security的使用
- spring security的配置
- 6-spring源码3.2.18解读+spring技术内幕(关于BeanDefinition的载入和解析)
- 初识Spring security-无Security的SpringMVC
- 初识Spring security-无Security的SpringMVC
- 初识Spring security-无Security的SpringMVC
- Linux系统 /目录下的各文件作用
- 泥塑课
- jsp简单导出word,不使用poi
- 卷积神经网络工程实践技巧
- 上传exel表格 以及处理的方式
- Spring Security的解析处理器的载入
- QT QML初体验随笔之QQuickView(8)
- OutOfMemoryError和StackOverflowError异常demo
- 离散题目13
- POJ:1459 Power Network
- Android判断前后台状态
- selenium+Java自学辛酸史
- 路由
- 判断IE各版本浏览器的最直接有效的方式