<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd" >
<beans>
    <bean id="userDetailsService" class="org.springframework.security.core.userdetails.memory.InMemoryDaoImpl">
      <property name="userMap">
        <value>
          blueuser=password,ROLE_BASIC,LABEL_BLUE
          superuser=password2,ROLE_BASIC,LABEL_SHARED
          orangeuser=password3,ROLE_BASIC,LABEL_ORANGE
          multiuser=password4,ROLE_BASIC,LABEL_BLUE,LABEL_ORANGE
        </value>
      </property>
    </bean>

    <bean id="daoAuthenticationProvider" class="org.springframework.security.authentication.dao.DaoAuthenticationProvider">
      <property name="userDetailsService"><ref bean="userDetailsService"/></property>
    </bean>

    <bean id="authenticationManager" class="org.springframework.security.authentication.ProviderManager">
      <property name="providers">
        <list>
          <ref local="daoAuthenticationProvider"/>
        </list>
      </property>
    </bean>

    <bean id="accessDecisionManager" class="org.springframework.security.access.vote.UnanimousBased">
        <property name="allowIfAllAbstainDecisions"><value>false</value></property>
        <property name="decisionVoters">
            <list>
                <bean class="org.springframework.security.access.vote.RoleVoter"/>
                <bean class="org.springframework.security.access.vote.LabelBasedAclVoter">
                    <property name="attributeIndicatingLabeledOperation"><value>LABELED_OPERATION</value></property>
                    <property name="labelMap">
                        <map>
                            <entry key="LABEL_BLUE">
                                <list>
                                    <value>blue</value>
                                    <value>blue-orange</value>
                                </list>
                            </entry>
                            <entry key="LABEL_ORANGE">
                                <list>
                                    <value>orange</value>
                                    <value>blue-orange</value>
                                </list>
                            </entry>
                            <entry key="LABEL_SHARED">
                                <list>
                                    <value>blue</value>
                                    <value>orange</value>
                                    <value>blue-orange</value>
                                </list>
                            </entry>
                        </map>
                    </property>
                </bean>
            </list>
        </property>
    </bean>

    <bean id="securityInteceptor"
        class="org.springframework.security.access.intercept.aopalliance.MethodSecurityInterceptor">
      <property name="validateConfigAttributes"><value>false</value></property>
      <property name="authenticationManager"><ref bean="authenticationManager"/></property>
      <property name="accessDecisionManager"><ref bean="accessDecisionManager"/></property>
      <property name="securityMetadataSource">
        <value>
            org.springframework.security.access.vote.SampleService.get*=ROLE_BASIC
            org.springframework.security.access.vote.SampleService.do*=ROLE_BASIC,LABELED_OPERATION
        </value>
      </property>
    </bean>

    <bean id="perfOfSecurity" class="org.springframework.aop.interceptor.PerformanceMonitorInterceptor">
        <property name="prefix"><value>Security: </value></property>
    </bean>

    <bean id="sampleService" class="org.springframework.security.access.vote.SampleServiceImpl"/>

     <bean class="org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator">
      <property name="beanNames"><value>sampleService</value></property>
      <property name="interceptorNames">
        <list>
          <value>perfOfSecurity</value>
          <value>securityInteceptor</value>
        </list>
      </property>
    </bean>

</beans>
