0 0

acegi拦截方法怎么配置5

请问acegi方法拦截怎么配置啊?
2008年8月15日 12:08

1个答案 按时间排序 按投票排序

0 0

采纳的答案

<?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: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" />

</beans>

其中,users.properties中的内容为
alice=123,ROLE_HEAD_OF_ENGINEERING


如果用数据库中的用户登陆可以选择
<property name="userDetailsService" ref="tuserDao" />

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

2008年8月15日 13:30

相关推荐

    acegi

    - **授权(Authorization)**:Acegi 提供细粒度的权限控制,允许开发者根据角色、URL路径、方法参数等进行权限配置,实现不同级别的访问控制。 - **会话管理(Session Management)**: Acegi 可以监控和管理用户...

    CAS及客户端Acegi的安装配置指南

    2. 修改Spring配置文件,引入Acegi的安全拦截器(如)。 3. 配置Acegi的DaoAuthenticationProvider,使其与CAS服务器进行交互。这可能需要在Acegi的配置文件中添加如下的bean定义: ```xml ...

    acegi实例,acegi详细配置和代码实现

    3. **Controller/Service中的Security Annotation**:在控制器或服务方法上使用Acegi Security的注解(如`@Secured`)来声明访问控制。 在`acegiTest`目录下,可能包含了一些测试用例,用于验证配置和实现是否正确...

    Acegi 详细配置说明

    在本文中,我们将深入探讨Acegi的详细配置,并通过实际示例来理解其工作原理。 首先,我们要明白Acegi的核心功能是提供身份验证(Authentication)和授权(Authorization)服务。身份验证是确认用户的身份,而授权...

    Acegi 数据库配置安全策略 源代码及图解

    Acegi 安全框架是Spring生态中的一个早期的安全组件,它提供了一套强大的基于数据库的配置来实现应用程序的安全策略。本资源由王政创作并分享,主要涉及如何将XML配置转换为数据库动态配置,这对于那些需要灵活管理...

    Acegi框架介绍 acegi安全与认证

    同时,它通过Spring AOP在方法级别进行拦截,阻止未经授权的访问。对于领域对象的访问,Acegi会在执行Bean方法前检查访问控制列表(ACL),确保用户有权操作该对象。 5. **体系结构** Acegi的核心组件包括...

    acegi保护业务方法_basedDatabase

    总的来说,"acegi保护业务方法_basedDatabase"涉及到的关键技术点包括Acegi Security的配置、用户角色权限模型的设计、数据库交互以及安全策略的实现。通过这一系列步骤,我们可以实现一个基于数据库的动态权限控制...

    spring acegi 详细文档

    在本文中,我们将深入探讨Spring Acegi的核心概念、功能和使用方法。 首先,Acegi的主要目标是保护Spring应用免受非法访问,它提供了丰富的功能来实现用户认证、会话管理、权限控制以及安全相关的异常处理。Acegi的...

    基于java的ACEGI

    过滤器链可以根据配置拦截请求,进行身份验证和授权检查。 在《实战Acegi:使用Acegi作为基于Spring框架的WEB应用的安全框架.pdf》中,可能会详细讲解如何配置和使用Acegi。以下是一些关键步骤: 1. **添加依赖**...

    spring acegi 使用工程demo

    5. **AcegiExample**:这可能是项目的主要代码或配置文件,包含Acegi的配置示例,例如自定义的`AuthenticationProvider`实现,或者展示了如何定义访问控制策略的XML配置。 6. **jar.GIF 和 result.GIF**:这些可能...

    权限Acegi的使用

    3. **安全拦截**:Acegi利用Spring的AOP框架来实现对方法调用和URL访问的拦截。你可以定义安全拦截规则,例如,只有特定角色的用户才能访问某个方法或页面。 4. **角色与权限**:在Acegi中,用户可以被分配多个角色...

    acegi保护业务方法_basedMemory

    Acegi Security通过拦截器模式工作,它会在每个请求到达目标方法之前进行拦截,检查用户是否具有执行该方法所需的权限。它提供了诸如Authentication(认证)和Authorization(授权)等核心组件,以及RememberMe服务...

    acegi安全策略与CAS整合

    这涉及设置安全拦截器、配置CasAuthenticationProvider,以及调整AceGI的其他安全相关设置。 4. 实战步骤: 文档接下来的部分将详细描述每一个配置步骤,包括XML配置文件的修改,代码的编写,以及可能遇到的问题和...

    Acegi学习笔记(JAVA系统安全编程时用到)

    在 `web.xml` 中,你需要定义一个名为 `Acegi Filter Chain Proxy` 的过滤器,并将其映射到所有 URL,以便拦截并处理每个请求。过滤器类使用 `FilterToBeanProxy` 创建 `FilterChainProxy` 的实例,`...

    使用acegi控制用户权限实例

    - Acegi拦截请求,检查请求中是否包含有效的身份凭证,如用户名和密码。 - 身份验证提供者(如`AuthenticationProvider`)对凭证进行验证,例如通过查询数据库确认用户名和密码的正确性。 - 如果验证成功,Acegi...

    Spring Acegi权限控制

    1. **安全拦截器(Security Interceptor)**:这是Acegi的核心组件,它根据配置的规则对请求进行拦截,决定是否允许访问。 2. **认证管理器(Authentication Manager)**:负责处理用户的认证请求,通常会集成多种...

    基于rbac模式的acegi权限管理

    通过配置Acegi的拦截器,我们可以控制哪些请求需要进行权限检查,以及如何进行检查。 在"权限管理组件在Spring框架下的设计与实现.nh"这个文件中,可能包含了关于如何配置Acegi Security、定义角色和权限、以及如何...

Global site tag (gtag.js) - Google Analytics