appContext-security.xml 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!--
  3. - Sample namespace-based configuration
  4. -
  5. - $Id: applicationContext-security-ns.xml 2923 2008-04-12 17:17:46Z luke_t $
  6. -->
  7. <b:beans xmlns="http://www.springframework.org/schema/security"
  8. xmlns:b="http://www.springframework.org/schema/beans"
  9. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  10. xmlns:aop="http://www.springframework.org/schema/aop"
  11. xmlns:context="http://www.springframework.org/schema/context"
  12. xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
  13. http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
  14. http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
  15. http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.0.xsd">
  16. <!--b:import resource="appContext-misc.xml"/-->
  17. <context:component-scan base-package='sample'/>
  18. <global-method-security secured-annotations="enabled" access-decision-manager-ref="methodAccessMgr">
  19. <protect-pointcut expression="execution(* sample.service.UserService+.*(..))"
  20. access="ROLE_LOGGEDIN" />
  21. </global-method-security>
  22. <aop:aspectj-autoproxy/>
  23. <b:bean id="methodAccessMgr" class="org.springframework.security.access.vote.AffirmativeBased">
  24. <b:property name="decisionVoters">
  25. <b:list>
  26. <b:bean class="sample.TestVoter"/>
  27. </b:list>
  28. </b:property>
  29. </b:bean>
  30. <http>
  31. <intercept-url pattern="/secure/extreme/**" access="ROLE_SUPERVISOR"/>
  32. <intercept-url pattern="/secure/**" access="IS_AUTHENTICATED_REMEMBERED" />
  33. <intercept-url pattern="/testMulti.htm*" access="IS_AUTHENTICATED_FULLY" />
  34. <!-- Disable web URI authorization, as we're using <global-method-security> and have @Secured the services layer instead
  35. <intercept-url pattern="/listAccounts.html" access="IS_AUTHENTICATED_REMEMBERED" />
  36. <intercept-url pattern="/post.html" access="ROLE_TELLER" />
  37. -->
  38. <intercept-url pattern="/**" access="IS_AUTHENTICATED_ANONYMOUSLY" />
  39. <!--
  40. Uncomment to enable X509 client authentication support
  41. <x509 user-service-ref="daoUserService"/>
  42. -->
  43. <form-login default-target-url="/secure/index.jsp" login-page="/login.jsp" authentication-failure-url="/login.jsp?login-error=1" always-use-default-target="false"/>
  44. <!-- http-basic / -->
  45. <logout />
  46. <remember-me key='doesntmatter' token-repository-ref='tokenRepo' user-service-ref='daoUserService'/>
  47. <!-- <remember-me user-service-ref="daoUserService"/> -->
  48. <!-- Uncomment to limit the number of sessions a user can have -->
  49. <session-management>
  50. <concurrency-control max-sessions="1" error-if-maximum-exceeded="true" session-registry-ref='sessionRegistry'/>
  51. </session-management>
  52. <!-- custom-filter position="AUTHENTICATION_PROCESSING_FILTER" ref="customAuthFilter" / -->
  53. </http>
  54. <b:bean id='tokenRepo' class='org.springframework.security.web.authentication.rememberme.InMemoryTokenRepositoryImpl'/>
  55. <!-- Traditional Session Control Beans -->
  56. <!--
  57. <b:bean id='sessionControlFilter' class="org.springframework.security.concurrent.ConcurrentSessionFilter">
  58. <custom-filter position="CONCURRENT_SESSION_FILTER"/>
  59. <b:property name="sessionRegistry" ref='sessionRegistry'/>
  60. </b:bean>
  61. -->
  62. <b:bean id='sessionRegistry' class="org.springframework.security.core.session.SessionRegistryImpl"/>
  63. <!--
  64. <b:bean id="customAuthFilter" class="heavyduty.security.ui.HeavyDutyAuthenticationProcessingFilter">
  65. <b:property name="defaultTargetUrl" value="/"/>
  66. <b:property name="authenticationManager" ref="authenticationManager"/>
  67. </b:bean>
  68. <b:bean id="customEntryPoint" class="heavyduty.security.ui.HeavyDutyEntryPoint">
  69. <b:property name="loginFormUrl" value="/login.jsp"/>
  70. </b:bean>
  71. -->
  72. <!--
  73. <b:bean id="loginPageGenerator" class="org.springframework.security.ui.webapp.DefaultLoginPageGeneratingFilter">
  74. <custom-filter after="AUTHENTICATION_PROCESSING_FILTER"/>
  75. <b:constructor-arg ref="customAuthFilter"/>
  76. </b:bean>
  77. -->
  78. <authentication-manager alias="authenticationManager" >
  79. <authentication-provider user-service-ref="daoUserService">
  80. <password-encoder hash="md5" />
  81. </authentication-provider>
  82. <authentication-provider>
  83. <password-encoder hash="md5"/>
  84. <user-service>
  85. <user name="rod" password="a564de63c2d0da68cf47586ee05984d7" authorities="ROLE_SUPERVISOR, ROLE_USER, ROLE_TELLER" />
  86. <user name="dianne" password="65d15fe9156f9c4bbffd98085992a44e" authorities="ROLE_USER,ROLE_TELLER" />
  87. <user name="scott" password="2b58af6dddbd072ed27ffc86725d7d3a" authorities="ROLE_USER" />
  88. <user name="peter" password="22b5c9accc6e1ba628cedc63a72d57f8" authorities="ROLE_USER" />
  89. </user-service>
  90. </authentication-provider>
  91. </authentication-manager>
  92. <ldap-server id="ldapServer"/>
  93. <!-- b:bean id="mbeanServer" class="org.springframework.jmx.support.MBeanServerFactoryBean"/ -->
  94. <b:bean id="exporter" class="org.springframework.jmx.export.MBeanExporter">
  95. <b:property name="beans">
  96. <b:map>
  97. <b:entry key="bean:name=ldapContextSource" value-ref="ldapServer"/>
  98. </b:map>
  99. </b:property>
  100. <b:property name="assembler">
  101. <b:bean class="org.springframework.jmx.export.assembler.MethodNameBasedMBeanInfoAssembler">
  102. <b:property name="managedMethods" value="setPassword,setUserDn,getUrls,setUrl,setUrls,setPooled,isPooled,setBase,getBaseLdapPathAsString"/>
  103. </b:bean>
  104. </b:property>
  105. <!-- b:property name="server" ref="mbeanServer"/-->
  106. </b:bean>
  107. </b:beans>