Announcement Announcement Module
Collapse
No announcement yet.
why my MethodSecurityInterceptor can't work? please. Page Title Module
Move Remove Collapse
This topic is closed
X
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • why my MethodSecurityInterceptor can't work? please.


    Can use Acegi to forbit a method execute ?

    I want that user without ROLE_METHOD_NOJTA can't save data, but the bean dualServiceWithoutJTA can still save data to database although it show in console "Access is denied".

    if I proxy bean "dualServiceBean" , it works well .

    my applicationContext-acegi-security.xml file is mostly same as the demo, I only change the bean "jdbcDao"


    Code:
    	<bean id="JtaMethodSecurityInterceptor"
    		class="org.acegisecurity.intercept.method.aopalliance.MethodSecurityInterceptor">
    		<property name="authenticationManager">
    			<ref bean="authenticationManager" />
    		</property>
    		<property name="accessDecisionManager">
    			<ref bean="httpRequestAccessDecisionManager" />
    		</property>
    		<property name="objectDefinitionSource">
    			<value>
    				creatxr.demos.service.Duplicable.duplicate=ROLE_METHOD_JTA
    			</value>
    		</property>
    	</bean>
    
    	<bean id="JtaAutoProxyCreator"
    		class="org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator">
    		<property name="interceptorNames">
    			<list>
    				<value>JtaMethodSecurityInterceptor</value>
    			</list>
    		</property>
    		<property name="beanNames">
    			<list>
    				<value>dualServiceBean</value>
    			</list>
    		</property>
    		<property name="proxyTargetClass" value="true" />
    	</bean>
    
    	<bean id="NojtaMethodSecurityInterceptor"
    		class="org.acegisecurity.intercept.method.aopalliance.MethodSecurityInterceptor">
    		<property name="authenticationManager">
    			<ref bean="authenticationManager" />
    		</property>
    		<property name="accessDecisionManager">
    			<ref bean="httpRequestAccessDecisionManager" />
    		</property>
    		
    
    		
    		<property name="objectDefinitionSource">
    			<value>
    				creatxr.demos.service.Duplicatable.duplicate=ROLE_METHOD_NOJTA
    			</value>
    		</property>
    	</bean>
    
    	<bean id="WithoutJtaAutoProxyCreator"
    		class="org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator">
    		<property name="interceptorNames">
    			<list>
    				<value>NojtaMethodSecurityInterceptor</value>
    			</list>
    		</property>
    		<property name="beanNames">
    			<list>
    				<value>dualServiceWithoutJTA</value>
    			</list>
    		</property>
    		<property name="proxyTargetClass" value="true" />
    	</bean>
    
    	<!-- Declarative transaction management with JTA Demo -->
    	<bean id="dualServiceWithJTA"
    		class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
    		<property name="transactionManager">
    			<ref bean="transactionManager" />
    		</property>
    		<property name="target">
    			<ref local="dualServiceBean" />
    		</property>
    		<property name="transactionAttributes">
    <!-- 
    			<value>*=PROPAGATION_REQUIRED</value>
     -->		
     			<props>
     				<prop key="*">PROPAGATION_REQUIRED</prop>
     			</props>
    		</property>
    	</bean>
    
    	<bean id="dualServiceBean"
    		class="creatxr.demos.service.DualServiceImpl">
    		<property name="distSessionFactory">
    			<ref bean="coreSessionFactory" />
    		</property>
    		<property name="copySessionFactory">
    			<ref bean="copySessionFactory" />
    		</property>
    	</bean>
    
    	<!-- org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator -->
    	<bean id="dualServiceWithoutJTA"
    		class="creatxr.demos.service.DualServiceImpl">
    		<property name="distSessionFactory">
    			<ref bean="coreSessionFactory" />
    		</property>
    		<property name="copySessionFactory">
    			<ref bean="copySessionFactory" />
    		</property>
    	</bean>
    Last edited by creatxr; Jul 2nd, 2006, 08:26 AM. Reason: change code

  • #2
    Can you post your entire applicationContext-acegi-security.xml file?

    Comment

    Working...
    X