<?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="org.wamblee.security.servlet.SubjectLocator" 
        class="org.wamblee.security.servlet.JBossSubjectLocator">
        <constructor-arg><value>${org.wamblee.photos.realm}</value></constructor-arg>        
    </bean>
    
    <bean id="org.wamblee.security.authorization.OperationRegistry"
        class="org.wamblee.security.authorization.DefaultOperationRegistry">
        <constructor-arg>
            <list>
                <bean class="org.wamblee.security.authorization.AllOperation"/>
                <bean class="org.wamblee.security.authorization.CreateOperation"/>
                <bean class="org.wamblee.security.authorization.DeleteOperation"/>
                <bean class="org.wamblee.security.authorization.ReadOperation"/>
                <bean class="org.wamblee.security.authorization.WriteOperation"/>                
            </list>
        </constructor-arg>
    </bean>
    
    <bean id="org.wamblee.security.authorization.AuthorizationService"
        class="org.wamblee.security.authorization.hibernate.PersistentAuthorizationService">
        <constructor-arg><value>DEFAULT</value></constructor-arg>
        <constructor-arg><ref bean="org.springframework.orm.hibernate3.HibernateTemplate"/></constructor-arg>
        <constructor-arg><ref bean="org.wamblee.usermgt.UserAccessor"/></constructor-arg>
        <constructor-arg><value type="long">10000</value></constructor-arg>
    </bean>
    
    <!-- any user -->
    <bean id="anyUserCondition" class="org.wamblee.security.authorization.AnyUserCondition">
    </bean>
    
    <!-- administrators -->
    <bean id="adminUserCondition" class="org.wamblee.security.authorization.GroupUserCondition">
        <constructor-arg><value>administrators</value></constructor-arg>
    </bean>
    
    <!-- The general rule for access to albums and photos -->
    <bean id="photoEntryRule"
        class="org.wamblee.photos.authorizationrules.PhotoAuthorizationRule">
    </bean>
    
    <!-- Pages that allow access by any authenticated user -->
    <bean id="anyUserPageRule" class="org.wamblee.photos.authorizationrules.PageAuthorizationRule">
        <constructor-arg><value>GRANTED</value></constructor-arg>
        <constructor-arg><ref local="anyUserCondition"/></constructor-arg>
        <constructor-arg>
            <list>
                <value>Home</value>
                <value>Photo</value>
                <value>EditProfile</value>
            </list>
        </constructor-arg>
    </bean>
    
    <!-- Grant access to the admin page to administrators -->
    <bean id="adminPageRule" class="org.wamblee.photos.authorizationrules.PageAuthorizationRule">
        <constructor-arg><value>GRANTED</value></constructor-arg>
        <constructor-arg><ref local="adminUserCondition"/></constructor-arg>
        <constructor-arg><value>Admin</value></constructor-arg>
    </bean>
    
    <bean id="org.wamblee.security.authorization.AuthorizationInitializer"
        class="org.wamblee.security.authorization.AuthorizationInitializer">
        <constructor-arg><ref local="org.wamblee.security.authorization.AuthorizationService"/></constructor-arg>
        <constructor-arg>
            <list>
                <ref local="photoEntryRule"/>
                <ref local="anyUserPageRule"/>
                <ref local="adminPageRule"/>
            </list>
        </constructor-arg>
    </bean>
   
</beans> 