<?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:p="http://www.springframework.org/schema/p"
       xmlns:sec="http://www.springframework.org/schema/security"
       xmlns:tx="http://www.springframework.org/schema/tx"
       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
       http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.0.xsd
       http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd">
	<bean id="authenticationManager"
		class="org.jasig.cas.authentication.AuthenticationManagerImpl">
		<property name="credentialsToPrincipalResolvers">
			<list>
                                <bean class="org.jasig.cas.authentication.principal.CredentialsToLDAPAttributePrincipalResolver">
                                   <property name="credentialsToPrincipalResolver">
                                      <bean class="org.jasig.cas.authentication.principal.UsernamePasswordCredentialsToPrincipalResolver"/>
                                   </property>
                                   <property name="filter" value="(uid=%u)" />
                                   <property name="principalAttributeName" value="uid" />
                                   <property name="searchBase" value="ou=people,dc=ellucian,dc=com" />
                                   <property name="contextSource" ref="contextSource" />
                                   <property name="attributeRepository">
                                      <ref bean="attributeRepository" />
                                   </property>
                               </bean>
			</list>
		</property>
		<property name="authenticationHandlers">
			<list>
				<bean class="org.jasig.cas.authentication.handler.support.HttpBasedServiceCredentialsAuthenticationHandler"
					p:httpClient-ref="httpClient" />
                                <bean class="org.jasig.cas.adaptors.ldap.BindLdapAuthenticationHandler">
                                   <property name="filter" value="uid=%u" />
                                   <property name="searchBase" value="ou=people,dc=ellucian,dc=com" />
                                   <property name="contextSource" ref="contextSource" />
                                   <property name="timeout" value="10" />
                                </bean>
			</list>
		</property>
	</bean>
    <sec:user-service id="userDetailsService">
        <sec:user name="ADMIN" password="ADMIN" authorities="ROLE_ADMIN" />
    </sec:user-service>
        <bean id="attributeRepository"
        class="org.jasig.services.persondir.support.ldap.LdapPersonAttributeDao">
           <property name="contextSource" ref="contextSource" />
           <property name="baseDN" value="ou=people,dc=ellucian,dc=com" />
           <property name="requireAllQueryAttributes" value="true" />
           <property name="queryAttributeMapping">
             <map>
                <entry key="username" value="uid" />
                <!--<entry key="UDC_IDENTIFIER" value="cn" />-->
             </map>
           </property>
           <property name="resultAttributeMapping">
             <map>
                <entry key="cn" value="UDC_IDENTIFIER"/>
                <entry key="uid" value="username" />
                <!--<entry key="udcid" value="UDC_IDENTIFIER" />
				<entry value="UDC_IDENTIFIER" key="cn" />
				<entry value="username" key="uid" />-->
             </map>
           </property>
       </bean>	
       <bean id="contextSource"
       class="org.springframework.ldap.core.support.LdapContextSource">
         <property name="pooled" value="true"/>
         <property name="urls">
            <list>
               <value>ldap://localhost:1389</value>
            </list>
         </property>
         <property name="userDn" value="cn=Manager,dc=ellucian,dc=com"/>
         <property name="password" value="u_pick_it"/>
         <property name="baseEnvironmentProperties">
            <map>
               <entry>
                  <key>
                     <value>java.naming.security.authentication</value>
                  </key>
                  <value>simple</value>
               </entry>
            </map>
        </property>
     </bean>
	<bean id="serviceRegistryDao" class="org.jasig.cas.services.JpaServiceRegistryDaoImpl"
		p:entityManagerFactory-ref="entityManagerFactory" />
	<bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
	  <property name="dataSource" ref="dataSource"/>
	  <property name="jpaVendorAdapter">
	 <bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
		<property name="generateDdl" value="true"/>
		<property name="showSql" value="true" />
	 </bean>
		</property>
		<property name="jpaProperties">
		   <props>
			 <prop key="hibernate.dialect">org.hibernate.dialect.OracleDialect</prop>
		   <prop key="hibernate.hbm2ddl.auto">update</prop>
		   </props>
	   </property>
	</bean>
	<bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
	   <property name="entityManagerFactory" ref="entityManagerFactory"/>
	</bean>
	<tx:annotation-driven transaction-manager="transactionManager"/>
	<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"
	   p:driverClassName="oracle.jdbc.driver.OracleDriver"
	   p:url="jdbc:oracle:thin:@localhost:1521:BAN83" p:username="bansecr" p:password="u_pick_it" />
	<bean id="auditTrailManager" class="com.github.inspektr.audit.support.Slf4jLoggingAuditTrailManager" />
</beans>
