Skip to content

Instantly share code, notes, and snippets.

@serac
Created February 2, 2013 13:49
Show Gist options
  • Save serac/4697454 to your computer and use it in GitHub Desktop.
Save serac/4697454 to your computer and use it in GitHub Desktop.
Spring Wiring Example for cas-server-integration-ldaptive Components
<bean id="ldapAuthHandler"
class="edu.vt.middleware.cas.authentication.handler.LdapAuthenticationHandler">
<constructor-arg>
<bean id="authenticator" class="org.ldaptive.auth.Authenticator">
<!-- Define the strategy for resolving DNs from the CAS username. -->
<constructor-arg>
<bean class="org.ldaptive.auth.PooledSearchDnResolver"
p:baseDn="${ldap.baseDn}"
p:allowMultipleDns="false"
p:connectionFactory-ref="pooledLdapConnectionFactory"
p:userFilter="authId={user}" />
</constructor-arg>
<!-- Define the source of LDAP connections used for authentication. -->
<constructor-arg>
<bean class="org.ldaptive.auth.PooledBindAuthenticationHandler"
p:connectionFactory-ref="pooledLdapConnectionFactory" />
</constructor-arg>
</bean>
</constructor-arg>
</bean>
<bean id="jndiProvider" class="org.ldaptive.provider.jndi.JndiProvider">
<property name="providerConfig">
<bean class="org.ldaptive.provider.jndi.JndiProviderConfig">
<property name="environment">
<map>
<entry key="java.naming.factory.initial" value="com.sun.jndi.ldap.LdapCtxFactory" />
</map>
</property>
</bean>
</property>
</bean>
<bean id="ldapConnectionConfig" class="org.ldaptive.ConnectionConfig"
p:ldapUrl="${ldapPurl}"
p:connectTimeout="${ldap.connectTimeout}"
p:useStartTLS="${ldap.useStartTLS}" />
<bean id="ldapConnectionFactory" class="org.ldaptive.DefaultConnectionFactory"
p:connectionConfig-ref="ldapConnectionConfig"
p:provider-ref="jndiProvider" />
<bean id="ldapPoolConfig" class="org.ldaptive.pool.PoolConfig"
p:minPoolSize="${ldap.pool.minSize}"
p:maxPoolSize="${ldap.pool.maxSize}"
p:validateOnCheckOut="${ldap.pool.validateOnCheckout}"
p:validatePeriodically="${ldap.pool.validatePeriodically}"
p:validatePeriod="${ldap.pool.validatePeriod}" />
<bean id="searchValidator" class="org.ldaptive.pool.SearchValidator" />
<bean id="pruneStrategy" class="org.ldaptive.pool.IdlePruneStrategy"
p:prunePeriod="${ldap.pool.prunePeriod}"
p:idleTime="${ldap.pool.idleTime}" />
<bean id="ldapConnectionPool" class="org.ldaptive.pool.BlockingConnectionPool"
init-method="initialize"
p:connectionFactory-ref="ldapConnectionFactory"
p:poolConfig-ref="ldapPoolConfig"
p:blockWaitTime="${ldap.pool.blockWaitTime}"
p:validator-ref="searchValidator"
p:pruneStrategy-ref="pruneStrategy"/>
<bean id="pooledLdapConnectionFactory" class="org.ldaptive.pool.PooledConnectionFactory"
p:connectionPool-ref="ldapConnectionPool" />
@bemosior
Copy link

bemosior commented Feb 3, 2013

Thanks! I'll take a look at this tomorrow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment