123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140 |
- <?xml version="1.0" encoding="UTF-8"?>
- <beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns:security="http://www.springframework.org/schema/security"
- xsi:schemaLocation="
- http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
- http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.1.xsd">
-
- <!-- 该路径下的资源不用过滤 -->
- <security:http pattern="/css/**" security="none"/>
- <security:http pattern="/qui/**" security="none"/>
- <security:http pattern="/js/**" security="none"/>
- <security:http pattern="/ckeditor/**" security="none"/>
- <security:http pattern="/image/**" security="none"/>
- <security:http pattern="/images/**" security="none"/>
- <security:http pattern="/login.jsp" security="none"/>
- <security:http pattern="/WEB-INF/view/aah/content.jsp" security="none"/>
- <security:http pattern="/jatoolsPrinter.cab" security="none"/>
- <security:http pattern="/upload/*.xls" security="none"/>
- <security:http pattern="/install_lodop32.exe" security="none"/>
- <security:http pattern="/install_lodop64.exe" security="none"/>
- <security:http pattern="/minicolors/**" security="none"/>
- <security:http pattern="/pic/**" security="none"/>
- <security:http pattern="/WEB-INF/view/wx/**" security="none"/>
-
- <!-- 自动配置模式,拦截所有请求进行匹配,有ROLE_USER才可以通过 -->
- <security:http auto-config="true" use-expressions="true">
-
- <!--使用表单登录-->
- <!--
- login-page:指定登录页面。
- login-processing-url:指定了客户在登录页面中按下 Sign In 按钮时要访问的 URL。
- authentication-failure-url:指定了身份验证失败时跳转到的页面。
- default-target-url:指定了成功进行身份验证和授权后默认呈现给用户的页面。
- always-use-default-target:指定了是否在身份验证通过后总是跳转到default-target-url属性指定的URL。
- -->
- <security:form-login login-page="/login.jsp" always-use-default-target="false" />
- <!--注销用户
- logout-url:指定了用于响应退出系统请求的URL。
- logout-success-url:退出系统后转向的URL。
- invalidate-session:指定在退出系统时是否要销毁Session。
- -->
- <security:logout invalidate-session="true" logout-url="/logout.do" logout-success-url="/login.jsp"/>
- <!-- 实现免登陆验证 -->
- <security:remember-me />
- <!-- 增加一个自定义的filter,放在FILTER_SECURITY_INTERCEPTOR之前, 实现用户、角色、权限、资源的数据库管理。 -->
- <security:custom-filter before="FILTER_SECURITY_INTERCEPTOR" ref="permissionFilter" />
- <!--尝试访问没有权限的页面时跳转的页面 ,accessDeniedHandler会接管操作,并转向/403.jsp页面-->
- <security:access-denied-handler ref="accessDeniedHandler"/>
- </security:http>
-
- <bean id="accessDeniedHandler" class="com.core.web.security.AccessDeniedHandlerImpl">
- <property name="accessDeniedUrl" value="/403.jsp"></property>
- </bean>
-
- <!-- 一个自定义的filter,必须包含authenticationManager,accessDecisionManager, 三个属性,我们的所有控制将在这三个类中实现 -->
- <bean id="permissionFilter" class="com.core.web.security.PermissionFilter">
- <!-- 用户拥有的权限 -->
- <property name="authenticationManager" ref="authenticationManager" />
- <!-- 访问决策器,决定某个用户具有的角色,是否有足够的权限去访问某个资源 -->
- <property name="accessDecisionManager" ref="accessDecisionManager" />
- <!-- 资源与权限对应关系 -->
- <property name="securityMetadataSource" ref="securityMetadataSource" />
- </bean>
-
- <!-- 认证管理器,实现用户认证的入口,主要实现UserDetailsService接口即可 -->
- <security:authentication-manager alias="authenticationManager" >
- <security:authentication-provider user-service-ref="userDetailsManager">
- <!-- 密码采用md5加密方式加密 -->
- <security:password-encoder base64="false" ref="passwordEncoder">
- <!-- 用username做盐值加密,防止md5字典攻击 -->
- <security:salt-source user-property="userName"/>
- </security:password-encoder>
- </security:authentication-provider>
- </security:authentication-manager>
-
- <!-- 访问决策器,决定某个用户具有的角色,是否有足够的权限去访问某个资源 -->
- <bean id="accessDecisionManager" class="com.core.web.security.AccessDecisionManagerImpl"/>
-
- <!-- 资源源数据定义,即定义某一资源可以被哪些角色访问 -->
- <bean id="securityMetadataSource" class="com.core.web.security.SecurityMetadataSourceImpl" scope="singleton">
- <constructor-arg index="0" ref="popResourceService"/>
- <!--设置不需要登陆就可以访问-->
- <property name="anonymousUrls">
- <set>
- <value>/login.do</value>
- <value>/logout.do </value>
- <value>/register/view.do</value>
- <value>/wx/View.do</value>
- <value>/wx/wxview.do</value>
- <value>/wx/wxxquery.do</value>
- <value>/wx/wxQuery.do</value>
- <value>/wx/wxYearQuery.do</value>
- <value>/wx/wxYearShow.do</value>
- <value>/wx/viewYearWaterPlan.do</value>
- <value>/wx/viewYearUnitNotice.do</value>
- <value>/wx/wxCreate.do</value>
- <value>/wx/binding.do</value>
- <value>/wx/index.do</value>
- <value>/wx/outOfPlan.do</value>
- <value>/wx/binding2.do</value>
- <value>/wx/bindInfo.do</value>
- <value>/wx/claim.do</value>
- <value>/wx/booking.do</value>
- <value>/register/checkUserName.do</value>
- <value>/register/checkOrgName.do</value>
- <value>/register/checkOrgCode.do</value>
- <value>/register/getValidCode.do</value>
- <value>/register/registerSubmit.do</value>
- <value>/org/validateOrgCode.do</value>
- <value>/org/validateOrgName.do</value>
- <value>/user/validateUserName.do</value>
- <!-- <value>/notices/listNoticesShow.do</value> -->
- <!-- <value>/notices/view.do</value> -->
- <!-- <value>/notices/downloadFile.do</value> -->
- <value>/wx/outOfPlan.do</value>
- <value>/wx/outOfPlanSearch.do</value>
- <value>/templateExport/templateExport.do</value>
- <!--
-
- <value>/test/uploadData.do</value>
- <value>/test/uploadPage.do</value>
- <value>/test/formData.do</value>
- -->
-
- </set>
- </property>
- <!--每个用户登陆后才可以访问的公共资源(如何后台框架),不需要通过角色来分配权限才能看到-->
- <property name="publicUrls">
- <set>
- <value>/frame/main.do</value>
- <value>/frame/left.do</value>
- <value>/frame/open.do</value>
- </set>
- </property>
- </bean>
-
- <!-- 用户的密码加密或解密 -->
- <bean id="passwordEncoder" class="org.springframework.security.authentication.encoding.Md5PasswordEncoder"/>
- </beans>
|