使用acegi在业务逻辑层获得Web层的用户ID

〈property name="driverClass"〉
〈value〉com.mysql.jdbc.Driver〈/value〉
〈/property〉
〈property name="jdbcUrl"〉
〈value〉jdbc:mysql://localhost:3308/acegidb〈/value〉
〈/property〉
〈property name="user"〉
〈value〉root〈/value〉
〈/property〉
〈property name="password"〉
〈value〉mysql〈/value〉
〈/property〉
〈property name="initialPoolSize"〉
〈value〉10〈/value〉
〈/property〉
〈property name="minPoolSize"〉
〈value〉10〈/value〉
〈/property〉
〈property name="maxPoolSize"〉
〈value〉50〈/value〉
〈/property〉
〈property name="checkoutTimeout"〉
〈value〉50000〈/value〉
〈/property〉
〈property name="maxIdleTime"〉
〈value〉1800〈/value〉
〈/property〉
〈property name="idleConnectionTestPeriod"〉
〈value〉3000〈/value〉
〈/property〉
〈property name="acquireIncrement"〉
〈value〉5〈/value〉
〈/property〉
〈/bean〉

〈bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager"〉
〈property name="dataSource"〉
〈ref local="dataSource"/〉
〈/property〉
〈/bean〉

〈bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate"〉
〈property name="dataSource"〉
〈ref bean="dataSource"/〉
〈/property〉
〈/bean〉

〈bean id="businessAccessDecisionManager" class="org.acegisecurity.vote.AffirmativeBased"〉
〈property name="allowIfAllAbstainDecisions"〉〈value〉false〈/value〉〈/property〉
〈property name="decisionVoters"〉
〈list〉
〈ref bean="roleVoter"/〉
〈/list〉
〈/property〉
〈/bean〉

〈bean id="customEditorConfigurer" class="org.springframework.beans.factory.config.CustomEditorConfigurer"〉
〈property name="customEditors"〉
〈map〉
〈entry key="org.acegisecurity.intercept.method.MethodDefinitionSource"〉
〈bean class="com.mysoft.pmi.security.DataSourceMethodDefinitionSourceEditor"〉
〈property name="jdbcTemplate"〉 〈ref bean="jdbcTemplate"/〉 〈/property〉
〈/bean〉
〈/entry〉
〈/map〉
〈/property〉
〈/bean〉

〈bean id="transactionInterceptor" class="org.springframework.transaction.interceptor.TransactionInterceptor"〉
〈property name="transactionManager"〉〈ref bean="transactionManager"/〉〈/property〉
〈property name="transactionAttributeSource"〉
〈value〉
com.mysoft.pmi.testcase.aop.TestAOPInterfaceImpl.*=PROPAGATION_REQUIRED
〈/value〉
〈/property〉
〈/bean〉
〈bean id="contactManagerTarget" class="com.mysoft.pmi.testcase.aop.TestAOPInterfaceImpl" /〉
〈bean id="contactManagerSecurity" class="org.acegisecurity.intercept.method.aopalliance.MethodSecurityInterceptor"〉
〈property name="authenticationManager"〉〈ref bean="authenticationManager"/〉〈/property〉
〈property name="accessDecisionManager"〉〈ref bean="businessAccessDecisionManager"/〉〈/property〉
〈property name="objectDefinitionSource"〉
〈value〉
select authority,PROTECTED_RES from authorities where AUTH_TYPE='FUNCTION' and authority like 'AUTH_FUNC_ContactManager%'
〈/value〉
〈/property〉
〈/bean〉

〈bean id="contactManager" class="org.springframework.aop.framework.ProxyFactoryBean"〉
〈property name="proxyInterfaces"〉

〈value〉com.mysoft.pmi.testcase.aop.TestAOPInterface〈/value〉
〈/property〉
〈property name="interceptorNames"〉
〈list〉
〈idref local="transactionInterceptor"/〉
〈idref local="contactManagerSecurity"/〉
〈idref local="contactManagerTarget"/〉
〈/list〉
〈/property〉
〈/bean〉


〈/beans〉

说明:请根据自己机器的配置更改数据库连接地址、端口、数据库名、口令配置参数。com.mysoft.pmi.testcase.aop.TestAOPInterface接口是一个业务逻辑层接口,本例com.mysoft.pmi.testcase.aop.TestAOPInterfaceImpl是此接口的实现类,提供了两个非常简单的接口方法:test和testAAA。
另外注意使用“一餐三碗”的数据库导入表结构和数据后,需要修改authorities表PROTECTED_RES的值,因为本例使用的接口为com.mysoft.pmi.testcase.aop.TestAOPInterface,如果此字段使用了不存在的接口和方法,在应用服务器启动时会报错,所以请将此字段的内容改为:com.mysoft.pmi.testcase.aop.TestAOPInterface.test或com.mysoft.pmi.testcase.aop.TestAOPInterface.testAAA,如果大家有兴趣可以在此接口下多加几个方法。

5、WEB-INF\classes下的applicationContext-acegi-security.xml文件:

〈?xml version="1.0" encoding="UTF-8"?〉
〈!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd"〉

〈beans〉

〈bean id="filterChainProxy" class="org.acegisecurity.util.FilterChainProxy"〉
〈property name="filterInvocationDefinitionSource"〉
〈value〉
CONVERT_URL_TO_LOWERCASE_BEFORE_COMPARISON
PATTERN_TYPE_APACHE_ANT
/**=httpSessionContextIntegrationFilter,authenticationProcessingFilter,securityContextHolderAwareRequestFilter,anonymousProcessingFilter,exceptionTranslationFilter,filterInvocationInterceptor
〈/value〉
〈/property〉
〈/bean〉

〈bean id="httpSessionContextIntegrationFilter" class="org.acegisecurity.context.HttpSessionContextIntegrationFilter"/〉

〈bean id="authenticationProcessingFilter" class="org.acegisecurity.ui.webapp.AuthenticationProcessingFilter"〉

共6页 首页 上一页 [1] [2] [3] [4] [5下一页 尾页>
字母检索 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z