Howe to make method interception really works
Hello all,
I have spent more than two weeks trying to get Method Interception and ACL to work but in vain.. well.. let's not jump to the ACL part because the security interceptor doesn't even get triggered to check for the correct ACE.. the question is if method interception would ever really work??
I have tried CGLIB proxying and Java Proxying.. and even though CGLIB proxying seems to cause the method interception to work sometimes I had to abandon it because it didn't work with
<aop:scoped-proxy />
and I kept getting the same proxy object for all HTTP sessions.. now I use
<aop:scoped-proxy proxy-target-class="false"/>
which requires Java interface proxying but at least gives me different Beans for different sessions.
I have also tried global point cuts, annotations, and the sec namespace XML to define the method inteception.. but all was in vain.
Any ideas?
My project uses IceFaces 1.8 with Facelets, Spring Security 2.0.8, and runs on Apache Tomcat 6 and JRE 6.18. The interesting part of the configuration file follows:
HTML Code:
<bean id="wfaclDecisionManager" class="org.springframework.security.vote.UnanimousBased">
<property name="allowIfAllAbstainDecisions" value="false" />
<property name="decisionVoters">
<list>
<bean id="roleVoter" class="org.springframework.security.vote.RoleVoter" />
<ref local="wfaclCREATEVoter" />
<ref local="wfaclEDITVoter" />
<ref local="wfaclRELEASEVoter" />
<ref local="wfaclDELETEVoter" />
</list>
</property>
</bean>
<bean id="wfaclCREATEVoter" class="org.springframework.security.vote.AclEntryVoter">
<constructor-arg ref="aclService" />
<constructor-arg value="WFACL_CREATE" />
<constructor-arg>
<list>
<util:constant
static-field="org.bibalex.workflow.storage.WFSVNClientPermission.WFACL_CREATE" />
</list>
</constructor-arg>
<property name="processDomainObjectClass" value="org.bibalex.workflow.storage.SVNFileCreationProtectionArtifact"/>
</bean>
<!-- And other entry voters ommitted -->
<!--
****** Workflow Definition ******
-->
<bean id="wfStepCREATE" class="org.bibalex.workflow.WFInitiationStep"
lazy-init="true">
<property name="creationProtectionClass"
value="org.bibalex.workflow.storage.SVNFileCreationProtectionArtifact" />
<property name="stepPermission">
<util:constant
static-field="org.bibalex.workflow.storage.WFSVNClientPermission.WFACL_CREATE" />
</property>
<property name="stepRole" value="ROLE_CREATOR" />
<property name="nextStepMap">
<map>
<entry key="PROCEED" value="EDIT" />
</map>
</property>
<!-- DON'T DO IT! -->
<!-- <sec:intercept-methods-->
<!-- access-decision-manager-ref="wfaclDecisionManager">-->
<!-- <sec:protect-->
<!-- method="complete"-->
<!-- access="ROLE_CREATOR,WFACL_CREATE" />-->
<!-- </sec:intercept-methods>-->
</bean>
<bean id="wfStepEDIT" class="org.bibalex.workflow.WFStep"
lazy-init="true">
<property name="stepPermission">
<util:constant
static-field="org.bibalex.workflow.storage.WFSVNClientPermission.WFACL_EDIT" />
</property>
<property name="stepRole" value="ROLE_EDITOR" />
<property name="nextStepMap">
<map>
<entry key="PROCEED" value="RELEASE" />
</map>
</property>
<sec:intercept-methods
access-decision-manager-ref="wfaclDecisionManager">
<sec:protect
method="complete"
access="ROLE_EDITOR,WFACL_EDIT" />
</sec:intercept-methods>
</bean>
<bean id="wfStepRELEASE" class="org.bibalex.workflow.WFStep"
lazy-init="true">
<property name="stepPermission">
<util:constant
static-field="org.bibalex.workflow.storage.WFSVNClientPermission.WFACL_RELEASE" />
</property>
<property name="stepRole" value="ROLE_RELEASER" />
<property name="nextStepMap">
<map>
<entry key="ACCEPT" value="DONE" />
<entry key="REJECT" value="EDIT" />
</map>
</property>
<sec:intercept-methods
access-decision-manager-ref="wfaclDecisionManager">
<sec:protect
method="complete"
access="ROLE_RELEASER,WFACL_RELEASE" />
</sec:intercept-methods>
</bean>
<bean id="wfStepDONE" class="org.bibalex.workflow.WFTerminationStep"
lazy-init="true">
</bean>
<!-- ******** WFProcessObject ******* -->
<bean id="wamcpWFProcess" class="org.bibalex.workflow.WFProcess"
lazy-init="true">
<constructor-arg ref="aclService" /> <!-- <property name="aclSvc" ref="aclService"/> -->
<constructor-arg ref="wamcpAppDataSource" /> <!-- <property name="datasource" ref="wamcpAppDataSource" /> -->
<constructor-arg ref="aclSecurityUtil" />
<property name="steps">
<map>
<entry key="INIT" value-ref="wfStepCREATE" />
<entry key="EDIT" value-ref="wfStepEDIT" />
<entry key="RELEASE" value-ref="wfStepRELEASE" />
<entry key="DONE" value-ref="wfStepDONE" />
</map>
</property>
</bean>
<!-- ****************** enforcing the workflow ***************** -->
<!-- This didn't work.. neither the annotations or the pointcuts :D -->
<!-- LOOOOOOOOOOOOOL -->
<!-- <sec:global-method-security-->
<!-- secured-annotations="enabled"-->
<!-- access-decision-manager-ref="wfaclDecisionManager" >-->
<!---->
<!-- <sec:protect-pointcut -->
<!-- access="ROLE_CREATOR, WFACL_CREATE" -->
<!--
expression="execution(*
org.bibalex.wamcp.application.WAMCPStorage.add(..))"/>
-->
<!-- </sec:global-method-security>-->
<bean class="org.bibalex.workflow.storage.WFSVNClient" id="wfsvnClient"
scope="session" lazy-init="true">
<aop:scoped-proxy proxy-target-class="false"/>
<property name="URL_SVN_ROOT" value="PROTECTED" />
<property name="svnUsername" value="PROTECTED.naga" />
<property name="svnPassword" value="PROTECTED" />
<property name="wfProcess" ref="wamcpWFProcess" />
<sec:intercept-methods
access-decision-manager-ref="wfaclDecisionManager">
<sec:protect
method="svn*"
access="ROLE_SVNACCESSOR"/>
<sec:protect
method="add"
access="ROLE_CREATOR,WFACL_CREATE" />
<sec:protect
method="openWrite"
access="ROLE_EDITOR,WFACL_EDIT" />
<sec:protect
method="openRead"
access="ROLE_SVNACCESSOR" />
<sec:protect
method="svnCommit"
access="ROLE_EDITOR,WFACL_EDIT" />
<sec:protect
method="svnRevert"
access="ROLE_EDITOR,WFACL_EDIT" />
<!-- <sec:protect-->
<!-- method="permitDelete"-->
<!-- access="ROLE_ADMIN" />-->
<sec:protect
method="delete"
access="ROLE_ADMIN,WFACL_DELETE" />
<sec:protect
method="requestDelete"
access="ROLE_DELETER" />
<sec:protect
method="unrequestDelete"
access="ROLE_DELETER" />
</sec:intercept-methods>
<property name="proxiedThis" ref="wfsvnClient" />
</bean>
Any help would be greatly appreciated