iteye_20052 2008-08-15 12:08
浏览 277
已采纳

acegi拦截方法怎么配置

请问acegi方法拦截怎么配置啊?

  • 写回答

1条回答 默认 最新

  • piccbj 2008-08-15 13:30
    关注

    [code="java"]
    <?xml version="1.0" encoding="UTF-8"?>
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:aop="http://www.springframework.org/schema/aop"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
    http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd">

    <!-- ========================= Filter Chain ============================ -->
    <bean id="filterChainProxy" class="org.acegisecurity.util.FilterChainProxy">
        <property name="filterInvocationDefinitionSource">
            <value>
                CONVERT_URL_TO_LOWERCASE_BEFORE_COMPARISON
                PATTERN_TYPE_APACHE_ANT
                /**=httpSessionContextIntegrationFilter,logoutFilter,authenticationProcessingFilter,securityContextHolderAwareRequestFilter,anonymousProcessingFilter,exceptionTranslationFilter,filterInvocationInterceptor
            </value>
        </property>
    </bean>
    
    <!-- Access authentication object -->
    <bean id="httpSessionContextIntegrationFilter"
        class="org.acegisecurity.context.HttpSessionContextIntegrationFilter" />
    
    <!-- Clear after logout -->
    <bean id="logoutFilter"
        class="org.acegisecurity.ui.logout.LogoutFilter">
        <constructor-arg value="/logoutSuccess.jsp" />  <!-- logout success to redirecte to -->
        <constructor-arg>
            <list>
                <bean class="org.acegisecurity.ui.logout.SecurityContextLogoutHandler" />
            </list>
        </constructor-arg>
    </bean>
    
    <!-- Process authentication request -->
    <bean id="authenticationProcessingFilter"
        class="org.acegisecurity.ui.webapp.AuthenticationProcessingFilter">
        <property name="authenticationManager" ref="authenticationManager" />
        <property name="authenticationFailureUrl" value="/login.jsp?login_error=1" /> <!-- login failure to redirected to -->
        <property name="defaultTargetUrl" value="/protected/protected1.jsp" /> <!-- login success to redirecte to -->
        <property name="filterProcessesUrl" value="/j_security_check" /> <!-- login request action -->
    </bean>
    
    <!-- Decorate HttpServletRequest which container request parameters,header,Date,cookies etc. -->
    <bean id="securityContextHolderAwareRequestFilter"
        class="org.acegisecurity.wrapper.SecurityContextHolderAwareRequestFilter" />
    
    <!-- Configure anonymous user and authentication -->
    <bean id="anonymousProcessingFilter"
        class="org.acegisecurity.providers.anonymous.AnonymousProcessingFilter">
        <property name="key" value="anonymous" />
        <property name="userAttribute" value="anonymous,ROLE_ANONYMOUS" />
    </bean>
    
    <!-- Configure the map relation of exception & URL -->
    <bean id="exceptionTranslationFilter"
        class="org.acegisecurity.ui.ExceptionTranslationFilter">
        <property name="authenticationEntryPoint">
            <bean
                class="org.acegisecurity.ui.webapp.AuthenticationProcessingFilterEntryPoint">
                <property name="loginFormUrl" value="/login.jsp" />
            </bean>
        </property>
        <property name="accessDeniedHandler">
            <bean
                class="org.acegisecurity.ui.AccessDeniedHandlerImpl">
                <property name="errorPage" value="/accessDenied.jsp" />
            </bean>
        </property>
    </bean>
    
    <!-- Configure the map relation of the URL & Role -->
    <bean id="filterInvocationInterceptor"
        class="org.acegisecurity.intercept.web.FilterSecurityInterceptor">
        <property name="authenticationManager" ref="authenticationManager" />
        <property name="accessDecisionManager" ref="accessDecisionManager" />
        <property name="objectDefinitionSource">
            <value>
                CONVERT_URL_TO_LOWERCASE_BEFORE_COMPARISON
                PATTERN_TYPE_APACHE_ANT 
                /protected/**=ROLE_HEAD_OF_ENGINEERING
                /**=IS_AUTHENTICATED_ANONYMOUSLY
            </value>
        </property>
    </bean>
    
    <!-- Authentication manager -->
    <bean id="authenticationManager"
        class="org.acegisecurity.providers.ProviderManager">
        <property name="providers">
            <list>
                <ref local="daoAuthenticationProvider" />
            </list>
        </property>
    </bean>
    
    <!-- Access decision vote manager -->
    <bean id="accessDecisionManager" class="org.acegisecurity.vote.AffirmativeBased">
        <property name="allowIfAllAbstainDecisions"
                value="false" />
            <property name="decisionVoters">
                <list>
                    <bean class="org.acegisecurity.vote.RoleVoter" />
                    <bean class="org.acegisecurity.vote.AuthenticatedVoter" />
                </list>
            </property>
    </bean>
    
    <!-- DAO authentication provider which get the user's information from database -->
    <bean id="daoAuthenticationProvider"
        class="org.acegisecurity.providers.dao.DaoAuthenticationProvider">
        <property name="userDetailsService" ref="userDetailsService" />
        <!--property name="userDetailsService" ref="tuserDao" /-->
        <!-- UserCache property will activate the cache, it is not 
        mandatory but increases performance by cacheing the user 
        details retrieved from user-base -->
        <property name="userCache" ref="userCache"/>
    </bean>
    
    <!-- Access user's username and password -->
    <bean id="userDetailsService" class="org.acegisecurity.userdetails.memory.InMemoryDaoImpl">
        <property name="userProperties">
            <bean class="org.springframework.beans.factory.config.PropertiesFactoryBean">
                <property name="location" value="/WEB-INF/users.properties" />
            </bean>
        </property>
    </bean>
    
    <!-- Cache user's information -->
    <bean id="userCache" class="org.acegisecurity.providers.dao.cache.EhCacheBasedUserCache">
                <property name="cache">
                    <bean
                        class="org.springframework.cache.ehcache.EhCacheFactoryBean">
                        <property name="cacheManager">
                            <bean
                                class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean" />
                        </property>
                        <property name="cacheName" value="userCache" />
                    </bean>
                </property>
    </bean>
    
    <!-- This bean is optional; it isn't used by any other bean as it only listens and logs -->
    <bean id="loggerListener" class="org.acegisecurity.event.authentication.LoggerListener" />
    


    [/code]
    其中,users.properties中的内容为
    [code="java"]
    alice=123,ROLE_HEAD_OF_ENGINEERING
    [/code]

    如果用数据库中的用户登陆可以选择
    [code="java"]

    [/code]
    已经给配置好了,你可以根据自己的要求修改。

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 android报错 brut.common.BrutException: could not exec (exit code = 1)
  • ¥15 nginx反向代理获取ip,java获取真实ip
  • ¥15 eda:门禁系统设计
  • ¥50 如何使用js去调用vscode-js-debugger的方法去调试网页
  • ¥15 376.1电表主站通信协议下发指令全被否认问题
  • ¥15 物体双站RCS和其组成阵列后的双站RCS关系验证
  • ¥15 复杂网络,变滞后传递熵,FDA
  • ¥20 csv格式数据集预处理及模型选择
  • ¥15 部分网页页面无法显示!
  • ¥15 怎样解决power bi 中设置管理聚合,详细信息表和详细信息列显示灰色,而不能选择相应的内容呢?