|
From: Tim K. <tim...@vi...> - 2005-09-12 21:10:38
|
I hate to come off sounding like a broken record here, but I asked about this issue last week in the hopes that someone could elaborate further = on it, but didn=92t get any reply on it. I=92m thinking maybe it got lost = in the events over the weekend, so I=92m re-posting both emails I sent below, = in the hopes that someone might afford a look at it and point me in the right direction. Thanks in advance! In a nutshell, I'm seeing different behavior on how interceptors are = applied to an proxy object purely based on whether it is using ProxyFactoryBean = or TransactionProxyFactoryBean. (details are in the email below) =3D=3D=3D=3D=3D=3D ORIGINAL EMAIL (SEE FOLLOWUP EMAIL AFTER THIS ONE) = =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D I'm running into some rather unusual behavior that I cannot explain - so = I thought I'd bring it up here, either I'm doing something wrong, or there = (a far more remote possibility) is something wrong w/ Spring. I previously had an object that was wrapped in a TransactionProxyFactoryBean, and this object also had an Acegi security method interceptor applied to it.=A0=20 In my refactoring of the code to move the transactional concerns to a = higher abstraction layer, I changed the object wrapper from TransactionProxyFactoryBean to ProxyFactoryBean.=A0 Since I wanted to = keep the Acegi method interceptor at this level, I upated the 'postInterceptors' property to 'interceptorNames', and set the name of the Acegi = interceptor in there.=A0=20 from this: =A0=A0=A0 =A0=A0=A0 <property name=3D"postInterceptors"> =A0=A0=A0 =A0=A0=A0 =A0=A0=A0 <list> =A0=A0=A0 =A0=A0=A0 =A0=A0=A0 =A0=A0=A0 <ref = bean=3D"serviceMethodSecurityInterceptor"/> =A0=A0=A0 =A0=A0=A0 =A0=A0=A0 </list> =A0=A0=A0 =A0=A0=A0 </property> to this: =A0=A0=A0 =A0=A0=A0 <property name=3D"interceptorNames"> =A0=A0=A0 =A0=A0=A0 =A0=A0=A0 <list> =A0=A0=A0 =A0=A0=A0 =A0=A0=A0 =A0=A0=A0 = <value>serviceMethodSecurityInterceptor</value> =A0=A0=A0 =A0=A0=A0 =A0=A0=A0 </list> =A0=A0=A0 =A0=A0=A0 </property> Some of the test cases I have broke after this change.=A0 I started = digging around a bit to find out why, and what I've turned up, to the best I can figure out is that when applying an interceptor via 'interceptorNames', = the interceptor gets selectively applied.=A0=A0=A0 This is the configuration = for the method interceptor.=A0 As you can see, we are applying access control on = three different methods.=A0 'get', 'getTopicList' and 'getTopicChildren'.=A0=20 =A0=A0=A0 <bean id=3D"serviceMethodSecurityInterceptor" class=3D"net.sf.acegisecurity.intercept.method.aopalliance.MethodSecurity= Inter ceptor"> =A0=A0=A0 =A0=A0=A0 <property name=3D"authenticationManager"><ref bean=3D"authenticationManager"/></property> =A0=A0=A0=A0 =A0=A0=A0 <property name=3D"accessDecisionManager"><ref bean=3D"decisionManager"/></property> =A0=A0=A0 =A0=A0=A0 <property name=3D"afterInvocationManager"><ref bean=3D"afterInvocationManager"/></property> =A0=A0=A0 =A0=A0=A0 <property name=3D"objectDefinitionSource"> =A0=A0=A0 =A0=A0=A0 =A0=A0=A0 <value> =A0=A0=A0 =A0=A0=A0 =A0=A0=A0 =A0=A0=A0 = com.vivakos.vps.service.Service.get=3DTOPIC_AFTER_ACL_READ =A0=A0=A0 =A0=A0=A0 =A0=A0=A0 =A0=A0=A0 com.vivakos.vps.service.content.TopicService.getTopicList=3DTOPIC_AFTER_A= CL_RE AD =A0=A0=A0 =A0=A0=A0 =A0=A0=A0 =A0=A0=A0 com.vivakos.vps.service.content.TopicService.getTopicChildren=3DTOPIC_AFT= ER_AC L_READ =A0=A0=A0 =A0=A0=A0 =A0=A0=A0 </value> =A0=A0=A0 =A0=A0=A0 </property> =A0=A0=A0 </bean>=A0=A0=A0 =A0=A0=A0=20 And as far as I can see - when using TransactionProxyFactoryBean, all = three methods get applied correctly.=A0 i.e. integration tests that test the = 'get', 'getTopicList' and 'getTopicChildren' all work properly.=A0=20 But when changing to use ProxyFactoryBean, the 'get' method integration = test fails (the interceptor apparently is not called), while 'getTopicList' = and 'getTopicChildren' work integration test works fine.=A0 The only = differnence in how the methods that are tested is that 'get' is defined in an higher level interface (Service) instead of (TopicService).=A0 The integration = test calls topicService.get() .... I'm hoping that someone can help shine additional light on this = difference in behavior with the interceptors, and what I might be doing wrong? Thanks in advance, -tim =3D=3D=3D=3D=3D=3D=3D=3D=3D FOLLOW UP EMAIL SENT A DAY AFTER THE = ORIGINAL =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D Following up on the previous email I sent yesterday, I explored one more scenario. Since the hiearchy for the 'Service' interface is like this. Service=20 -'.get()' + TopicService (extends Service) - .getTopicList() - .getTopicChildren() And as I've mentioned in my previous email, the Acegi security method interceptor does not seem to be kicking in on the 'get()' method when = called on a TopicService implementation, although it does kick in for the other = two methods defined under TopicService when using ProxyFactoryBean and 'interceptorNames' property. =20 So I tested out earlier today what would happen if I defined the 'get()' method at the TopicService interface level, and updated the security = method interceptor from com.vivakos.vps.service.Service.get=3DTOPIC_AFTER_ACL_READ to=20 com.vivakos.vps.service.content.Topic.get=3DTOPIC_AFTER_ACL_READ And the result is that it worked. So, I'm hoping that someone with a = better understanding of what the differences between the ProxyFactoryBean = advising process and the TransactionProxyFactoryBean would be - could clarify = what is going on, since to me, they should work the same? Thanks. -tim |