Raible's Wiki
Raible Designs AppFuseHomepage- Korean - Chinese - Italian - Japanese QuickStart Guide User Guide Tutorials Other ApplicationsStruts ResumeSecurity Example Struts Menu
Set your name in
UserPreferences
Referenced by
JSPWiki v2.2.33
Hide Menu |
Step V: Add new ACEGI Managers to secure all person objectsFinally we need some new bean definitions Adding new beansNew Secure person manager
<bean id="personManagerSecure" class="org.springframework.aop.framework.ProxyFactoryBean">
<property name="proxyInterfaces"><value>org.appfuse.service.PersonManager</value></property>
<property name="interceptorNames">
<list>
<idref bean="personSecurity"/>
<idref bean="personManager"/>
</list>
</property>
</bean>
Adding new personSecurity beanThis bean is resonsible for all security relevant actions, such as securing methods and checking ACLS.
<bean id="personSecurity" class="org.acegisecurity.intercept.method.aopalliance.MethodSecurityInterceptor">
<property name="authenticationManager"><ref bean="authenticationManager"/></property>
<property name="accessDecisionManager"><ref bean="personAccessDecisionManager"/></property>
<property name="afterInvocationManager"><ref bean="afterInvocationManager"/></property>
<property name="objectDefinitionSource">
<value>
org.appfuse.service.PersonManager.getPerson*=user,admin,AFTER_ACL_READ
org.appfuse.service.PersonManager.savePerson*=ACL_PERSON_WRITE
org.appfuse.service.PersonManager.removePerson*=ACL_PERSON_DELETE,admin
org.appfuse.service.PersonManager.getPersons*=ACL_PERSON_READ,AFTER_ACL_COLLECTION_READ
</value>
</property>
</bean>
Defining the decision votersIn this step we need to tell ACEGI, what permissions are described by our new variables (in this case ACL_PERSON_READ , ACL_PERSON_WRITE and ACL_PERSON_DELETE)
<!-- An access decision manager used by the business objects -->
<bean id="personAccessDecisionManager" class="org.acegisecurity.vote.AffirmativeBased">
<property name="allowIfAllAbstainDecisions"><value>false</value></property>
<property name="decisionVoters">
<list>
<ref bean="roleVoter"/>
<ref local="aclPersonReadVoter"/>
<ref local="aclPersonDeleteVoter"/>
<ref local="aclPersonWriteVoter"/>
<ref local="aclPersonAdminVoter"/>
</list>
</property>
</bean>
<!-- An access decision voter that reads ACL_PERSON_READ configuration settings --> <bean id="aclPersonReadVoter" class="org.acegisecurity.vote.BasicAclEntryVoter"> <property name="processConfigAttribute"><value>ACL_PERSON_READ</value></property> <property name="processDomainObjectClass"><value>org.appfuse.model.Person</value></property> <property name="aclManager"><ref bean="aclManager"/></property> <property name="requirePermission"> <list> <ref bean="org.acegisecurity.acl.basic.SimpleAclEntry.ADMINISTRATION"/> <ref bean="org.acegisecurity.acl.basic.SimpleAclEntry.READ"/> </list> </property> </bean> <!-- An access decision voter that reads ACL_PERSON_DELETE configuration settings --> <bean id="aclPersonDeleteVoter" class="org.acegisecurity.vote.BasicAclEntryVoter"> <property name="processConfigAttribute"><value>ACL_PERSON_DELETE</value></property> <property name="processDomainObjectClass"><value>org.appfuse.model.Person</value></property> <property name="aclManager"><ref bean="aclManager"/></property> <property name="requirePermission"> <list> <ref bean="org.acegisecurity.acl.basic.SimpleAclEntry.ADMINISTRATION"/> <ref bean="org.acegisecurity.acl.basic.SimpleAclEntry.DELETE"/> </list> </property> </bean> <!-- An access decision voter that reads ACL_PERSON_DELETE configuration settings --> <bean id="aclPersonWriteVoter" class="org.acegisecurity.vote.BasicAclEntryVoter"> <property name="processConfigAttribute"><value>ACL_PERSON_WRITE</value></property> <property name="processDomainObjectClass"><value>org.appfuse.model.Person</value></property> <property name="aclManager"><ref bean="aclManager"/></property> <property name="requirePermission"> <list> <ref bean="org.acegisecurity.acl.basic.SimpleAclEntry.ADMINISTRATION"/> <ref bean="org.acegisecurity.acl.basic.SimpleAclEntry.WRITE"/> </list> </property> </bean> <!-- An access decision voter that reads ACL_PERSON_ADMIN configuration settings --> <bean id="aclPersonAdminVoter" class="org.acegisecurity.vote.BasicAclEntryVoter"> <property name="processConfigAttribute"><value>ACL_PERSON_ADMIN</value></property> <property name="processDomainObjectClass"><value>org.appfuse.model.Person</value></property> <property name="aclManager"><ref bean="aclManager"/></property> <property name="requirePermission"> <list> <ref bean="org.acegisecurity.acl.basic.SimpleAclEntry.ADMINISTRATION"/> </list> </property> </bean>
<!-- ACL permission masks used by this application -->
<bean id="org.acegisecurity.acl.basic.SimpleAclEntry.ADMINISTRATION" class="org.springframework.beans.factory.config.FieldRetrievingFactoryBean">
<property name="staticField"><value>org.acegisecurity.acl.basic.SimpleAclEntry.ADMINISTRATION</value></property>
</bean>
<bean id="org.acegisecurity.acl.basic.SimpleAclEntry.READ" class="org.springframework.beans.factory.config.FieldRetrievingFactoryBean">
<property name="staticField"><value>org.acegisecurity.acl.basic.SimpleAclEntry.READ</value></property>
</bean>
<bean id="org.acegisecurity.acl.basic.SimpleAclEntry.DELETE" class="org.springframework.beans.factory.config.FieldRetrievingFactoryBean">
<property name="staticField"><value>org.acegisecurity.acl.basic.SimpleAclEntry.DELETE</value></property>
</bean>
<bean id="org.acegisecurity.acl.basic.SimpleAclEntry.WRITE" class="org.springframework.beans.factory.config.FieldRetrievingFactoryBean">
<property name="staticField"><value>org.acegisecurity.acl.basic.SimpleAclEntry.WRITE</value></property>
</bean>
<bean id="aclManager" class="org.acegisecurity.acl.AclProviderManager">
<property name="providers">
<list>
<ref local="basicAclProviderManager"/>
</list>
</property>
</bean>
<bean id="basicAclProviderManager" parent="txProxyTemplate">
<property name="target">
<bean class="org.appfuse.service.acl.impl.BasicAclProviderManagerImpl" autowire="byName" />
</property>
</bean>
Defining the afterInvocationManagerThis manager is used to filter returns values and remove objects a user has no sufficient rights.
<bean id="afterInvocationManager" class="org.acegisecurity.afterinvocation.AfterInvocationProviderManager">
<property name="providers">
<list>
<ref local="afterAclRead"/>
<ref local="afterAclCollectionRead"/>
</list>
</property>
</bean>
<!-- Processes AFTER_ACL_COLLECTION_READ configuration settings -->
<bean id="afterAclCollectionRead" class="org.acegisecurity.afterinvocation.BasicAclEntryAfterInvocationCollectionFilteringProvider">
<property name="aclManager"><ref local="aclManager"/></property>
<property name="requirePermission">
<list>
<ref local="org.acegisecurity.acl.basic.SimpleAclEntry.ADMINISTRATION"/>
<ref local="org.acegisecurity.acl.basic.SimpleAclEntry.READ"/>
</list>
</property>
</bean>
<!-- Processes AFTER_ACL_READ configuration settings -->
<bean id="afterAclRead" class="org.acegisecurity.afterinvocation.BasicAclEntryAfterInvocationProvider">
<property name="aclManager"><ref local="aclManager"/></property>
<property name="requirePermission">
<list>
<ref local="org.acegisecurity.acl.basic.SimpleAclEntry.ADMINISTRATION"/>
<ref local="org.acegisecurity.acl.basic.SimpleAclEntry.READ"/>
</list>
</property>
</bean>
Next step:Step VI. Change all references to the old manager to the new manager
|
||||||