applicationContext-acegi-security.xml 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  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. - A simple "base bones" Acegi Security configuration.
  5. -
  6. - The sample includes the "popular" features that people tend to use.
  7. - Specifically, form authentication, remember-me, and anonymous processing.
  8. - Other features aren't setup, as these can be added later by inserting
  9. - the relevant XML fragments as specified in the Reference Guide.
  10. -
  11. - To assist new users, the filters specified in the FilterChainProxy are
  12. - declared in the application context in the same order. Collaborators
  13. - required by those filters are placed at the end of the file.
  14. -
  15. - $Id$
  16. -->
  17. <beans>
  18. <bean id="filterChainProxy" class="org.springframework.security.util.FilterChainProxy">
  19. <property name="filterInvocationDefinitionSource">
  20. <value><![CDATA[
  21. CONVERT_URL_TO_LOWERCASE_BEFORE_COMPARISON
  22. PATTERN_TYPE_APACHE_ANT
  23. /**=httpSessionContextIntegrationFilter,logoutFilter,authenticationProcessingFilter,basicProcessingFilter,securityContextHolderAwareRequestFilter,rememberMeProcessingFilter,anonymousProcessingFilter,exceptionTranslationFilter,filterInvocationInterceptor
  24. ]]></value>
  25. </property>
  26. </bean>
  27. <bean id="httpSessionContextIntegrationFilter" class="org.springframework.security.context.HttpSessionContextIntegrationFilter"/>
  28. <bean id="logoutFilter" class="org.springframework.security.ui.logout.LogoutFilter">
  29. <constructor-arg value="/index.jsp"/> <!-- URL redirected to after logout -->
  30. <constructor-arg>
  31. <list>
  32. <ref bean="rememberMeServices"/>
  33. <bean class="org.springframework.security.ui.logout.SecurityContextLogoutHandler"/>
  34. </list>
  35. </constructor-arg>
  36. </bean>
  37. <bean id="authenticationProcessingFilter" class="org.springframework.security.ui.webapp.AuthenticationProcessingFilter">
  38. <property name="authenticationManager" ref="authenticationManager"/>
  39. <property name="authenticationFailureUrl" value="/acegilogin.jsp?login_error=1"/>
  40. <property name="defaultTargetUrl" value="/"/>
  41. <property name="filterProcessesUrl" value="/j_spring_security_check"/>
  42. <property name="rememberMeServices" ref="rememberMeServices"/>
  43. </bean>
  44. <bean id="basicProcessingFilter" class="org.springframework.security.ui.basicauth.BasicProcessingFilter">
  45. <property name="authenticationManager"><ref local="authenticationManager"/></property>
  46. <property name="authenticationEntryPoint"><ref local="basicProcessingFilterEntryPoint"/></property>
  47. </bean>
  48. <bean id="basicProcessingFilterEntryPoint" class="org.springframework.security.ui.basicauth.BasicProcessingFilterEntryPoint">
  49. <property name="realmName"><value>My Realm</value></property>
  50. </bean>
  51. <bean id="securityContextHolderAwareRequestFilter" class="org.springframework.security.wrapper.SecurityContextHolderAwareRequestFilter"/>
  52. <bean id="rememberMeProcessingFilter" class="org.springframework.security.ui.rememberme.RememberMeProcessingFilter">
  53. <property name="authenticationManager" ref="authenticationManager"/>
  54. <property name="rememberMeServices" ref="rememberMeServices"/>
  55. </bean>
  56. <bean id="anonymousProcessingFilter" class="org.springframework.security.providers.anonymous.AnonymousProcessingFilter">
  57. <property name="key" value="changeThis"/>
  58. <property name="userAttribute" value="anonymousUser,ROLE_ANONYMOUS"/>
  59. </bean>
  60. <bean id="exceptionTranslationFilter" class="org.springframework.security.ui.ExceptionTranslationFilter">
  61. <property name="authenticationEntryPoint">
  62. <bean class="org.springframework.security.ui.webapp.AuthenticationProcessingFilterEntryPoint">
  63. <property name="loginFormUrl" value="/acegilogin.jsp"/>
  64. <property name="forceHttps" value="false"/>
  65. </bean>
  66. </property>
  67. <property name="accessDeniedHandler">
  68. <bean class="org.springframework.security.ui.AccessDeniedHandlerImpl">
  69. <property name="errorPage" value="/accessDenied.jsp"/>
  70. </bean>
  71. </property>
  72. </bean>
  73. <bean id="filterInvocationInterceptor" class="org.springframework.security.intercept.web.FilterSecurityInterceptor">
  74. <property name="authenticationManager" ref="authenticationManager"/>
  75. <property name="accessDecisionManager">
  76. <bean class="org.springframework.security.vote.AffirmativeBased">
  77. <property name="allowIfAllAbstainDecisions" value="false"/>
  78. <property name="decisionVoters">
  79. <list>
  80. <bean class="org.springframework.security.vote.RoleVoter"/>
  81. <bean class="org.springframework.security.vote.AuthenticatedVoter"/>
  82. </list>
  83. </property>
  84. </bean>
  85. </property>
  86. <property name="objectDefinitionSource">
  87. <value><![CDATA[
  88. CONVERT_URL_TO_LOWERCASE_BEFORE_COMPARISON
  89. PATTERN_TYPE_APACHE_ANT
  90. /secure/extreme/**=ROLE_SUPERVISOR
  91. /secure/**=IS_AUTHENTICATED_REMEMBERED
  92. /**=IS_AUTHENTICATED_ANONYMOUSLY
  93. ]]></value>
  94. </property>
  95. </bean>
  96. <bean id="rememberMeServices" class="org.springframework.security.ui.rememberme.TokenBasedRememberMeServices">
  97. <property name="userDetailsService" ref="userDetailsService"/>
  98. <property name="key" value="changeThis"/>
  99. </bean>
  100. <bean id="authenticationManager" class="org.springframework.security.providers.ProviderManager">
  101. <property name="providers">
  102. <list>
  103. <ref local="daoAuthenticationProvider"/>
  104. <bean class="org.springframework.security.providers.anonymous.AnonymousAuthenticationProvider">
  105. <property name="key" value="changeThis"/>
  106. </bean>
  107. <bean class="org.springframework.security.providers.rememberme.RememberMeAuthenticationProvider">
  108. <property name="key" value="changeThis"/>
  109. </bean>
  110. </list>
  111. </property>
  112. </bean>
  113. <bean id="daoAuthenticationProvider" class="org.springframework.security.providers.dao.DaoAuthenticationProvider">
  114. <property name="userDetailsService" ref="userDetailsService"/>
  115. </bean>
  116. <!-- UserDetailsService is the most commonly frequently Acegi Security interface implemented by end users -->
  117. <bean id="userDetailsService" class="org.springframework.security.userdetails.memory.InMemoryDaoImpl">
  118. <property name="userProperties">
  119. <bean class="org.springframework.beans.factory.config.PropertiesFactoryBean">
  120. <property name="location" value="/WEB-INF/users.properties"/>
  121. </bean>
  122. </property>
  123. </bean>
  124. <!-- This bean is optional; it isn't used by any other bean as it only listens and logs -->
  125. <bean id="loggerListener" class="org.springframework.security.event.authentication.LoggerListener"/>
  126. </beans>