contacts-servlet.xml 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  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. <!-- We rely on the Because the web container to authenticate the user -->
  51. <!-- Authentication provider that accepts as valid our RunAsManagerImpl created tokens -->
  52. <bean id="runAsAuthenticationProvider" class="net.sf.acegisecurity.runas.RunAsImplAuthenticationProvider">
  53. <property name="key"><value>my_run_as_password</value></property>
  54. </bean>
  55. <!-- Authentication provider that accepts as valid any adapter-created Authentication token -->
  56. <bean id="authByAdapterProvider" class="net.sf.acegisecurity.adapters.AuthByAdapterProvider">
  57. <property name="key"><value>my_password</value></property>
  58. </bean>
  59. <!-- The authentication manager that iterates through our authentication providers -->
  60. <bean id="providerManager" class="net.sf.acegisecurity.providers.ProviderManager">
  61. <property name="providers">
  62. <list>
  63. <ref bean="runAsAuthenticationProvider"/>
  64. <ref bean="authByAdapterProvider"/>
  65. </list>
  66. </property>
  67. </bean>
  68. <!-- ~~~~~~~~~~~~~~~~~~~~ AUTHORIZATION DEFINITIONS ~~~~~~~~~~~~~~~~~~~ -->
  69. <!-- An access decision voter that reads ROLE_* configuaration settings -->
  70. <bean id="roleVoter" class="net.sf.acegisecurity.vote.RoleVoter"/>
  71. <!-- An access decision voter that reads CONTACT_OWNED_BY_CURRENT_USER configuaration settings -->
  72. <bean id="contactSecurityVoter" class="sample.contact.ContactSecurityVoter"/>
  73. <!-- An affirmative access decision manager -->
  74. <bean id="affirmativeBased" class="net.sf.acegisecurity.vote.AffirmativeBased">
  75. <property name="allowIfAllAbstainDecisions"><value>false</value></property>
  76. <property name="decisionVoters">
  77. <list>
  78. <ref bean="roleVoter"/>
  79. <ref bean="contactSecurityVoter"/>
  80. </list>
  81. </property>
  82. </bean>
  83. <!-- ===================== SECURITY DEFINITIONS ======================= -->
  84. <bean id="publicContactManagerSecurity" class="net.sf.acegisecurity.SecurityInterceptor">
  85. <property name="authenticationManager"><ref bean="providerManager"/></property>
  86. <property name="accessDecisionManager"><ref bean="affirmativeBased"/></property>
  87. <property name="runAsManager"><ref bean="runAsManager"/></property>
  88. <property name="methodDefinitionSource">
  89. <value>
  90. sample.contact.ContactManager.delete=ROLE_SUPERVISOR,RUN_AS_SERVER
  91. sample.contact.ContactManager.getAllByOwner=CONTACT_OWNED_BY_CURRENT_USER,RUN_AS_SERVER
  92. sample.contact.ContactManager.save=CONTACT_OWNED_BY_CURRENT_USER,RUN_AS_SERVER
  93. sample.contact.ContactManager.getById=ROLE_TELLER,RUN_AS_SERVER
  94. </value>
  95. </property>
  96. </bean>
  97. <!-- We expect all callers of the backend object to hold the role ROLE_RUN_AS_SERVER -->
  98. <bean id="backendContactManagerSecurity" class="net.sf.acegisecurity.SecurityInterceptor">
  99. <property name="authenticationManager"><ref bean="providerManager"/></property>
  100. <property name="accessDecisionManager"><ref bean="affirmativeBased"/></property>
  101. <property name="runAsManager"><ref bean="runAsManager"/></property>
  102. <property name="methodDefinitionSource">
  103. <value>
  104. sample.contact.ContactManager.delete=ROLE_RUN_AS_SERVER
  105. sample.contact.ContactManager.getAllByOwner=ROLE_RUN_AS_SERVER
  106. sample.contact.ContactManager.save=ROLE_RUN_AS_SERVER
  107. sample.contact.ContactManager.getById=ROLE_RUN_AS_SERVER
  108. </value>
  109. </property>
  110. </bean>
  111. <!-- ======================= BUSINESS DEFINITIONS ===================== -->
  112. <bean id="contactManager" class="org.springframework.aop.framework.ProxyFactoryBean">
  113. <property name="proxyInterfaces"><value>sample.contact.ContactManager</value></property>
  114. <property name="interceptorNames">
  115. <list>
  116. <value>publicContactManagerSecurity</value>
  117. <value>publicContactManagerTarget</value>
  118. </list>
  119. </property>
  120. </bean>
  121. <bean id="publicContactManagerTarget" class="sample.contact.ContactManagerFacade">
  122. <property name="backend"><ref bean="backendContactManager"/></property>
  123. </bean>
  124. <bean id="backendContactManager" class="org.springframework.aop.framework.ProxyFactoryBean">
  125. <property name="proxyInterfaces"><value>sample.contact.ContactManager</value></property>
  126. <property name="interceptorNames">
  127. <list>
  128. <value>backendContactManagerSecurity</value>
  129. <value>backendContactManagerTarget</value>
  130. </list>
  131. </property>
  132. </bean>
  133. <bean id="backendContactManagerTarget" class="sample.contact.ContactManagerBackend"/>
  134. </beans>