<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xmlns:security="http://www.springframework.org/schema/security"
	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
		http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security.xsd">

	<!-- LDAP -->
	
	<!-- embedded server only for testing -->
	<security:ldap-server root="dc=bukova,dc=info" ldif="classpath:users.ldif" port="3089"/>
	
	<security:authentication-manager>
		<security:authentication-provider ref="ldapAuthProvider"/>
	</security:authentication-manager>
	
	<bean id="contextSource" class="org.springframework.security.ldap.DefaultSpringSecurityContextSource">
		<constructor-arg value="${ldap.server}"/>
	</bean>
	
	<bean id="authenticator" class="org.springframework.security.ldap.authentication.BindAuthenticator">
		<constructor-arg ref="contextSource"/>
		<property name="userDnPatterns" value="#{'${ldap.userDNPattern}'.split(';')}"/>
	</bean>

	<bean id="populator" class="info.bukova.isspst.security.AuthPopulator">
		<constructor-arg>
		 	<ref local="userService"/>
		 </constructor-arg>
		 <constructor-arg>
		 	<ref local="roleService"/>
		 </constructor-arg>
	</bean>
	
	<bean id="ldapAuthProvider"
		class="org.springframework.security.ldap.authentication.LdapAuthenticationProvider">
			<constructor-arg ref="authenticator"/>
	        <constructor-arg ref="populator"/>
	</bean>


</beans>
