applicationContext.xml 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
  3. <!--
  4. - Application context loaded by ContextLoaderListener if using container adapters
  5. - $Id$
  6. -->
  7. <beans>
  8. <!-- =================== SECURITY SYSTEM DEFINITIONS ================== -->
  9. <!-- RunAsManager -->
  10. <bean id="runAsManager" class="net.sf.acegisecurity.runas.RunAsManagerImpl">
  11. <property name="key"><value>my_run_as_password</value></property>
  12. </bean>
  13. <!-- ~~~~~~~~~~~~~~~~~~~~ AUTHENTICATION DEFINITIONS ~~~~~~~~~~~~~~~~~~ -->
  14. <bean id="runAsAuthenticationProvider" class="net.sf.acegisecurity.runas.RunAsImplAuthenticationProvider">
  15. <property name="key"><value>my_run_as_password</value></property>
  16. </bean>
  17. <bean id="authByAdapterProvider" class="net.sf.acegisecurity.adapters.AuthByAdapterProvider">
  18. <property name="key"><value>my_password</value></property>
  19. </bean>
  20. <bean id="authenticationManager" class="net.sf.acegisecurity.providers.ProviderManager">
  21. <property name="providers">
  22. <list>
  23. <ref bean="runAsAuthenticationProvider"/>
  24. <ref bean="authByAdapterProvider"/>
  25. <ref bean="daoAuthenticationProvider"/>
  26. </list>
  27. </property>
  28. </bean>
  29. <bean id="inMemoryDaoImpl" class="net.sf.acegisecurity.providers.dao.memory.InMemoryDaoImpl">
  30. <property name="userMap">
  31. <value>
  32. marissa=koala,ROLE_TELLER,ROLE_SUPERVISOR
  33. dianne=emu,ROLE_TELLER
  34. scott=wombat,ROLE_TELLER
  35. peter=opal,disabled,ROLE_TELLER
  36. </value>
  37. </property>
  38. </bean>
  39. <bean id="daoAuthenticationProvider" class="net.sf.acegisecurity.providers.dao.DaoAuthenticationProvider">
  40. <property name="authenticationDao"><ref bean="inMemoryDaoImpl"/></property>
  41. </bean>
  42. <!-- ~~~~~~~~~~~~~~~~~~~~ AUTHORIZATION DEFINITIONS ~~~~~~~~~~~~~~~~~~~ -->
  43. <!-- An access decision voter that reads ROLE_* configuaration settings -->
  44. <bean id="roleVoter" class="net.sf.acegisecurity.vote.RoleVoter"/>
  45. <!-- An access decision voter that reads CONTACT_OWNED_BY_CURRENT_USER configuaration settings -->
  46. <bean id="contactSecurityVoter" class="sample.contact.ContactSecurityVoter"/>
  47. <!-- An access decision manager used by the business objects -->
  48. <bean id="businessAccessDecisionManager" class="net.sf.acegisecurity.vote.AffirmativeBased">
  49. <property name="allowIfAllAbstainDecisions"><value>false</value></property>
  50. <property name="decisionVoters">
  51. <list>
  52. <ref bean="roleVoter"/>
  53. <ref bean="contactSecurityVoter"/>
  54. </list>
  55. </property>
  56. </bean>
  57. <!-- ===================== SECURITY DEFINITIONS ======================= -->
  58. <bean id="publicContactManagerSecurity" class="net.sf.acegisecurity.intercept.method.MethodSecurityInterceptor">
  59. <property name="authenticationManager"><ref bean="authenticationManager"/></property>
  60. <property name="accessDecisionManager"><ref bean="businessAccessDecisionManager"/></property>
  61. <property name="runAsManager"><ref bean="runAsManager"/></property>
  62. <property name="objectDefinitionSource">
  63. <value>
  64. sample.contact.ContactManager.delete=ROLE_SUPERVISOR,RUN_AS_SERVER
  65. sample.contact.ContactManager.getAllByOwner=CONTACT_OWNED_BY_CURRENT_USER,RUN_AS_SERVER
  66. sample.contact.ContactManager.save=CONTACT_OWNED_BY_CURRENT_USER,RUN_AS_SERVER
  67. sample.contact.ContactManager.getById=ROLE_TELLER,RUN_AS_SERVER
  68. </value>
  69. </property>
  70. </bean>
  71. <!-- We expect all callers of the backend object to hold the role ROLE_RUN_AS_SERVER -->
  72. <bean id="backendContactManagerSecurity" class="net.sf.acegisecurity.intercept.method.MethodSecurityInterceptor">
  73. <property name="authenticationManager"><ref bean="authenticationManager"/></property>
  74. <property name="accessDecisionManager"><ref bean="businessAccessDecisionManager"/></property>
  75. <property name="runAsManager"><ref bean="runAsManager"/></property>
  76. <property name="objectDefinitionSource">
  77. <value>
  78. sample.contact.ContactManager.delete=ROLE_RUN_AS_SERVER
  79. sample.contact.ContactManager.getAllByOwner=ROLE_RUN_AS_SERVER
  80. sample.contact.ContactManager.save=ROLE_RUN_AS_SERVER
  81. sample.contact.ContactManager.getById=ROLE_RUN_AS_SERVER
  82. </value>
  83. </property>
  84. </bean>
  85. <!-- ======================= BUSINESS DEFINITIONS ===================== -->
  86. <bean id="contactManager" class="org.springframework.aop.framework.ProxyFactoryBean">
  87. <property name="proxyInterfaces"><value>sample.contact.ContactManager</value></property>
  88. <property name="interceptorNames">
  89. <list>
  90. <value>publicContactManagerSecurity</value>
  91. <value>publicContactManagerTarget</value>
  92. </list>
  93. </property>
  94. </bean>
  95. <bean id="publicContactManagerTarget" class="sample.contact.ContactManagerFacade">
  96. <property name="backend"><ref bean="backendContactManager"/></property>
  97. </bean>
  98. <bean id="backendContactManager" class="org.springframework.aop.framework.ProxyFactoryBean">
  99. <property name="proxyInterfaces"><value>sample.contact.ContactManager</value></property>
  100. <property name="interceptorNames">
  101. <list>
  102. <value>backendContactManagerSecurity</value>
  103. <value>backendContactManagerTarget</value>
  104. </list>
  105. </property>
  106. </bean>
  107. <bean id="backendContactManagerTarget" class="sample.contact.ContactManagerBackend"/>
  108. </beans>