熱點推薦:
您现在的位置: 電腦知識網 >> 編程 >> Java編程 >> Java開源技術 >> 正文

淺談Acegi配置-Spring-Java[6]

2013-11-23 20:44:05  來源: Java開源技術 

  這樣當直接訪問http://localhost/AcegiWeb/servlet/TestServlet的時候會發現不可訪問控件台也不輸出javafish當輸入正確的用戶名和密碼之後便可以訪問

  這樣它就對類的方法調用起了保護的作用這一點可以把Acegi應用到DWR上效果是很理想的

  對於Acegi有很多的過濾器不用全寫在webxml裡acegi提供了一個特殊的過濾器我們可以寫成這樣在Webxml裡

<filter>
        <filtername>Acegi</filtername>
        <filterclass>orgacegisecurityutilFilterToBeanProxy</filterclass>
        <initparam>
            <paramname>targetClass</paramname>
            <paramvalue>orgacegisecurityutilFilterChainProxy</paramvalue>
        </initparam>
    </filter>
    <filtermapping>
        <filtername>Acegi</filtername>
        <urlpattern>/*</urlpattern>
    </filtermapping>
    <contextparam>
        <paramname>contextConfigLocation</paramname>
        <paramvalue>
            /WEBINF/applicationContextxml
        </paramvalue>
    </contextparam>
    <listener>
        <listenerclass>orgspringframeworkwebcontextContextLoaderListener</listenerclass>
    </listener>

    <listener>
        <listenerclass>orgspringframeworkwebutilLogjConfigListener</listenerclass>
    </listener>
    <listener>
        <listenerclass>orgacegisecurityuisessionHttpSessionEventPublisher</listenerclass>
    </listener>
  <servlet>
    <servletname>TestServlet</servletname>
    <servletclass>orgliservletTestServlet</servletclass>
  </servlet>

  <servletmapping>
    <servletname>TestServlet</servletname>
    <urlpattern>/servlet/TestServlet</urlpattern>
  </servletmapping>

  在Spring的配置文件裡

<bean id=chainProxy class=orgacegisecurityutilFilterChainProxy>
        <property name=filterInvocationDefinitionSource>
            <value>
                CONVERT_URL_TO_LOWERCASE_BEFORE_COMPARISON
            PATTERN_TYPE_APACHE_ANT
           

/**=HttpSessionContextIntegrationFilterauthenticationProcessingFilterBasicProcessingFilteranonymousProcessingFilt

erexceptionTranslationFilterfilterSecurityInterceptor
            </value>
        </property>
    </bean>

[]  []  []  []  []  []  


From:http://tw.wingwit.com/Article/program/Java/ky/201311/28992.html
    推薦文章
    Copyright © 2005-2013 電腦知識網 Computer Knowledge   All rights reserved.