这厮

observing

  BlogJava :: 首页 :: 联系 :: 聚合  :: 管理
  48 Posts :: 3 Stories :: 3 Comments :: 0 Trackbacks
web.xml


<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns
="http://java.sun.com/xml/ns/javaee"
        xmlns:web
="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
    xsi:schemaLocation
="http://java.sun.com/xml/ns/javaee
        http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"

    id
="WebApp_ID" version="2.5">

    <display-name>JSFSpringNoSecurityWebApp</display-name>

    <!-- Spring configuration file location -->
    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>
            /WEB-INF/applicationContext-business.xml
            /WEB-INF/applicationContext-security.xml
        </param-value>
    </context-param>


    <!-- Let Spring handle all requests coming to the web application through this filter. -->
    <filter>
        <filter-name>springSecurityFilterChain</filter-name>
        <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
    </filter>

 
    <!-- All the requests to be handled by the above filter -->
    <filter-mapping>
      <filter-name>springSecurityFilterChain</filter-name>
      <url-pattern>/*</url-pattern>
    </filter-mapping>


    <!-- To start/stop Spring framework automatically. -->
    <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>

    <welcome-file-list>
        <welcome-file>index.html</welcome-file>
        <welcome-file>index.htm</welcome-file>
        <welcome-file>index.jsp</welcome-file>
        <welcome-file>default.html</welcome-file>
        <welcome-file>default.htm</welcome-file>
        <welcome-file>default.jsp</welcome-file>
    </welcome-file-list>

    <servlet>
        <servlet-name>Faces Servlet</servlet-name>
        <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
        <servlet-name>Faces Servlet</servlet-name>
        <url-pattern>/faces/*</url-pattern>
    </servlet-mapping>
</web-app>


newly added applicationContext-security.xml  
<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns="http://www.springframework.org/schema/security"
    xmlns:xsi
="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:beans
="http://www.springframework.org/schema/beans"
    xsi:schemaLocation
="http://www.springframework.org/schema/beans
        http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
        http://www.springframework.org/schema/security
        http://www.springframework.org/schema/security/spring-security-3.0.xsd"
>
    

    <!-- Method based security -->
    <global-method-security>
        <protect-pointcut access="ROLE_SPECIAL_USER"
          expression
="execution(* org.swview.springsecuritytestapp.logic.Calculator.add(..))"/>
        <protect-pointcut access="ROLE_GENERAL_USER"
          expression
="execution(* org.swview.springsecuritytestapp.logic.Calculator.subtract(..))"/>
    </global-method-security>
    

    <!-- URL pattern based security -->
    <http auto-config="true">
        <intercept-url pattern="/**" access="ROLE_GENERAL_USER, ROLE_SPECIAL_USER" />
    </http>


    <!--
    Usernames/Passwords are
        kamal/swview
        test/spring
    
-->
    <authentication-manager>
        <authentication-provider>
            <password-encoder hash="md5"/>
            <user-service>
                <user name="kamal"
                   password
="65dc70650690999922d7dcd99dbd4033" authorities="ROLE_SPECIAL_USER" />
                <user name="test"
                   password
="2a2d595e6ed9a0b24f027f2b63b134d6" authorities="ROLE_GENERAL_USER" />
            </user-service>
        </authentication-provider>
    </authentication-manager>

</beans:beans>




other files remain the same...








        
posted on 2011-12-26 12:44 cnbarry 阅读(268) 评论(0)  编辑  收藏 所属分类: Java

只有注册用户登录后才能发表评论。


网站导航: