applicationContext-acegi-security.xml 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  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 containing authentication, channel
  5. - security and web URI beans.
  6. -
  7. - Only used by "cas" artifact.
  8. -
  9. - $Id$
  10. -->
  11. <beans>
  12. <!-- ======================== AUTHENTICATION ======================= -->
  13. <bean id="authenticationManager" class="net.sf.acegisecurity.providers.ProviderManager">
  14. <property name="providers">
  15. <list>
  16. <ref local="casAuthenticationProvider"/>
  17. </list>
  18. </property>
  19. </bean>
  20. <bean id="jdbcDaoImpl" class="net.sf.acegisecurity.providers.dao.jdbc.JdbcDaoImpl">
  21. <property name="dataSource"><ref bean="dataSource"/></property>
  22. </bean>
  23. <bean id="basicProcessingFilter" class="net.sf.acegisecurity.ui.basicauth.BasicProcessingFilter">
  24. <property name="authenticationManager"><ref local="authenticationManager"/></property>
  25. <property name="authenticationEntryPoint"><ref local="basicProcessingFilterEntryPoint"/></property>
  26. </bean>
  27. <bean id="basicProcessingFilterEntryPoint" class="net.sf.acegisecurity.ui.basicauth.BasicProcessingFilterEntryPoint">
  28. <property name="realmName"><value>Contacts Realm</value></property>
  29. </bean>
  30. <bean id="httpSessionIntegrationFilter" class="net.sf.acegisecurity.ui.webapp.HttpSessionIntegrationFilter"/>
  31. <bean id="casAuthenticationProvider" class="net.sf.acegisecurity.providers.cas.CasAuthenticationProvider">
  32. <property name="casAuthoritiesPopulator"><ref local="casAuthoritiesPopulator"/></property>
  33. <property name="casProxyDecider"><ref local="casProxyDecider"/></property>
  34. <property name="ticketValidator"><ref local="casProxyTicketValidator"/></property>
  35. <property name="statelessTicketCache"><ref local="statelessTicketCache"/></property>
  36. <property name="key"><value>my_password_for_this_auth_provider_only</value></property>
  37. </bean>
  38. <bean id="casProxyTicketValidator" class="net.sf.acegisecurity.providers.cas.ticketvalidator.CasProxyTicketValidator">
  39. <property name="casValidate"><value>https://localhost:8443/cas/proxyValidate</value></property>
  40. <property name="proxyCallbackUrl"><value>https://localhost:8443/contacts-cas/casProxy/receptor</value></property>
  41. <property name="serviceProperties"><ref local="serviceProperties"/></property>
  42. <!-- <property name="trustStore"><value>/some/path/to/your/lib/security/cacerts</value></property> -->
  43. </bean>
  44. <bean id="cacheManager" class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean"/>
  45. <bean id="ticketCacheBackend" class="org.springframework.cache.ehcache.EhCacheFactoryBean">
  46. <property name="cacheManager">
  47. <ref local="cacheManager"/>
  48. </property>
  49. <property name="cacheName">
  50. <value>ticketCache</value>
  51. </property>
  52. </bean>
  53. <bean id="statelessTicketCache" class="net.sf.acegisecurity.providers.cas.cache.EhCacheBasedTicketCache">
  54. <property name="cache"><ref local="ticketCacheBackend"/></property>
  55. </bean>
  56. <bean id="casAuthoritiesPopulator" class="net.sf.acegisecurity.providers.cas.populator.DaoCasAuthoritiesPopulator">
  57. <property name="authenticationDao"><ref local="jdbcDaoImpl"/></property>
  58. </bean>
  59. <bean id="casProxyDecider" class="net.sf.acegisecurity.providers.cas.proxy.RejectProxyTickets">
  60. </bean>
  61. <bean id="serviceProperties" class="net.sf.acegisecurity.ui.cas.ServiceProperties">
  62. <property name="service"><value>https://localhost:8443/contacts-cas/j_acegi_cas_security_check</value></property>
  63. <property name="sendRenew"><value>false</value></property>
  64. </bean>
  65. <!-- ===================== HTTP CHANNEL REQUIREMENTS ==================== -->
  66. <!-- Enabled by default for CAS, as a CAS deployment uses HTTPS -->
  67. <bean id="channelProcessingFilter" class="net.sf.acegisecurity.securechannel.ChannelProcessingFilter">
  68. <property name="channelDecisionManager"><ref local="channelDecisionManager"/></property>
  69. <property name="filterInvocationDefinitionSource">
  70. <value>
  71. CONVERT_URL_TO_LOWERCASE_BEFORE_COMPARISON
  72. \A/secure/.*\Z=REQUIRES_SECURE_CHANNEL
  73. \A/j_acegi_cas_security_check.*\Z=REQUIRES_SECURE_CHANNEL
  74. \A.*\Z=REQUIRES_INSECURE_CHANNEL
  75. </value>
  76. </property>
  77. </bean>
  78. <bean id="channelDecisionManager" class="net.sf.acegisecurity.securechannel.ChannelDecisionManagerImpl">
  79. <property name="channelProcessors">
  80. <list>
  81. <ref local="secureChannelProcessor"/>
  82. <ref local="insecureChannelProcessor"/>
  83. </list>
  84. </property>
  85. </bean>
  86. <bean id="secureChannelProcessor" class="net.sf.acegisecurity.securechannel.SecureChannelProcessor"/>
  87. <bean id="insecureChannelProcessor" class="net.sf.acegisecurity.securechannel.InsecureChannelProcessor"/>
  88. <!-- ===================== HTTP REQUEST SECURITY ==================== -->
  89. <bean id="securityEnforcementFilter" class="net.sf.acegisecurity.intercept.web.SecurityEnforcementFilter">
  90. <property name="filterSecurityInterceptor"><ref local="filterInvocationInterceptor"/></property>
  91. <property name="authenticationEntryPoint"><ref local="casProcessingFilterEntryPoint"/></property>
  92. </bean>
  93. <bean id="casProcessingFilter" class="net.sf.acegisecurity.ui.cas.CasProcessingFilter">
  94. <property name="authenticationManager"><ref local="authenticationManager"/></property>
  95. <property name="authenticationFailureUrl"><value>/casfailed.jsp</value></property>
  96. <property name="defaultTargetUrl"><value>/</value></property>
  97. <property name="filterProcessesUrl"><value>/j_acegi_cas_security_check</value></property>
  98. </bean>
  99. <bean id="casProcessingFilterEntryPoint" class="net.sf.acegisecurity.ui.cas.CasProcessingFilterEntryPoint">
  100. <property name="loginUrl"><value>https://localhost:8443/cas/login</value></property>
  101. <property name="serviceProperties"><ref local="serviceProperties"/></property>
  102. </bean>
  103. <bean id="httpRequestAccessDecisionManager" class="net.sf.acegisecurity.vote.AffirmativeBased">
  104. <property name="allowIfAllAbstainDecisions"><value>false</value></property>
  105. <property name="decisionVoters">
  106. <list>
  107. <ref bean="roleVoter"/>
  108. </list>
  109. </property>
  110. </bean>
  111. <!-- Note the order that entries are placed against the objectDefinitionSource is critical.
  112. The FilterSecurityInterceptor will work from the top of the list down to the FIRST pattern that matches the request URL.
  113. Accordingly, you should place MOST SPECIFIC (ie a/b/c/d.*) expressions first, with LEAST SPECIFIC (ie a/.*) expressions last -->
  114. <bean id="filterInvocationInterceptor" class="net.sf.acegisecurity.intercept.web.FilterSecurityInterceptor">
  115. <property name="authenticationManager"><ref local="authenticationManager"/></property>
  116. <property name="accessDecisionManager"><ref local="httpRequestAccessDecisionManager"/></property>
  117. <property name="objectDefinitionSource">
  118. <value>
  119. CONVERT_URL_TO_LOWERCASE_BEFORE_COMPARISON
  120. \A/secure/super.*\Z=ROLE_WE_DONT_HAVE
  121. \A/secure/.*\Z=ROLE_SUPERVISOR,ROLE_TELLER
  122. </value>
  123. </property>
  124. </bean>
  125. <!-- BASIC Regular Expression Syntax (for beginners):
  126. \A means the start of the string (ie the beginning of the URL)
  127. \Z means the end of the string (ie the end of the URL)
  128. . means any single character
  129. * means null or any number of repetitions of the last expression (so .* means zero or more characters)
  130. Some examples:
  131. Expression: \A/my/directory/.*\Z
  132. Would match: /my/directory/
  133. /my/directory/hello.html
  134. Expression: \A/.*\Z
  135. Would match: /hello.html
  136. /
  137. Expression: \A/.*/secret.html\Z
  138. Would match: /some/directory/secret.html
  139. /another/secret.html
  140. Not match: /anothersecret.html (missing required /)
  141. -->
  142. </beans>