applicationContext-annotations.xml 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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. * Copyright 2004 Acegi Technology Pty Limited
  5. *
  6. * Licensed under the Apache License, Version 2.0 (the "License");
  7. * you may not use this file except in compliance with the License.
  8. * You may obtain a copy of the License at
  9. *
  10. * http://www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing, software
  13. * distributed under the License is distributed on an "AS IS" BASIS,
  14. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. * See the License for the specific language governing permissions and
  16. * limitations under the License.
  17. *
  18. *
  19. * $Id$
  20. -->
  21. <beans>
  22. <!-- =================== SECURITY SYSTEM DEFINITIONS ================== -->
  23. <!-- RunAsManager -->
  24. <bean id="runAsManager" class="org.springframework.security.runas.RunAsManagerImpl">
  25. <property name="key"><value>my_run_as_password</value></property>
  26. </bean>
  27. <!-- ~~~~~~~~~~~~~~~~~~~~ AUTHENTICATION DEFINITIONS ~~~~~~~~~~~~~~~~~~ -->
  28. <!-- This authentication provider accepts any presented TestingAuthenticationToken -->
  29. <bean id="testingAuthenticationProvider" class="org.springframework.security.providers.TestingAuthenticationProvider"/>
  30. <!-- The authentication manager that iterates through our only authentication provider -->
  31. <bean id="authenticationManager" class="org.springframework.security.providers.ProviderManager">
  32. <property name="providers">
  33. <list>
  34. <ref local="testingAuthenticationProvider"/>
  35. </list>
  36. </property>
  37. </bean>
  38. <!-- ~~~~~~~~~~~~~~~~~~~~ AUTHORIZATION DEFINITIONS ~~~~~~~~~~~~~~~~~~~ -->
  39. <!-- An access decision voter that reads ROLE_* configuaration settings -->
  40. <bean id="roleVoter" class="org.springframework.security.vote.RoleVoter"/>
  41. <!-- A unanimous access decision manager -->
  42. <bean id="accessDecisionManager" class="org.springframework.security.vote.UnanimousBased">
  43. <property name="allowIfAllAbstainDecisions"><value>false</value></property>
  44. <property name="decisionVoters">
  45. <list>
  46. <ref local="roleVoter"/>
  47. </list>
  48. </property>
  49. </bean>
  50. <!-- ===================== SECURITY DEFINITIONS ======================= -->
  51. <bean id="attributes" class="org.springframework.security.annotation.SecurityAnnotationAttributes"/>
  52. <bean id="objectDefinitionSource" class="org.springframework.security.intercept.method.MethodDefinitionAttributes">
  53. <property name="attributes"><ref local="attributes"/></property>
  54. </bean>
  55. <!-- We don't validate config attributes, as it's unsupported by MethodDefinitionAttributes -->
  56. <bean id="securityInterceptor" class="org.springframework.security.intercept.method.aopalliance.MethodSecurityInterceptor">
  57. <property name="validateConfigAttributes"><value>false</value></property>
  58. <property name="authenticationManager"><ref local="authenticationManager"/></property>
  59. <property name="accessDecisionManager"><ref local="accessDecisionManager"/></property>
  60. <property name="runAsManager"><ref local="runAsManager"/></property>
  61. <property name="objectDefinitionSource"><ref local="objectDefinitionSource"/></property>
  62. </bean>
  63. <bean id="bankService" class="sample.annotations.BankServiceImpl"/>
  64. <!--
  65. This bean is a postprocessor that will automatically apply relevant advisors
  66. to any bean in child factories.
  67. -->
  68. <bean id="autoproxy"
  69. class="org.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator">
  70. </bean>
  71. <!--
  72. AOP advisor that will automatically wire the MethodSecurityInterceptor (above)
  73. into BankServiceImpl (above). The configuration attributes used are obtained
  74. from the securityInterceptor.objectDefinitionSouce, which in the
  75. above configuration is a JDK 5 Annotations Attributes-based source.
  76. -->
  77. <bean id="methodSecurityAdvisor"
  78. class="org.springframework.security.intercept.method.aopalliance.MethodDefinitionSourceAdvisor"
  79. autowire="constructor" >
  80. </bean>
  81. </beans>