这是负责鉴权的Filter,典型的配置如下:
<bean id="filterSecurityInterceptor"
class="org.springframework.security.web.access.intercept.FilterSecurityInterceptor">
<property name="authenticationManager" ref="authenticationManager"/>
<property name="accessDecisionManager" ref="accessDecisionManager"/>
<property name="securityMetadataSource">
<security:filter-security-metadata-source>
<security:intercept-url pattern="/secure/super/**" access="ROLE_WE_DONT_HAVE"/>
<security:intercept-url pattern="/secure/**" access="ROLE_SUPERVISOR,ROLE_TELLER"/>
</security:filter-security-metadata-source>
</property>
</bean>
这样只有安全属性才被加密,而且任何管理员都可使用该导出文件来导入配置配置。当我们当问某个属性时,compoundrootaccessor对象实例会负责在compoundroot对象中找到包含我们指定属性的对象一般情况下我们只会接触到ognl的一小部分功能,所以我们就主要学习一下我们可能会用到的知识点,如果要更加深入的学习ognl,那么可以去看一下ognl的官方文档,上面有非常详细的介绍。
这样做可适用的一个业务场景就是:如在某游戏系统中可以通过配置将会员信息缓存到分布式部署的memcache缓存中,而将会员后台界面中的权限菜单缓存在本地ehcache缓存或者干脆放到基于map的内置缓存中(会员只能在同一个服务器登录,因此比如权限菜单之类的数据没必要缓存到分布式缓存容器中)。异常详细信息: system.security.securityexception: 请求“system.web.aspnethostingpermission, system, version=2.0.0.0, culture=neutral, publickeytoken=b77a5c561934e089”类型的权限已失败。ps:如果已经设置了登录密码,则会出现如下图所示的界面,请直接输入之前设置的管理员密码登录。
<bean id="exceptionTranslationFilter"
class="org.springframework.security.web.access.ExceptionTranslationFilter">
<property name="authenticationEntryPoint" ref="authenticationEntryPoint"/>
<property name="accessDeniedHandler" ref="accessDeniedHandler"/>
</bean>
<bean id="authenticationEntryPoint"
class="org.springframework.security.web.authentication.LoginUrlAuthenticationEntryPoint">
<property name="loginFormUrl" value="/login.jsp"/>
</bean>
<bean id="accessDeniedHandler"
class="org.springframework.security.web.access.AccessDeniedHandlerImpl">
<property name="errorPage" value="/accessDenied.htm"/>
</bean>
本文来自电脑杂谈,转载请注明本文网址:
https://www.pc-fly.com/a/ruanjian/article-93148-7.html
老巴可比你富哦