applicationContext.xml 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  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. <bean id="basicProcessingFilter" class="net.sf.acegisecurity.ui.basicauth.BasicProcessingFilter">
  43. <property name="authenticationManager"><ref bean="authenticationManager"/></property>
  44. <property name="authenticationEntryPoint"><ref bean="basicProcessingFilterEntryPoint"/></property>
  45. </bean>
  46. <bean id="basicProcessingFilterEntryPoint" class="net.sf.acegisecurity.ui.basicauth.BasicProcessingFilterEntryPoint">
  47. <property name="realmName"><value>Contacts Realm</value></property>
  48. </bean>
  49. <bean id="autoIntegrationFilter" class="net.sf.acegisecurity.ui.AutoIntegrationFilter" />
  50. <!-- ~~~~~~~~~~~~~~~~~~~~ AUTHORIZATION DEFINITIONS ~~~~~~~~~~~~~~~~~~~ -->
  51. <!-- An access decision voter that reads ROLE_* configuaration settings -->
  52. <bean id="roleVoter" class="net.sf.acegisecurity.vote.RoleVoter"/>
  53. <!-- An access decision voter that reads CONTACT_OWNED_BY_CURRENT_USER configuaration settings -->
  54. <bean id="contactSecurityVoter" class="sample.contact.ContactSecurityVoter"/>
  55. <!-- An access decision manager used by the business objects -->
  56. <bean id="businessAccessDecisionManager" class="net.sf.acegisecurity.vote.AffirmativeBased">
  57. <property name="allowIfAllAbstainDecisions"><value>false</value></property>
  58. <property name="decisionVoters">
  59. <list>
  60. <ref bean="roleVoter"/>
  61. <ref bean="contactSecurityVoter"/>
  62. </list>
  63. </property>
  64. </bean>
  65. <!-- ===================== SECURITY DEFINITIONS ======================= -->
  66. <bean id="publicContactManagerSecurity" class="net.sf.acegisecurity.intercept.method.MethodSecurityInterceptor">
  67. <property name="authenticationManager"><ref bean="authenticationManager"/></property>
  68. <property name="accessDecisionManager"><ref bean="businessAccessDecisionManager"/></property>
  69. <property name="runAsManager"><ref bean="runAsManager"/></property>
  70. <property name="objectDefinitionSource">
  71. <value>
  72. sample.contact.ContactManager.delete=ROLE_SUPERVISOR,RUN_AS_SERVER
  73. sample.contact.ContactManager.getAllByOwner=CONTACT_OWNED_BY_CURRENT_USER,RUN_AS_SERVER
  74. sample.contact.ContactManager.save=CONTACT_OWNED_BY_CURRENT_USER,RUN_AS_SERVER
  75. sample.contact.ContactManager.getById=ROLE_TELLER,RUN_AS_SERVER
  76. </value>
  77. </property>
  78. </bean>
  79. <!-- We expect all callers of the backend object to hold the role ROLE_RUN_AS_SERVER -->
  80. <bean id="backendContactManagerSecurity" class="net.sf.acegisecurity.intercept.method.MethodSecurityInterceptor">
  81. <property name="authenticationManager"><ref bean="authenticationManager"/></property>
  82. <property name="accessDecisionManager"><ref bean="businessAccessDecisionManager"/></property>
  83. <property name="runAsManager"><ref bean="runAsManager"/></property>
  84. <property name="objectDefinitionSource">
  85. <value>
  86. sample.contact.ContactManager.delete=ROLE_RUN_AS_SERVER
  87. sample.contact.ContactManager.getAllByOwner=ROLE_RUN_AS_SERVER
  88. sample.contact.ContactManager.save=ROLE_RUN_AS_SERVER
  89. sample.contact.ContactManager.getById=ROLE_RUN_AS_SERVER
  90. </value>
  91. </property>
  92. </bean>
  93. <!-- ======================= BUSINESS DEFINITIONS ===================== -->
  94. <bean id="contactManager" class="org.springframework.aop.framework.ProxyFactoryBean">
  95. <property name="proxyInterfaces"><value>sample.contact.ContactManager</value></property>
  96. <property name="interceptorNames">
  97. <list>
  98. <value>publicContactManagerSecurity</value>
  99. <value>publicContactManagerTarget</value>
  100. </list>
  101. </property>
  102. </bean>
  103. <bean id="publicContactManagerTarget" class="sample.contact.ContactManagerFacade">
  104. <property name="backend"><ref bean="backendContactManager"/></property>
  105. </bean>
  106. <bean id="backendContactManager" class="org.springframework.aop.framework.ProxyFactoryBean">
  107. <property name="proxyInterfaces"><value>sample.contact.ContactManager</value></property>
  108. <property name="interceptorNames">
  109. <list>
  110. <value>backendContactManagerSecurity</value>
  111. <value>backendContactManagerTarget</value>
  112. </list>
  113. </property>
  114. </bean>
  115. <bean id="backendContactManagerTarget" class="sample.contact.ContactManagerBackend"/>
  116. </beans>