applicationContext.xml 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229
  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="casAuthenticationProvider" class="net.sf.acegisecurity.providers.cas.CasAuthenticationProvider">
  43. <property name="casAuthoritiesPopulator"><ref bean="casAuthoritiesPopulator"/></property>
  44. <property name="casProxyDecider"><ref bean="casProxyDecider"/></property>
  45. <property name="ticketValidator"><ref bean="casProxyTicketValidator"/></property>
  46. <property name="statelessTicketCache"><ref bean="statelessTicketCache"/></property>
  47. <property name="key"><value>my_password_for_this_auth_provider_only</value></property>
  48. </bean>
  49. <bean id="casProxyTicketValidator" class="net.sf.acegisecurity.providers.cas.ticketvalidator.CasProxyTicketValidator">
  50. <property name="casValidate"><value>https://localhost:8443/cas/proxyValidate</value></property>
  51. <property name="proxyCallbackUrl"><value>https://localhost:8443/contacts-cas/casProxy/receptor</value></property>
  52. <property name="serviceProperties"><ref bean="serviceProperties"/></property>
  53. <!-- <property name="trustStore"><value>/some/path/to/your/lib/security/cacerts</value></property> -->
  54. </bean>
  55. <bean id="statelessTicketCache" class="net.sf.acegisecurity.providers.cas.cache.EhCacheBasedTicketCache">
  56. <property name="minutesToIdle"><value>20</value></property>
  57. </bean>
  58. <bean id="casAuthoritiesPopulator" class="net.sf.acegisecurity.providers.cas.populator.DaoCasAuthoritiesPopulator">
  59. <property name="authenticationDao"><ref bean="inMemoryDaoImpl"/></property>
  60. </bean>
  61. <bean id="casProxyDecider" class="net.sf.acegisecurity.providers.cas.proxy.RejectProxyTickets">
  62. </bean>
  63. <bean id="serviceProperties" class="net.sf.acegisecurity.ui.cas.ServiceProperties">
  64. <property name="service"><value>https://localhost:8443/contacts-cas/j_acegi_cas_security_check</value></property>
  65. <property name="sendRenew"><value>false</value></property>
  66. </bean>
  67. <!-- ~~~~~~~~~~~~~~~~~~~~ AUTHORIZATION DEFINITIONS ~~~~~~~~~~~~~~~~~~~ -->
  68. <!-- An access decision voter that reads ROLE_* configuaration settings -->
  69. <bean id="roleVoter" class="net.sf.acegisecurity.vote.RoleVoter"/>
  70. <!-- An access decision voter that reads CONTACT_OWNED_BY_CURRENT_USER configuaration settings -->
  71. <bean id="contactSecurityVoter" class="sample.contact.ContactSecurityVoter"/>
  72. <!-- An access decision manager used by the business objects -->
  73. <bean id="businessAccessDecisionManager" class="net.sf.acegisecurity.vote.AffirmativeBased">
  74. <property name="allowIfAllAbstainDecisions"><value>false</value></property>
  75. <property name="decisionVoters">
  76. <list>
  77. <ref bean="roleVoter"/>
  78. <ref bean="contactSecurityVoter"/>
  79. </list>
  80. </property>
  81. </bean>
  82. <!-- ===================== SECURITY DEFINITIONS ======================= -->
  83. <bean id="publicContactManagerSecurity" class="net.sf.acegisecurity.intercept.method.MethodSecurityInterceptor">
  84. <property name="authenticationManager"><ref bean="authenticationManager"/></property>
  85. <property name="accessDecisionManager"><ref bean="businessAccessDecisionManager"/></property>
  86. <property name="runAsManager"><ref bean="runAsManager"/></property>
  87. <property name="objectDefinitionSource">
  88. <value>
  89. sample.contact.ContactManager.delete=ROLE_SUPERVISOR,RUN_AS_SERVER
  90. sample.contact.ContactManager.getAllByOwner=CONTACT_OWNED_BY_CURRENT_USER,RUN_AS_SERVER
  91. sample.contact.ContactManager.save=CONTACT_OWNED_BY_CURRENT_USER,RUN_AS_SERVER
  92. sample.contact.ContactManager.getById=ROLE_TELLER,RUN_AS_SERVER
  93. </value>
  94. </property>
  95. </bean>
  96. <!-- We expect all callers of the backend object to hold the role ROLE_RUN_AS_SERVER -->
  97. <bean id="backendContactManagerSecurity" class="net.sf.acegisecurity.intercept.method.MethodSecurityInterceptor">
  98. <property name="authenticationManager"><ref bean="authenticationManager"/></property>
  99. <property name="accessDecisionManager"><ref bean="businessAccessDecisionManager"/></property>
  100. <property name="runAsManager"><ref bean="runAsManager"/></property>
  101. <property name="objectDefinitionSource">
  102. <value>
  103. sample.contact.ContactManager.delete=ROLE_RUN_AS_SERVER
  104. sample.contact.ContactManager.getAllByOwner=ROLE_RUN_AS_SERVER
  105. sample.contact.ContactManager.save=ROLE_RUN_AS_SERVER
  106. sample.contact.ContactManager.getById=ROLE_RUN_AS_SERVER
  107. </value>
  108. </property>
  109. </bean>
  110. <!-- ======================= BUSINESS DEFINITIONS ===================== -->
  111. <bean id="contactManager" class="org.springframework.aop.framework.ProxyFactoryBean">
  112. <property name="proxyInterfaces"><value>sample.contact.ContactManager</value></property>
  113. <property name="interceptorNames">
  114. <list>
  115. <value>publicContactManagerSecurity</value>
  116. <value>publicContactManagerTarget</value>
  117. </list>
  118. </property>
  119. </bean>
  120. <bean id="publicContactManagerTarget" class="sample.contact.ContactManagerFacade">
  121. <property name="backend"><ref bean="backendContactManager"/></property>
  122. </bean>
  123. <bean id="backendContactManager" class="org.springframework.aop.framework.ProxyFactoryBean">
  124. <property name="proxyInterfaces"><value>sample.contact.ContactManager</value></property>
  125. <property name="interceptorNames">
  126. <list>
  127. <value>backendContactManagerSecurity</value>
  128. <value>backendContactManagerTarget</value>
  129. </list>
  130. </property>
  131. </bean>
  132. <bean id="backendContactManagerTarget" class="sample.contact.ContactManagerBackend"/>
  133. <!-- ===================== HTTP REQUEST SECURITY ==================== -->
  134. <bean id="casProcessingFilter" class="net.sf.acegisecurity.ui.cas.CasProcessingFilter">
  135. <property name="authenticationManager"><ref bean="authenticationManager"/></property>
  136. <property name="authenticationFailureUrl"><value>/casfailed.jsp</value></property>
  137. <property name="defaultTargetUrl"><value>/</value></property>
  138. <property name="filterProcessesUrl"><value>/j_acegi_cas_security_check</value></property>
  139. </bean>
  140. <bean id="securityEnforcementFilter" class="net.sf.acegisecurity.intercept.web.SecurityEnforcementFilter">
  141. <property name="filterSecurityInterceptor"><ref bean="filterInvocationInterceptor"/></property>
  142. <property name="authenticationEntryPoint"><ref bean="casProcessingFilterEntryPoint"/></property>
  143. </bean>
  144. <bean id="casProcessingFilterEntryPoint" class="net.sf.acegisecurity.ui.cas.CasProcessingFilterEntryPoint">
  145. <property name="loginUrl"><value>https://localhost:8443/cas/login</value></property>
  146. <property name="serviceProperties"><ref bean="serviceProperties"/></property>
  147. </bean>
  148. <bean id="httpRequestAccessDecisionManager" class="net.sf.acegisecurity.vote.AffirmativeBased">
  149. <property name="allowIfAllAbstainDecisions"><value>false</value></property>
  150. <property name="decisionVoters">
  151. <list>
  152. <ref bean="roleVoter"/>
  153. </list>
  154. </property>
  155. </bean>
  156. <!-- Note the order that entries are placed against the objectDefinitionSource is critical.
  157. The FilterSecurityInterceptor will work from the top of the list down to the FIRST pattern that matches the request URL.
  158. Accordingly, you should place MOST SPECIFIC (ie a/b/c/d.*) expressions first, with LEAST SPECIFIC (ie a/.*) expressions last -->
  159. <bean id="filterInvocationInterceptor" class="net.sf.acegisecurity.intercept.web.FilterSecurityInterceptor">
  160. <property name="authenticationManager"><ref bean="authenticationManager"/></property>
  161. <property name="accessDecisionManager"><ref bean="httpRequestAccessDecisionManager"/></property>
  162. <property name="runAsManager"><ref bean="runAsManager"/></property>
  163. <property name="objectDefinitionSource">
  164. <value>
  165. CONVERT_URL_TO_LOWERCASE_BEFORE_COMPARISON
  166. \A/secure/super.*\Z=ROLE_WE_DONT_HAVE
  167. \A/secure/.*\Z=ROLE_SUPERVISOR,ROLE_TELLER
  168. </value>
  169. </property>
  170. </bean>
  171. <!-- BASIC Regular Expression Syntax (for beginners):
  172. \A means the start of the string (ie the beginning of the URL)
  173. \Z means the end of the string (ie the end of the URL)
  174. . means any single character
  175. * means null or any number of repetitions of the last expression (so .* means zero or more characters)
  176. Some examples:
  177. Expression: \A/my/directory/.*\Z
  178. Would match: /my/directory/
  179. /my/directory/hello.html
  180. Expression: \A/.*\Z
  181. Would match: /hello.html
  182. /
  183. Expression: \A/.*/secret.html\Z
  184. Would match: /some/directory/secret.html
  185. /another/secret.html
  186. Not match: /anothersecret.html (missing required /)
  187. -->
  188. </beans>