applicationContext.xml 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257
  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. <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="authenticationManager" class="net.sf.acegisecurity.providers.ProviderManager">
  18. <property name="providers">
  19. <list>
  20. <ref bean="runAsAuthenticationProvider"/>
  21. <ref bean="casAuthenticationProvider"/>
  22. </list>
  23. </property>
  24. </bean>
  25. <bean id="inMemoryDaoImpl" class="net.sf.acegisecurity.providers.dao.memory.InMemoryDaoImpl">
  26. <property name="userMap">
  27. <value>
  28. marissa=PASSWORD_NOT_USED,ROLE_TELLER,ROLE_SUPERVISOR
  29. dianne=PASSWORD_NOT_USED,ROLE_TELLER
  30. scott=PASSWORD_NOT_USED,ROLE_TELLER
  31. peter=PASSWORD_NOT_USED_AND_DISABLED_IGNORED,disabled,ROLE_TELLER
  32. </value>
  33. </property>
  34. </bean>
  35. <bean id="basicProcessingFilter" class="net.sf.acegisecurity.ui.basicauth.BasicProcessingFilter">
  36. <property name="authenticationManager"><ref bean="authenticationManager"/></property>
  37. <property name="authenticationEntryPoint"><ref bean="basicProcessingFilterEntryPoint"/></property>
  38. </bean>
  39. <bean id="basicProcessingFilterEntryPoint" class="net.sf.acegisecurity.ui.basicauth.BasicProcessingFilterEntryPoint">
  40. <property name="realmName"><value>Contacts Realm</value></property>
  41. </bean>
  42. <bean id="autoIntegrationFilter" class="net.sf.acegisecurity.ui.AutoIntegrationFilter" />
  43. <bean id="casAuthenticationProvider" class="net.sf.acegisecurity.providers.cas.CasAuthenticationProvider">
  44. <property name="casAuthoritiesPopulator"><ref bean="casAuthoritiesPopulator"/></property>
  45. <property name="casProxyDecider"><ref bean="casProxyDecider"/></property>
  46. <property name="ticketValidator"><ref bean="casProxyTicketValidator"/></property>
  47. <property name="statelessTicketCache"><ref bean="statelessTicketCache"/></property>
  48. <property name="key"><value>my_password_for_this_auth_provider_only</value></property>
  49. </bean>
  50. <bean id="casProxyTicketValidator" class="net.sf.acegisecurity.providers.cas.ticketvalidator.CasProxyTicketValidator">
  51. <property name="casValidate"><value>https://localhost:8443/cas/proxyValidate</value></property>
  52. <property name="proxyCallbackUrl"><value>https://localhost:8443/contacts-cas/casProxy/receptor</value></property>
  53. <property name="serviceProperties"><ref bean="serviceProperties"/></property>
  54. <!-- <property name="trustStore"><value>/some/path/to/your/lib/security/cacerts</value></property> -->
  55. </bean>
  56. <bean id="statelessTicketCache" class="net.sf.acegisecurity.providers.cas.cache.EhCacheBasedTicketCache">
  57. <property name="minutesToIdle"><value>20</value></property>
  58. </bean>
  59. <bean id="casAuthoritiesPopulator" class="net.sf.acegisecurity.providers.cas.populator.DaoCasAuthoritiesPopulator">
  60. <property name="authenticationDao"><ref bean="inMemoryDaoImpl"/></property>
  61. </bean>
  62. <bean id="casProxyDecider" class="net.sf.acegisecurity.providers.cas.proxy.RejectProxyTickets">
  63. </bean>
  64. <bean id="serviceProperties" class="net.sf.acegisecurity.ui.cas.ServiceProperties">
  65. <property name="service"><value>https://localhost:8443/contacts-cas/j_acegi_cas_security_check</value></property>
  66. <property name="sendRenew"><value>false</value></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 access decision manager used by the business objects -->
  74. <bean id="businessAccessDecisionManager" 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.intercept.method.MethodSecurityInterceptor">
  85. <property name="authenticationManager"><ref bean="authenticationManager"/></property>
  86. <property name="accessDecisionManager"><ref bean="businessAccessDecisionManager"/></property>
  87. <property name="runAsManager"><ref bean="runAsManager"/></property>
  88. <property name="objectDefinitionSource">
  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.intercept.method.MethodSecurityInterceptor">
  99. <property name="authenticationManager"><ref bean="authenticationManager"/></property>
  100. <property name="accessDecisionManager"><ref bean="businessAccessDecisionManager"/></property>
  101. <property name="runAsManager"><ref bean="runAsManager"/></property>
  102. <property name="objectDefinitionSource">
  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. <!-- ===================== HTTP CHANNEL REQUIREMENTS ==================== -->
  135. <bean id="channelProcessingFilter" class="net.sf.acegisecurity.securechannel.ChannelProcessingFilter">
  136. <property name="channelDecisionManager"><ref bean="channelDecisionManager"/></property>
  137. <property name="filterInvocationDefinitionSource">
  138. <value>
  139. CONVERT_URL_TO_LOWERCASE_BEFORE_COMPARISON
  140. \A/secure/.*\Z=REQUIRES_SECURE_CHANNEL
  141. \A/j_acegi_cas_security_check.*\Z=REQUIRES_SECURE_CHANNEL
  142. \A.*\Z=REQUIRES_INSECURE_CHANNEL
  143. </value>
  144. </property>
  145. </bean>
  146. <bean id="channelDecisionManager" class="net.sf.acegisecurity.securechannel.ChannelDecisionManagerImpl">
  147. <property name="channelProcessors">
  148. <list>
  149. <ref bean="secureChannelProcessor"/>
  150. <ref bean="insecureChannelProcessor"/>
  151. </list>
  152. </property>
  153. </bean>
  154. <bean id="secureChannelProcessor" class="net.sf.acegisecurity.securechannel.SecureChannelProcessor"/>
  155. <bean id="insecureChannelProcessor" class="net.sf.acegisecurity.securechannel.InsecureChannelProcessor"/>
  156. <!-- ===================== HTTP REQUEST SECURITY ==================== -->
  157. <bean id="casProcessingFilter" class="net.sf.acegisecurity.ui.cas.CasProcessingFilter">
  158. <property name="authenticationManager"><ref bean="authenticationManager"/></property>
  159. <property name="authenticationFailureUrl"><value>/casfailed.jsp</value></property>
  160. <property name="defaultTargetUrl"><value>/</value></property>
  161. <property name="filterProcessesUrl"><value>/j_acegi_cas_security_check</value></property>
  162. </bean>
  163. <bean id="securityEnforcementFilter" class="net.sf.acegisecurity.intercept.web.SecurityEnforcementFilter">
  164. <property name="filterSecurityInterceptor"><ref bean="filterInvocationInterceptor"/></property>
  165. <property name="authenticationEntryPoint"><ref bean="casProcessingFilterEntryPoint"/></property>
  166. </bean>
  167. <bean id="casProcessingFilterEntryPoint" class="net.sf.acegisecurity.ui.cas.CasProcessingFilterEntryPoint">
  168. <property name="loginUrl"><value>https://localhost:8443/cas/login</value></property>
  169. <property name="serviceProperties"><ref bean="serviceProperties"/></property>
  170. </bean>
  171. <bean id="httpRequestAccessDecisionManager" class="net.sf.acegisecurity.vote.AffirmativeBased">
  172. <property name="allowIfAllAbstainDecisions"><value>false</value></property>
  173. <property name="decisionVoters">
  174. <list>
  175. <ref bean="roleVoter"/>
  176. </list>
  177. </property>
  178. </bean>
  179. <!-- Note the order that entries are placed against the objectDefinitionSource is critical.
  180. The FilterSecurityInterceptor will work from the top of the list down to the FIRST pattern that matches the request URL.
  181. Accordingly, you should place MOST SPECIFIC (ie a/b/c/d.*) expressions first, with LEAST SPECIFIC (ie a/.*) expressions last -->
  182. <bean id="filterInvocationInterceptor" class="net.sf.acegisecurity.intercept.web.FilterSecurityInterceptor">
  183. <property name="authenticationManager"><ref bean="authenticationManager"/></property>
  184. <property name="accessDecisionManager"><ref bean="httpRequestAccessDecisionManager"/></property>
  185. <property name="runAsManager"><ref bean="runAsManager"/></property>
  186. <property name="objectDefinitionSource">
  187. <value>
  188. CONVERT_URL_TO_LOWERCASE_BEFORE_COMPARISON
  189. \A/secure/super.*\Z=ROLE_WE_DONT_HAVE
  190. \A/secure/.*\Z=ROLE_SUPERVISOR,ROLE_TELLER
  191. </value>
  192. </property>
  193. </bean>
  194. <!-- BASIC Regular Expression Syntax (for beginners):
  195. \A means the start of the string (ie the beginning of the URL)
  196. \Z means the end of the string (ie the end of the URL)
  197. . means any single character
  198. * means null or any number of repetitions of the last expression (so .* means zero or more characters)
  199. Some examples:
  200. Expression: \A/my/directory/.*\Z
  201. Would match: /my/directory/
  202. /my/directory/hello.html
  203. Expression: \A/.*\Z
  204. Would match: /hello.html
  205. /
  206. Expression: \A/.*/secret.html\Z
  207. Would match: /some/directory/secret.html
  208. /another/secret.html
  209. Not match: /anothersecret.html (missing required /)
  210. -->
  211. </beans>