<?xml version="1.0" encoding="UTF-8"?>

<b:beans xmlns="http://www.springframework.org/schema/security"
	xmlns:b="http://www.springframework.org/schema/beans"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans.xsd
	http://www.springframework.org/schema/security https://www.springframework.org/schema/security/spring-security.xsd">

	<http pattern="/_ah/**" security="none"/>
	<http pattern="/static/**" security="none" />
	<http pattern="/favicon.ico" security="none" />
	<http pattern="/loggedout.htm" security="none" />
	<http pattern="/disabled.htm" security="none" />

	<http use-expressions="true" entry-point-ref="gaeEntryPoint">
		<intercept-url pattern="/" access="permitAll" />
		<intercept-url pattern="/logout.htm" access="permitAll" />
		<intercept-url pattern="/register.htm*" access="hasRole('NEW_USER')" />
		<intercept-url pattern="/**" access="hasRole('USER')" />
		<custom-filter position="PRE_AUTH_FILTER" ref="gaeFilter" />
	</http>

	<b:bean id="gaeEntryPoint" class="samples.gae.security.GoogleAccountsAuthenticationEntryPoint" />

	<b:bean id="gaeFilter" class="samples.gae.security.GaeAuthenticationFilter">
		<b:property name="authenticationManager" ref="authenticationManager"/>
		<b:property name="failureHandler">
			<b:bean class="org.springframework.security.web.authentication.ExceptionMappingAuthenticationFailureHandler">
				<b:property name="exceptionMappings">
					<b:map>
						<b:entry key="org.springframework.security.authentication.DisabledException" value="/disabled.htm" />
					</b:map>
				</b:property>
			</b:bean>
		</b:property>
	</b:bean>

	<authentication-manager alias="authenticationManager">
		<authentication-provider ref="gaeAuthenticationProvider"/>
	</authentication-manager>

	<b:bean id="gaeAuthenticationProvider" class="samples.gae.security.GoogleAccountsAuthenticationProvider">
		<b:property name="userRegistry" ref="userRegistry" />
	</b:bean>

	<b:bean id="userRegistry" class="samples.gae.users.GaeDatastoreUserRegistry" />

</b:beans>
