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 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器