<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
<!--
  Licensed to the Apache Software Foundation (ASF) under one or more
  contributor license agreements.  See the NOTICE file distributed with
  this work for additional information regarding copyright ownership.
  The ASF licenses this file to You under the Apache License, Version 2.0
  (the "License"); you may not use this file except in compliance with
  the License.  You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.
-->
<beans>

  <!-- ************** Security SPI Handlers ************** -->

  <!-- require a non-empty password -->
  <bean id="org.apache.jetspeed.security.spi.CredentialPasswordValidator" 
       class="org.apache.jetspeed.security.spi.impl.DefaultCredentialPasswordValidator"/>

  <!-- MessageDigest encode passwords using SHA-1 -->
  <bean id="org.apache.jetspeed.security.spi.CredentialPasswordEncoder" 
       class="org.apache.jetspeed.security.spi.impl.MessageDigestCredentialPasswordEncoder">
       <constructor-arg index="0"><value>SHA-1</value></constructor-arg>       
  </bean>       

  <bean id="org.apache.jetspeed.security.spi.PasswordCredentialProvider" 
       class="org.apache.jetspeed.security.spi.impl.DefaultPasswordCredentialProvider">
       <constructor-arg index="0"><ref bean="org.apache.jetspeed.security.spi.CredentialPasswordValidator"/></constructor-arg>       
       <constructor-arg index="1"><ref bean="org.apache.jetspeed.security.spi.CredentialPasswordEncoder"/></constructor-arg>       
  </bean>       

  <!-- allow multiple InternalPasswordCredentialInterceptors to be used for DefaultCredentialHandler --> 
  <bean id="org.apache.jetspeed.security.spi.InternalPasswordCredentialInterceptor"
       class="org.apache.jetspeed.security.spi.impl.InternalPasswordCredentialInterceptorsProxy">
       <constructor-arg index="0">
         <list>
           <!-- enforce an invalid preset password value in the persisent store is required to be changed -->
           <bean class="org.apache.jetspeed.security.spi.impl.ValidatePasswordOnLoadInterceptor"/>

           <!-- ensure preset cleartext passwords in the persistent store  will be encoded on first use -->
           <bean class="org.apache.jetspeed.security.spi.impl.EncodePasswordOnFirstLoadInterceptor"/>
         </list>
       </constructor-arg>
  </bean>

  <!-- Security SPI: CredentialHandler -->
  <bean id="org.apache.jetspeed.security.spi.CredentialHandler" 
       class="org.apache.jetspeed.security.spi.impl.DefaultCredentialHandler"
  >       
       <constructor-arg index="0"><ref bean="org.apache.jetspeed.security.spi.SecurityAccess"/></constructor-arg>       
       <constructor-arg index="1"><ref bean="org.apache.jetspeed.security.spi.PasswordCredentialProvider"/></constructor-arg>       
       <constructor-arg index="2"><ref bean="org.apache.jetspeed.security.spi.InternalPasswordCredentialInterceptor"/></constructor-arg>       
  </bean>
  
  <!-- Security SPI: UserSecurityHandler -->
  <!-- The DefaultUSerSecurityHandler uses the raw SecurityAccessImpl so that it
  	   may demarcate its own transactions -->
  <bean id="org.apache.jetspeed.security.spi.UserSecurityHandlerImpl" 
  	   class="org.apache.jetspeed.security.spi.impl.DefaultUserSecurityHandler"
  >  	   
  	   <constructor-arg ><ref bean="org.apache.jetspeed.security.spi.SecurityAccess"/></constructor-arg>  	   
  </bean>
  
  <bean id="org.apache.jetspeed.security.spi.UserSecurityHandler" parent="baseTransactionProxy" 
		name="userSecurityHandler" >
		<property name="proxyInterfaces">
			<value>org.apache.jetspeed.security.spi.UserSecurityHandler</value>
		</property>
		<property name="target">
			<ref bean="org.apache.jetspeed.security.spi.UserSecurityHandlerImpl"/>
		</property>
		<property name="transactionAttributes">
			<props>				
				<prop key="*">PROPAGATION_REQUIRED</prop>
			</props>
		</property>
   </bean>

</beans>
