LDAP-267: Minor tweaks to XML namespace support more tests and reference documentation.

This commit is contained in:
Mattias Hellborg Arthursson
2013-10-08 17:02:40 +02:00
parent 795701fd58
commit a16646ca2c
24 changed files with 1034 additions and 523 deletions

View File

@@ -18,22 +18,25 @@ package org.springframework.ldap.config;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.parsing.BeanComponentDefinition;
import org.springframework.beans.factory.support.AbstractBeanDefinition;
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
import org.springframework.beans.factory.xml.AbstractBeanDefinitionParser;
import org.springframework.beans.factory.xml.BeanDefinitionParser;
import org.springframework.beans.factory.xml.ParserContext;
import org.springframework.ldap.CommunicationException;
import org.springframework.ldap.core.support.LdapContextSource;
import org.springframework.ldap.pool.PoolExhaustedAction;
import org.springframework.ldap.pool.factory.PoolingContextSource;
import org.springframework.ldap.pool.validation.DefaultDirContextValidator;
import org.springframework.ldap.transaction.compensating.manager.TransactionAwareContextSourceProxy;
import org.springframework.util.Assert;
import org.springframework.util.ClassUtils;
import org.springframework.util.StringUtils;
import org.springframework.util.xml.DomUtils;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
import static org.springframework.ldap.config.ParserUtils.NAMESPACE;
import java.util.HashSet;
import java.util.Set;
import static org.springframework.ldap.config.ParserUtils.getBoolean;
import static org.springframework.ldap.config.ParserUtils.getInt;
import static org.springframework.ldap.config.ParserUtils.getString;
@@ -43,12 +46,14 @@ import static org.springframework.ldap.config.ParserUtils.getString;
*/
public class ContextSourceParser implements BeanDefinitionParser {
private final static String ATT_ANONYMOUS_READ_ONLY = "anonymous-read-only";
private final static String ATT_AUTHENTICATION_SOURCE_REF = "authentication-source-ref";
private final static String ATT_AUTHENTICATION_STRATEGY_REF = "authentication-strategy-ref";
private final static String ATT_BASE = "base";
private final static String ATT_PASSWORD = "password";
private final static String ATT_NATIVE_POOLING = "native-pooling";
private final static String ATT_REFERRAL = "referral";
private final static String ATT_URL = "url";
private final static String ATT_BASE_ENV_PROPS_REF = "base-env-props-ref";
// pooling attributes
private final static String ATT_MAX_ACTIVE = "max-active";
@@ -66,6 +71,7 @@ public class ContextSourceParser implements BeanDefinitionParser {
private final static String ATT_VALIDATION_QUERY_BASE = "validation-query-base";
private final static String ATT_VALIDATION_QUERY_FILTER = "validation-query-filter";
private final static String ATT_VALIDATION_QUERY_SEARCH_CONTROLS_REF = "validation-query-search-controls-ref";
private final static String ATT_NON_TRANSIENT_EXCEPTIONS = "non-transient-exceptions";
private final static String ATT_USERNAME = "username";
static final String DEFAULT_ID = "contextSource";
@@ -78,8 +84,6 @@ public class ContextSourceParser implements BeanDefinitionParser {
String password = element.getAttribute(ATT_PASSWORD);
String url = element.getAttribute(ATT_URL);
Assert.hasText(username, "username attribute must be specified");
Assert.hasText(password, "password attribute must be specified");
Assert.hasText(url, "url attribute must be specified");
builder.addPropertyValue("userDn", username);
@@ -89,35 +93,60 @@ public class ContextSourceParser implements BeanDefinitionParser {
builder.addPropertyValue("base", getString(element, ATT_BASE, ""));
builder.addPropertyValue("referral", getString(element, ATT_REFERRAL, null));
builder.addPropertyValue("anonymousReadOnly", getBoolean(element, ATT_ANONYMOUS_READ_ONLY, false));
builder.addPropertyValue("pooled", getBoolean(element, ATT_NATIVE_POOLING, false));
boolean anonymousReadOnly = getBoolean(element, ATT_ANONYMOUS_READ_ONLY, false);
builder.addPropertyValue("anonymousReadOnly", anonymousReadOnly);
boolean nativePooling = getBoolean(element, ATT_NATIVE_POOLING, false);
builder.addPropertyValue("pooled", nativePooling);
String authStrategyRef = element.getAttribute(ATT_AUTHENTICATION_STRATEGY_REF);
if(StringUtils.hasText(authStrategyRef)) {
builder.addPropertyReference("authenticationStrategy", authStrategyRef);
}
String authSourceRef = element.getAttribute(ATT_AUTHENTICATION_SOURCE_REF);
if(StringUtils.hasText(authSourceRef)) {
builder.addPropertyReference("authenticationSource", authSourceRef);
} else {
Assert.hasText(username, "username attribute must be specified unless an authentication-source-ref explicitly configured");
Assert.hasText(password, "password attribute must be specified unless an authentication-source-ref explicitly configured");
}
String baseEnvPropsRef = element.getAttribute(ATT_BASE_ENV_PROPS_REF);
if(StringUtils.hasText(baseEnvPropsRef)) {
builder.addPropertyReference("baseEnvironmentProperties", baseEnvPropsRef);
}
BeanDefinition targetContextSourceDefinition = builder.getBeanDefinition();
targetContextSourceDefinition = applyPoolingIfApplicable(targetContextSourceDefinition, element);
targetContextSourceDefinition = applyPoolingIfApplicable(targetContextSourceDefinition, element, nativePooling);
BeanDefinitionBuilder proxyBuilder = BeanDefinitionBuilder.rootBeanDefinition(TransactionAwareContextSourceProxy.class);
proxyBuilder.addConstructorArgValue(targetContextSourceDefinition);
AbstractBeanDefinition proxyBeanDefinition = proxyBuilder.getBeanDefinition();
BeanDefinition actualContextSourceDefinition = targetContextSourceDefinition;
if (!anonymousReadOnly) {
BeanDefinitionBuilder proxyBuilder = BeanDefinitionBuilder.rootBeanDefinition(TransactionAwareContextSourceProxy.class);
proxyBuilder.addConstructorArgValue(targetContextSourceDefinition);
actualContextSourceDefinition = proxyBuilder.getBeanDefinition();
}
String id = getString(element, AbstractBeanDefinitionParser.ID_ATTRIBUTE, DEFAULT_ID);
parserContext.registerBeanComponent(new BeanComponentDefinition(proxyBeanDefinition, id));
parserContext.registerBeanComponent(new BeanComponentDefinition(actualContextSourceDefinition, id));
return proxyBeanDefinition;
return actualContextSourceDefinition;
}
private BeanDefinition applyPoolingIfApplicable(BeanDefinition targetContextSourceDefinition, Element element) {
NodeList poolingChildren = element.getElementsByTagNameNS(NAMESPACE, Elements.POOLING);
if(poolingChildren.getLength() == 0) {
private BeanDefinition applyPoolingIfApplicable(
BeanDefinition targetContextSourceDefinition,
Element element,
boolean nativePooling) {
Element poolingElement = DomUtils.getChildElementByTagName(element, Elements.POOLING);
if(poolingElement == null) {
return targetContextSourceDefinition;
}
Element poolingElement = (Element) poolingChildren.item(0);
if(nativePooling) {
throw new IllegalArgumentException(
String.format("%s cannot be enabled together with %s", ATT_NATIVE_POOLING, Elements.POOLING));
}
BeanDefinitionBuilder builder = BeanDefinitionBuilder.rootBeanDefinition(PoolingContextSource.class);
builder.addPropertyValue("contextSource", targetContextSourceDefinition);
@@ -160,6 +189,18 @@ public class ContextSourceParser implements BeanDefinitionParser {
builder.addPropertyValue("timeBetweenEvictionRunsMillis", getInt(element, ATT_EVICTION_RUN_MILLIS, -1));
builder.addPropertyValue("numTestsPerEvictionRun", getInt(element, ATT_TESTS_PER_EVICTION_RUN, 3));
builder.addPropertyValue("minEvictableIdleTimeMillis", getInt(element, ATT_EVICTABLE_TIME_MILLIS, 1000 * 60 * 30));
}
String nonTransientExceptions = getString(element, ATT_NON_TRANSIENT_EXCEPTIONS, CommunicationException.class.getName());
String[] strings = StringUtils.commaDelimitedListToStringArray(nonTransientExceptions);
Set<Class<?>> nonTransientExceptionClasses = new HashSet<Class<?>>();
for (String className : strings) {
try {
nonTransientExceptionClasses.add(ClassUtils.getDefaultClassLoader().loadClass(className));
} catch (ClassNotFoundException e) {
throw new IllegalArgumentException(String.format("%s is not a valid class name", className));
}
}
builder.addPropertyValue("nonTransientExceptions", nonTransientExceptionClasses);
}
}

View File

@@ -27,10 +27,9 @@ import org.springframework.ldap.transaction.compensating.support.DefaultTempEntr
import org.springframework.ldap.transaction.compensating.support.DifferentSubtreeTempEntryRenamingStrategy;
import org.springframework.util.Assert;
import org.springframework.util.StringUtils;
import org.springframework.util.xml.DomUtils;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
import static org.springframework.ldap.config.ParserUtils.NAMESPACE;
import static org.springframework.ldap.config.ParserUtils.getString;
/**
@@ -62,17 +61,15 @@ public class TransactionManagerParser implements BeanDefinitionParser {
BeanDefinitionBuilder builder = BeanDefinitionBuilder.rootBeanDefinition(ContextSourceTransactionManager.class);
builder.addPropertyReference("contextSource", contextSourceRef);
NodeList defaultStrategyChildren =
element.getElementsByTagNameNS(NAMESPACE, Elements.DEFAULT_RENAMING_STRATEGY);
NodeList differentSubtreeChildren =
element.getElementsByTagNameNS(NAMESPACE, Elements.DIFFERENT_SUBTREE_RENAMING_STRATEGY);
Element defaultStrategyChild = DomUtils.getChildElementByTagName(element, Elements.DEFAULT_RENAMING_STRATEGY);
Element differentSubtreeChild = DomUtils.getChildElementByTagName(element, Elements.DIFFERENT_SUBTREE_RENAMING_STRATEGY);
if(defaultStrategyChildren.getLength() == 1) {
builder.addPropertyValue("renamingStrategy", parseDefaultRenamingStrategy((Element) defaultStrategyChildren.item(0)));
if(defaultStrategyChild != null) {
builder.addPropertyValue("renamingStrategy", parseDefaultRenamingStrategy(defaultStrategyChild));
}
if(differentSubtreeChildren.getLength() == 1) {
builder.addPropertyValue("renamingStrategy", parseDifferentSubtreeRenamingStrategy((Element) differentSubtreeChildren.item(0)));
if(differentSubtreeChild != null) {
builder.addPropertyValue("renamingStrategy", parseDifferentSubtreeRenamingStrategy(differentSubtreeChild));
}
String id = getString(element, AbstractBeanDefinitionParser.ID_ATTRIBUTE, DEFAULT_ID);

View File

@@ -665,6 +665,5 @@ public abstract class AbstractContextSource implements BaseLdapPathContextSource
public String getCredentials() {
return password;
}
}
}

View File

@@ -19,6 +19,7 @@ package org.springframework.ldap.transaction.compensating.manager;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.ldap.core.ContextSource;
import org.springframework.ldap.core.support.AbstractContextSource;
import org.springframework.ldap.transaction.compensating.LdapCompensatingTransactionOperationFactory;
import org.springframework.ldap.transaction.compensating.TempEntryRenamingStrategy;
import org.springframework.ldap.transaction.compensating.support.DefaultTempEntryRenamingStrategy;
@@ -68,6 +69,14 @@ public class ContextSourceTransactionManagerDelegate extends
} else {
this.contextSource = contextSource;
}
if (contextSource instanceof AbstractContextSource) {
AbstractContextSource abstractContextSource = (AbstractContextSource) contextSource;
if(abstractContextSource.isAnonymousReadOnly()) {
throw new IllegalArgumentException(
"Compensating LDAP transactions cannot be used when context-source is anonymous-read-only");
}
}
}
public ContextSource getContextSource() {

View File

@@ -39,13 +39,13 @@
<xs:attribute name="base" type="xs:string">
<xs:annotation>
<xs:documentation>
The base DN. If specified, all LDAP operations on contexts retrieved from this ContextSource will
The base DN. If configured, all LDAP operations on contexts retrieved from this ContextSource will
be relative to this DN. Default is an empty distinguished name (i.e. all operations will be
relative to the directory root).
</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="password" type="xs:string" use="required">
<xs:attribute name="password" type="xs:string">
<xs:annotation>
<xs:documentation>
The password to use for authentication.
@@ -82,7 +82,7 @@
</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="username" type="xs:string" use="required">
<xs:attribute name="username" type="xs:string">
<xs:annotation>
<xs:documentation>
The username (principal) to use for authentication. This will normally be the distinguished name
@@ -90,6 +90,14 @@
</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="base-env-props-ref" type="xs:token">
<xs:annotation>
<xs:documentation>
Reference to a Map of custom environment properties that should supplied with the environment
sent to the DirContext on construction.
</xs:documentation>
</xs:annotation>
</xs:attribute>
</xs:attributeGroup>
<xs:attributeGroup name="pooling.attlist">
@@ -240,6 +248,14 @@
</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="non-transient-exceptions" type="xs:string">
<xs:annotation>
<xs:documentation>
Id of the SearchControls instance to use for searches. Default is searchScope=OBJECT_SCOPE;
countLimit: 1; timeLimit: 500; returningAttributes: [objectclass].
</xs:documentation>
</xs:annotation>
</xs:attribute>
</xs:attributeGroup>
<xs:element name="context-source">

View File

@@ -0,0 +1,34 @@
/*
* Copyright 2005-2013 the original author or authors.
*
* Licensed 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.
*/
package org.springframework.ldap.config;
import org.springframework.ldap.core.AuthenticationSource;
/**
* @author Mattias Hellborg Arthursson
*/
public class DummyAuthenticationSource implements AuthenticationSource {
@Override
public String getPrincipal() {
throw new UnsupportedOperationException();
}
@Override
public String getCredentials() {
throw new UnsupportedOperationException();
}
}

View File

@@ -0,0 +1,38 @@
/*
* Copyright 2005-2013 the original author or authors.
*
* Licensed 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.
*/
package org.springframework.ldap.config;
import org.springframework.ldap.core.support.DirContextAuthenticationStrategy;
import javax.naming.NamingException;
import javax.naming.directory.DirContext;
import java.util.Hashtable;
/**
* @author Mattias Hellborg Arthursson
*/
public class DummyAuthenticationStrategy implements DirContextAuthenticationStrategy {
@Override
public void setupEnvironment(Hashtable<String, Object> env, String userDn, String password) throws NamingException {
throw new UnsupportedOperationException();
}
@Override
public DirContext processContextAfterCreation(DirContext ctx, String userDn, String password) throws NamingException {
throw new UnsupportedOperationException();
}
}

View File

@@ -18,10 +18,13 @@ package org.springframework.ldap.config;
import org.apache.commons.pool.impl.GenericKeyedObjectPool;
import org.junit.Test;
import org.springframework.beans.BeansException;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.ldap.core.AuthenticationSource;
import org.springframework.ldap.core.ContextSource;
import org.springframework.ldap.core.LdapTemplate;
import org.springframework.ldap.core.support.DirContextAuthenticationStrategy;
import org.springframework.ldap.core.support.LdapContextSource;
import org.springframework.ldap.pool.factory.PoolingContextSource;
import org.springframework.ldap.pool.validation.DefaultDirContextValidator;
import org.springframework.ldap.support.LdapUtils;
@@ -32,7 +35,10 @@ import org.springframework.ldap.transaction.compensating.support.DefaultTempEntr
import org.springframework.ldap.transaction.compensating.support.DifferentSubtreeTempEntryRenamingStrategy;
import org.springframework.transaction.PlatformTransactionManager;
import javax.naming.CannotProceedException;
import javax.naming.CommunicationException;
import javax.naming.directory.SearchControls;
import java.util.Set;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
@@ -75,6 +81,48 @@ public class LdapTemplateNamespaceHandlerTest {
assertEquals(SearchControls.SUBTREE_SCOPE, getInternalState(ldapTemplate, "defaultSearchScope"));
}
@Test
public void verifyThatAnonymousReadOnlyContextWillNotBeWrappedInProxy() {
ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext("/ldap-namespace-config-anonymous-read-only.xml");
ContextSource contextSource = ctx.getBean(ContextSource.class);
assertNotNull(contextSource);
assertTrue(contextSource instanceof LdapContextSource);
assertEquals(Boolean.TRUE, getInternalState(contextSource, "anonymousReadOnly"));
}
@Test(expected = BeansException.class)
public void verifyThatAnonymousReadOnlyAndTransactionalThrowsException() {
new ClassPathXmlApplicationContext("/ldap-namespace-config-anonymous-read-only-and-transactions.xml");
}
@Test(expected = BeansException.class)
public void verifyThatMissingUsernameThrowsException() {
new ClassPathXmlApplicationContext("/ldap-namespace-config-missing-username.xml");
}
@Test(expected = BeansException.class)
public void verifyThatMissingPasswordThrowsException() {
new ClassPathXmlApplicationContext("/ldap-namespace-config-missing-password.xml");
}
@Test
public void verifyReferences() {
ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext("/ldap-namespace-config-references.xml");
ContextSource outerContextSource = ctx.getBean(ContextSource.class);
AuthenticationSource authenticationSource = ctx.getBean(AuthenticationSource.class);
DirContextAuthenticationStrategy authenticationStrategy = ctx.getBean(DirContextAuthenticationStrategy.class);
Object baseEnv = ctx.getBean("baseEnvProps");
assertNotNull(outerContextSource);
assertTrue(outerContextSource instanceof TransactionAwareContextSourceProxy);
ContextSource contextSource = ((TransactionAwareContextSourceProxy) outerContextSource).getTarget();
assertSame(authenticationSource, getInternalState(contextSource, "authenticationSource"));
assertSame(authenticationStrategy, getInternalState(contextSource, "authenticationStrategy"));
assertEquals(baseEnv, getInternalState(contextSource, "baseEnv"));
}
@Test
public void verifyParseWithCustomValues() {
ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext("/ldap-namespace-config-values.xml");
@@ -93,7 +141,7 @@ public class LdapTemplateNamespaceHandlerTest {
assertEquals("apassword", getInternalState(contextSource, "password"));
assertArrayEquals(new String[]{"ldap://localhost:389"}, (Object[]) getInternalState(contextSource, "urls"));
assertEquals(Boolean.TRUE, getInternalState(contextSource, "pooled"));
assertEquals(Boolean.TRUE, getInternalState(contextSource, "anonymousReadOnly"));
assertEquals(Boolean.FALSE, getInternalState(contextSource, "anonymousReadOnly"));
assertEquals("follow", getInternalState(contextSource, "referral"));
assertSame(authenticationStrategy, getInternalState(contextSource, "authenticationStrategy"));
@@ -164,6 +212,7 @@ public class LdapTemplateNamespaceHandlerTest {
}
@Test
@SuppressWarnings("unchecked")
public void verifyParsePoolingDefaults() {
ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext("/ldap-namespace-config-pooling-defaults.xml");
@@ -178,6 +227,10 @@ public class LdapTemplateNamespaceHandlerTest {
Object objectFactory = getInternalState(pooledContextSource, "dirContextPoolableObjectFactory");
assertNotNull(getInternalState(objectFactory, "contextSource"));
assertNull(getInternalState(objectFactory, "dirContextValidator"));
Set<Class<? extends Throwable>> nonTransientExceptions =
(Set<Class<? extends Throwable>>) getInternalState(objectFactory, "nonTransientExceptions");
assertEquals(1, nonTransientExceptions.size());
assertTrue(nonTransientExceptions.contains(CommunicationException.class));
GenericKeyedObjectPool objectPool = (GenericKeyedObjectPool) getInternalState(pooledContextSource, "keyedObjectPool");
assertEquals(8, objectPool.getMaxActive());
@@ -208,6 +261,7 @@ public class LdapTemplateNamespaceHandlerTest {
}
@Test
@SuppressWarnings("unchecked")
public void verifyParsePoolingValidationSet() {
ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext("/ldap-namespace-config-pooling-test-specified.xml");
@@ -230,5 +284,16 @@ public class LdapTemplateNamespaceHandlerTest {
SearchControls searchControls = ctx.getBean(SearchControls.class);
assertEquals("objectclass=person", validator.getFilter());
assertSame(searchControls, validator.getSearchControls());
Set<Class<? extends Throwable>> nonTransientExceptions =
(Set<Class<? extends Throwable>>) getInternalState(objectFactory, "nonTransientExceptions");
assertEquals(2, nonTransientExceptions.size());
assertTrue(nonTransientExceptions.contains(CommunicationException.class));
assertTrue(nonTransientExceptions.contains(CannotProceedException.class));
}
@Test(expected = BeansException.class)
public void verifyParseWithPoolingAndNativePoolingWillFail() {
new ClassPathXmlApplicationContext("/ldap-namespace-config-pooling-with-native.xml");
}
}

View File

@@ -0,0 +1,20 @@
<?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:ldap="http://www.springframework.org/schema/ldap"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/ldap http://www.springframework.org/schema/ldap/spring-ldap.xsd">
<ldap:context-source
password="apassword"
url="ldap://localhost:389"
username="uid=admin"
anonymous-read-only="true" />
<!-- This is not valid together with anonymous-read-only -->
<ldap:transaction-manager>
<ldap:default-renaming-strategy />
</ldap:transaction-manager>
<ldap:ldap-template />
</beans>

View File

@@ -0,0 +1,15 @@
<?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:ldap="http://www.springframework.org/schema/ldap"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/ldap http://www.springframework.org/schema/ldap/spring-ldap.xsd">
<ldap:context-source
password="apassword"
url="ldap://localhost:389"
username="uid=admin"
anonymous-read-only="true" />
<ldap:ldap-template />
</beans>

View File

@@ -2,8 +2,8 @@
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:ldap="http://www.springframework.org/schema/ldap"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/ldap http://www.springframework.org/schema/ldap/spring-ldap.xsd">
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/ldap http://www.springframework.org/schema/ldap/spring-ldap.xsd">
<ldap:context-source password="apassword" url="ldap://localhost:389" username="uid=admin"/>
<ldap:ldap-template />

View File

@@ -0,0 +1,10 @@
<?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:ldap="http://www.springframework.org/schema/ldap"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/ldap http://www.springframework.org/schema/ldap/spring-ldap.xsd">
<ldap:context-source url="ldap://localhost:389" username="uid=admin"/>
<ldap:ldap-template />
</beans>

View File

@@ -0,0 +1,9 @@
<?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:ldap="http://www.springframework.org/schema/ldap"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/ldap http://www.springframework.org/schema/ldap/spring-ldap.xsd">
<ldap:context-source password="apassword" url="ldap://localhost:389" />
</beans>

View File

@@ -15,7 +15,8 @@
tests-per-eviction-run="22"
validation-query-base="ou=test"
validation-query-filter="objectclass=person"
validation-query-search-controls-ref="searchControls"/>
validation-query-search-controls-ref="searchControls"
non-transient-exceptions="javax.naming.CannotProceedException,javax.naming.CommunicationException" />
</ldap:context-source>
<bean class="javax.naming.directory.SearchControls" id="searchControls" />

View File

@@ -0,0 +1,17 @@
<?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:ldap="http://www.springframework.org/schema/ldap"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/ldap http://www.springframework.org/schema/ldap/spring-ldap.xsd">
<!--
The below is invalid, since native pooling is not supported together with Spring LDAP pooling.
-->
<ldap:context-source
password="apassword" url="ldap://localhost:389" username="uid=admin"
native-pooling="true">
<ldap:pooling />
</ldap:context-source>
<ldap:ldap-template />
</beans>

View File

@@ -0,0 +1,21 @@
<?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:ldap="http://www.springframework.org/schema/ldap" xmlns:util="http://www.springframework.org/schema/util"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/ldap http://www.springframework.org/schema/ldap/spring-ldap.xsd http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd">
<ldap:context-source url="ldap://localhost:389"
authentication-source-ref="authenticationSource"
authentication-strategy-ref="authenticationStrategy"
base-env-props-ref="baseEnvProps" />
<bean class="org.springframework.ldap.config.DummyAuthenticationSource" id="authenticationSource" />
<bean class="org.springframework.ldap.config.DummyAuthenticationStrategy" id="authenticationStrategy" />
<util:map id="baseEnvProps">
<entry key="dummy" value="dummyValue" />
</util:map>
<ldap:ldap-template />
</beans>

View File

@@ -11,7 +11,6 @@
url="ldap://localhost:389"
username="uid=admin"
base="dc=261consulting,dc=com"
anonymous-read-only="true"
authentication-strategy-ref="authenticationStrategy"
native-pooling="true"
referral="follow" />