applicationContext.xml 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262
  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 NOT using container adapters
  5. - $Id$
  6. -
  7. -
  8. - HAVING PROBLEMS? See the etc/ssl/howto.txt file and read "TROUBLESHOOTING".
  9. -
  10. -
  11. -->
  12. <beans>
  13. <!-- =================== SECURITY SYSTEM DEFINITIONS ================== -->
  14. <!-- RunAsManager -->
  15. <bean id="runAsManager" class="net.sf.acegisecurity.runas.RunAsManagerImpl">
  16. <property name="key"><value>my_run_as_password</value></property>
  17. </bean>
  18. <!-- ~~~~~~~~~~~~~~~~~~~~ AUTHENTICATION DEFINITIONS ~~~~~~~~~~~~~~~~~~ -->
  19. <bean id="runAsAuthenticationProvider" class="net.sf.acegisecurity.runas.RunAsImplAuthenticationProvider">
  20. <property name="key"><value>my_run_as_password</value></property>
  21. </bean>
  22. <bean id="authenticationManager" class="net.sf.acegisecurity.providers.ProviderManager">
  23. <property name="providers">
  24. <list>
  25. <ref local="runAsAuthenticationProvider"/>
  26. <ref local="casAuthenticationProvider"/>
  27. </list>
  28. </property>
  29. </bean>
  30. <bean id="inMemoryDaoImpl" class="net.sf.acegisecurity.providers.dao.memory.InMemoryDaoImpl">
  31. <property name="userMap">
  32. <value>
  33. marissa=PASSWORD_NOT_USED,ROLE_TELLER,ROLE_SUPERVISOR
  34. dianne=PASSWORD_NOT_USED,ROLE_TELLER
  35. scott=PASSWORD_NOT_USED,ROLE_TELLER
  36. peter=PASSWORD_NOT_USED_AND_DISABLED_IGNORED,disabled,ROLE_TELLER
  37. </value>
  38. </property>
  39. </bean>
  40. <bean id="basicProcessingFilter" class="net.sf.acegisecurity.ui.basicauth.BasicProcessingFilter">
  41. <property name="authenticationManager"><ref local="authenticationManager"/></property>
  42. <property name="authenticationEntryPoint"><ref local="basicProcessingFilterEntryPoint"/></property>
  43. </bean>
  44. <bean id="basicProcessingFilterEntryPoint" class="net.sf.acegisecurity.ui.basicauth.BasicProcessingFilterEntryPoint">
  45. <property name="realmName"><value>Contacts Realm</value></property>
  46. </bean>
  47. <bean id="autoIntegrationFilter" class="net.sf.acegisecurity.ui.AutoIntegrationFilter" />
  48. <bean id="casAuthenticationProvider" class="net.sf.acegisecurity.providers.cas.CasAuthenticationProvider">
  49. <property name="casAuthoritiesPopulator"><ref local="casAuthoritiesPopulator"/></property>
  50. <property name="casProxyDecider"><ref local="casProxyDecider"/></property>
  51. <property name="ticketValidator"><ref local="casProxyTicketValidator"/></property>
  52. <property name="statelessTicketCache"><ref local="statelessTicketCache"/></property>
  53. <property name="key"><value>my_password_for_this_auth_provider_only</value></property>
  54. </bean>
  55. <bean id="casProxyTicketValidator" class="net.sf.acegisecurity.providers.cas.ticketvalidator.CasProxyTicketValidator">
  56. <property name="casValidate"><value>https://localhost:8443/cas/proxyValidate</value></property>
  57. <property name="proxyCallbackUrl"><value>https://localhost:8443/contacts-cas/casProxy/receptor</value></property>
  58. <property name="serviceProperties"><ref local="serviceProperties"/></property>
  59. <!-- <property name="trustStore"><value>/some/path/to/your/lib/security/cacerts</value></property> -->
  60. </bean>
  61. <bean id="statelessTicketCache" class="net.sf.acegisecurity.providers.cas.cache.EhCacheBasedTicketCache">
  62. <property name="minutesToIdle"><value>20</value></property>
  63. </bean>
  64. <bean id="casAuthoritiesPopulator" class="net.sf.acegisecurity.providers.cas.populator.DaoCasAuthoritiesPopulator">
  65. <property name="authenticationDao"><ref local="inMemoryDaoImpl"/></property>
  66. </bean>
  67. <bean id="casProxyDecider" class="net.sf.acegisecurity.providers.cas.proxy.RejectProxyTickets">
  68. </bean>
  69. <bean id="serviceProperties" class="net.sf.acegisecurity.ui.cas.ServiceProperties">
  70. <property name="service"><value>https://localhost:8443/contacts-cas/j_acegi_cas_security_check</value></property>
  71. <property name="sendRenew"><value>false</value></property>
  72. </bean>
  73. <!-- ~~~~~~~~~~~~~~~~~~~~ AUTHORIZATION DEFINITIONS ~~~~~~~~~~~~~~~~~~~ -->
  74. <!-- An access decision voter that reads ROLE_* configuaration settings -->
  75. <bean id="roleVoter" class="net.sf.acegisecurity.vote.RoleVoter"/>
  76. <!-- An access decision voter that reads CONTACT_OWNED_BY_CURRENT_USER configuaration settings -->
  77. <bean id="contactSecurityVoter" class="sample.contact.ContactSecurityVoter"/>
  78. <!-- An access decision manager used by the business objects -->
  79. <bean id="businessAccessDecisionManager" class="net.sf.acegisecurity.vote.AffirmativeBased">
  80. <property name="allowIfAllAbstainDecisions"><value>false</value></property>
  81. <property name="decisionVoters">
  82. <list>
  83. <ref local="roleVoter"/>
  84. <ref local="contactSecurityVoter"/>
  85. </list>
  86. </property>
  87. </bean>
  88. <!-- ===================== SECURITY DEFINITIONS ======================= -->
  89. <bean id="publicContactManagerSecurity" class="net.sf.acegisecurity.intercept.method.aopalliance.MethodSecurityInterceptor">
  90. <property name="authenticationManager"><ref local="authenticationManager"/></property>
  91. <property name="accessDecisionManager"><ref local="businessAccessDecisionManager"/></property>
  92. <property name="runAsManager"><ref local="runAsManager"/></property>
  93. <property name="objectDefinitionSource">
  94. <value>
  95. sample.contact.ContactManager.delete=ROLE_SUPERVISOR,RUN_AS_SERVER
  96. sample.contact.ContactManager.getAllByOwner=CONTACT_OWNED_BY_CURRENT_USER,RUN_AS_SERVER
  97. sample.contact.ContactManager.save=CONTACT_OWNED_BY_CURRENT_USER,RUN_AS_SERVER
  98. sample.contact.ContactManager.getById=ROLE_TELLER,RUN_AS_SERVER
  99. </value>
  100. </property>
  101. </bean>
  102. <!-- We expect all callers of the backend object to hold the role ROLE_RUN_AS_SERVER -->
  103. <bean id="backendContactManagerSecurity" class="net.sf.acegisecurity.intercept.method.aopalliance.MethodSecurityInterceptor">
  104. <property name="authenticationManager"><ref local="authenticationManager"/></property>
  105. <property name="accessDecisionManager"><ref local="businessAccessDecisionManager"/></property>
  106. <property name="runAsManager"><ref local="runAsManager"/></property>
  107. <property name="objectDefinitionSource">
  108. <value>
  109. sample.contact.ContactManager.delete=ROLE_RUN_AS_SERVER
  110. sample.contact.ContactManager.getAllByOwner=ROLE_RUN_AS_SERVER
  111. sample.contact.ContactManager.save=ROLE_RUN_AS_SERVER
  112. sample.contact.ContactManager.getById=ROLE_RUN_AS_SERVER
  113. </value>
  114. </property>
  115. </bean>
  116. <!-- ======================= BUSINESS DEFINITIONS ===================== -->
  117. <bean id="contactManager" class="org.springframework.aop.framework.ProxyFactoryBean">
  118. <property name="proxyInterfaces"><value>sample.contact.ContactManager</value></property>
  119. <property name="interceptorNames">
  120. <list>
  121. <idref local="publicContactManagerSecurity"/>
  122. <idref local="publicContactManagerTarget"/>
  123. </list>
  124. </property>
  125. </bean>
  126. <bean id="publicContactManagerTarget" class="sample.contact.ContactManagerFacade">
  127. <property name="backend"><ref local="backendContactManager"/></property>
  128. </bean>
  129. <bean id="backendContactManager" class="org.springframework.aop.framework.ProxyFactoryBean">
  130. <property name="proxyInterfaces"><value>sample.contact.ContactManager</value></property>
  131. <property name="interceptorNames">
  132. <list>
  133. <idref local="backendContactManagerSecurity"/>
  134. <idref local="backendContactManagerTarget"/>
  135. </list>
  136. </property>
  137. </bean>
  138. <bean id="backendContactManagerTarget" class="sample.contact.ContactManagerBackend"/>
  139. <!-- ===================== HTTP CHANNEL REQUIREMENTS ==================== -->
  140. <bean id="channelProcessingFilter" class="net.sf.acegisecurity.securechannel.ChannelProcessingFilter">
  141. <property name="channelDecisionManager"><ref local="channelDecisionManager"/></property>
  142. <property name="filterInvocationDefinitionSource">
  143. <value>
  144. CONVERT_URL_TO_LOWERCASE_BEFORE_COMPARISON
  145. \A/secure/.*\Z=REQUIRES_SECURE_CHANNEL
  146. \A/j_acegi_cas_security_check.*\Z=REQUIRES_SECURE_CHANNEL
  147. \A.*\Z=REQUIRES_INSECURE_CHANNEL
  148. </value>
  149. </property>
  150. </bean>
  151. <bean id="channelDecisionManager" class="net.sf.acegisecurity.securechannel.ChannelDecisionManagerImpl">
  152. <property name="channelProcessors">
  153. <list>
  154. <ref local="secureChannelProcessor"/>
  155. <ref local="insecureChannelProcessor"/>
  156. </list>
  157. </property>
  158. </bean>
  159. <bean id="secureChannelProcessor" class="net.sf.acegisecurity.securechannel.SecureChannelProcessor"/>
  160. <bean id="insecureChannelProcessor" class="net.sf.acegisecurity.securechannel.InsecureChannelProcessor"/>
  161. <!-- ===================== HTTP REQUEST SECURITY ==================== -->
  162. <bean id="casProcessingFilter" class="net.sf.acegisecurity.ui.cas.CasProcessingFilter">
  163. <property name="authenticationManager"><ref local="authenticationManager"/></property>
  164. <property name="authenticationFailureUrl"><value>/casfailed.jsp</value></property>
  165. <property name="defaultTargetUrl"><value>/</value></property>
  166. <property name="filterProcessesUrl"><value>/j_acegi_cas_security_check</value></property>
  167. </bean>
  168. <bean id="securityEnforcementFilter" class="net.sf.acegisecurity.intercept.web.SecurityEnforcementFilter">
  169. <property name="filterSecurityInterceptor"><ref local="filterInvocationInterceptor"/></property>
  170. <property name="authenticationEntryPoint"><ref local="casProcessingFilterEntryPoint"/></property>
  171. </bean>
  172. <bean id="casProcessingFilterEntryPoint" class="net.sf.acegisecurity.ui.cas.CasProcessingFilterEntryPoint">
  173. <property name="loginUrl"><value>https://localhost:8443/cas/login</value></property>
  174. <property name="serviceProperties"><ref local="serviceProperties"/></property>
  175. </bean>
  176. <bean id="httpRequestAccessDecisionManager" class="net.sf.acegisecurity.vote.AffirmativeBased">
  177. <property name="allowIfAllAbstainDecisions"><value>false</value></property>
  178. <property name="decisionVoters">
  179. <list>
  180. <ref local="roleVoter"/>
  181. </list>
  182. </property>
  183. </bean>
  184. <!-- Note the order that entries are placed against the objectDefinitionSource is critical.
  185. The FilterSecurityInterceptor will work from the top of the list down to the FIRST pattern that matches the request URL.
  186. Accordingly, you should place MOST SPECIFIC (ie a/b/c/d.*) expressions first, with LEAST SPECIFIC (ie a/.*) expressions last -->
  187. <bean id="filterInvocationInterceptor" class="net.sf.acegisecurity.intercept.web.FilterSecurityInterceptor">
  188. <property name="authenticationManager"><ref local="authenticationManager"/></property>
  189. <property name="accessDecisionManager"><ref local="httpRequestAccessDecisionManager"/></property>
  190. <property name="runAsManager"><ref local="runAsManager"/></property>
  191. <property name="objectDefinitionSource">
  192. <value>
  193. CONVERT_URL_TO_LOWERCASE_BEFORE_COMPARISON
  194. \A/secure/super.*\Z=ROLE_WE_DONT_HAVE
  195. \A/secure/.*\Z=ROLE_SUPERVISOR,ROLE_TELLER
  196. </value>
  197. </property>
  198. </bean>
  199. <!-- BASIC Regular Expression Syntax (for beginners):
  200. \A means the start of the string (ie the beginning of the URL)
  201. \Z means the end of the string (ie the end of the URL)
  202. . means any single character
  203. * means null or any number of repetitions of the last expression (so .* means zero or more characters)
  204. Some examples:
  205. Expression: \A/my/directory/.*\Z
  206. Would match: /my/directory/
  207. /my/directory/hello.html
  208. Expression: \A/.*\Z
  209. Would match: /hello.html
  210. /
  211. Expression: \A/.*/secret.html\Z
  212. Would match: /some/directory/secret.html
  213. /another/secret.html
  214. Not match: /anothersecret.html (missing required /)
  215. -->
  216. </beans>