applicationContext.xml 5.7 KB

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