contacts-servlet.xml 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  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 definition for "contacts" DispatcherServlet.
  5. - $Id$
  6. -->
  7. <beans>
  8. <!-- ========================== WEB DEFINITIONS ======================= -->
  9. <bean id="publicIndexController" class="sample.contact.PublicIndexController">
  10. <property name="contactManager"><ref bean="contactManager"/></property>
  11. </bean>
  12. <bean id="secureIndexController" class="sample.contact.SecureIndexController">
  13. <property name="contactManager"><ref bean="contactManager"/></property>
  14. </bean>
  15. <bean id="secureDeleteController" class="sample.contact.DeleteController">
  16. <property name="contactManager"><ref bean="contactManager"/></property>
  17. </bean>
  18. <bean id="urlMapping" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
  19. <property name="mappings">
  20. <props>
  21. <prop key="/hello.htm">publicIndexController</prop>
  22. <prop key="/secure/add.htm">secureAddForm</prop>
  23. <prop key="/secure/index.htm">secureIndexController</prop>
  24. <prop key="/secure/del.htm">secureDeleteController</prop>
  25. </props>
  26. </property>
  27. </bean>
  28. <bean id="addValidator" class="sample.contact.WebContactValidator"/>
  29. <bean id="secureAddForm" class="sample.contact.WebContactAddController">
  30. <property name="sessionForm"><value>true</value></property>
  31. <property name="commandName"><value>webContact</value></property>
  32. <property name="commandClass"><value>sample.contact.WebContact</value></property>
  33. <property name="validator"><ref bean="addValidator"/></property>
  34. <property name="formView"><value>add</value></property>
  35. <property name="successView"><value>index.htm</value></property>
  36. <property name="contactManager">
  37. <ref bean="contactManager"/>
  38. </property>
  39. </bean>
  40. <bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
  41. <property name="prefix"><value>/WEB-INF/jsp/</value></property>
  42. <property name="suffix"><value>.jsp</value></property>
  43. </bean>
  44. <!-- =================== SECURITY SYSTEM DEFINITIONS ================== -->
  45. <!-- RunAsManager -->
  46. <bean id="runAsManager" class="net.sf.acegisecurity.runas.RunAsManagerImpl">
  47. <property name="key"><value>my_run_as_password</value></property>
  48. </bean>
  49. <!-- ~~~~~~~~~~~~~~~~~~~~ AUTHENTICATION DEFINITIONS ~~~~~~~~~~~~~~~~~~ -->
  50. <bean id="runAsAuthenticationProvider" class="net.sf.acegisecurity.runas.RunAsImplAuthenticationProvider">
  51. <property name="key"><value>my_run_as_password</value></property>
  52. </bean>
  53. <bean id="authByAdapterProvider" class="net.sf.acegisecurity.adapters.AuthByAdapterProvider">
  54. <property name="key"><value>my_password</value></property>
  55. </bean>
  56. <bean id="authenticationManager" class="net.sf.acegisecurity.providers.ProviderManager">
  57. <property name="providers">
  58. <list>
  59. <ref bean="runAsAuthenticationProvider"/>
  60. <ref bean="authByAdapterProvider"/>
  61. <ref bean="daoAuthenticationProvider"/>
  62. </list>
  63. </property>
  64. </bean>
  65. <bean id="inMemoryDaoImpl" class="net.sf.acegisecurity.providers.dao.memory.InMemoryDaoImpl">
  66. <property name="userMap">
  67. <value>
  68. marissa=koala,ROLE_TELLER,ROLE_SUPERVISOR
  69. dianne=emu,ROLE_TELLER
  70. scott=wombat,ROLE_TELLER
  71. peter=opal,disabled,ROLE_TELLER
  72. </value>
  73. </property>
  74. </bean>
  75. <bean id="daoAuthenticationProvider" class="net.sf.acegisecurity.providers.dao.DaoAuthenticationProvider">
  76. <property name="authenticationDao"><ref bean="inMemoryDaoImpl"/></property>
  77. <property name="ignorePasswordCase"><value>false</value></property>
  78. <property name="ignoreUsernameCase"><value>true</value></property>
  79. </bean>
  80. <!-- ~~~~~~~~~~~~~~~~~~~~ AUTHORIZATION DEFINITIONS ~~~~~~~~~~~~~~~~~~~ -->
  81. <!-- An access decision voter that reads ROLE_* configuaration settings -->
  82. <bean id="roleVoter" class="net.sf.acegisecurity.vote.RoleVoter"/>
  83. <!-- An access decision voter that reads CONTACT_OWNED_BY_CURRENT_USER configuaration settings -->
  84. <bean id="contactSecurityVoter" class="sample.contact.ContactSecurityVoter"/>
  85. <!-- An affirmative access decision manager -->
  86. <bean id="accessDecisionManager" class="net.sf.acegisecurity.vote.AffirmativeBased">
  87. <property name="allowIfAllAbstainDecisions"><value>false</value></property>
  88. <property name="decisionVoters">
  89. <list>
  90. <ref bean="roleVoter"/>
  91. <ref bean="contactSecurityVoter"/>
  92. </list>
  93. </property>
  94. </bean>
  95. <!-- ===================== SECURITY DEFINITIONS ======================= -->
  96. <bean id="publicContactManagerSecurity" class="net.sf.acegisecurity.intercept.method.MethodSecurityInterceptor">
  97. <property name="authenticationManager"><ref bean="authenticationManager"/></property>
  98. <property name="accessDecisionManager"><ref bean="accessDecisionManager"/></property>
  99. <property name="runAsManager"><ref bean="runAsManager"/></property>
  100. <property name="objectDefinitionSource">
  101. <value>
  102. sample.contact.ContactManager.delete=ROLE_SUPERVISOR,RUN_AS_SERVER
  103. sample.contact.ContactManager.getAllByOwner=CONTACT_OWNED_BY_CURRENT_USER,RUN_AS_SERVER
  104. sample.contact.ContactManager.save=CONTACT_OWNED_BY_CURRENT_USER,RUN_AS_SERVER
  105. sample.contact.ContactManager.getById=ROLE_TELLER,RUN_AS_SERVER
  106. </value>
  107. </property>
  108. </bean>
  109. <!-- We expect all callers of the backend object to hold the role ROLE_RUN_AS_SERVER -->
  110. <bean id="backendContactManagerSecurity" class="net.sf.acegisecurity.intercept.method.MethodSecurityInterceptor">
  111. <property name="authenticationManager"><ref bean="authenticationManager"/></property>
  112. <property name="accessDecisionManager"><ref bean="accessDecisionManager"/></property>
  113. <property name="runAsManager"><ref bean="runAsManager"/></property>
  114. <property name="objectDefinitionSource">
  115. <value>
  116. sample.contact.ContactManager.delete=ROLE_RUN_AS_SERVER
  117. sample.contact.ContactManager.getAllByOwner=ROLE_RUN_AS_SERVER
  118. sample.contact.ContactManager.save=ROLE_RUN_AS_SERVER
  119. sample.contact.ContactManager.getById=ROLE_RUN_AS_SERVER
  120. </value>
  121. </property>
  122. </bean>
  123. <!-- ======================= BUSINESS DEFINITIONS ===================== -->
  124. <bean id="contactManager" class="org.springframework.aop.framework.ProxyFactoryBean">
  125. <property name="proxyInterfaces"><value>sample.contact.ContactManager</value></property>
  126. <property name="interceptorNames">
  127. <list>
  128. <value>publicContactManagerSecurity</value>
  129. <value>publicContactManagerTarget</value>
  130. </list>
  131. </property>
  132. </bean>
  133. <bean id="publicContactManagerTarget" class="sample.contact.ContactManagerFacade">
  134. <property name="backend"><ref bean="backendContactManager"/></property>
  135. </bean>
  136. <bean id="backendContactManager" class="org.springframework.aop.framework.ProxyFactoryBean">
  137. <property name="proxyInterfaces"><value>sample.contact.ContactManager</value></property>
  138. <property name="interceptorNames">
  139. <list>
  140. <value>backendContactManagerSecurity</value>
  141. <value>backendContactManagerTarget</value>
  142. </list>
  143. </property>
  144. </bean>
  145. <bean id="backendContactManagerTarget" class="sample.contact.ContactManagerBackend"/>
  146. </beans>