LDAP-258: Parameterized the core callback interfaces.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2005-2010 the original author or authors.
|
||||
* 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.
|
||||
@@ -39,7 +39,7 @@ import javax.naming.directory.Attributes;
|
||||
*
|
||||
* @author Mattias Hellborg Arthursson
|
||||
*/
|
||||
public interface AttributesMapper {
|
||||
public interface AttributesMapper<T> {
|
||||
/**
|
||||
* Map Attributes to an object. The supplied attributes are the attributes
|
||||
* from a single SearchResult.
|
||||
@@ -50,6 +50,6 @@ public interface AttributesMapper {
|
||||
* @throws NamingException
|
||||
* if any error occurs mapping the attributes
|
||||
*/
|
||||
Object mapFromAttributes(Attributes attributes)
|
||||
T mapFromAttributes(Attributes attributes)
|
||||
throws NamingException;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2005-2010 the original author or authors.
|
||||
* 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.
|
||||
@@ -16,12 +16,12 @@
|
||||
|
||||
package org.springframework.ldap.core;
|
||||
|
||||
import org.springframework.ldap.support.LdapUtils;
|
||||
|
||||
import javax.naming.NameClassPair;
|
||||
import javax.naming.directory.Attributes;
|
||||
import javax.naming.directory.SearchResult;
|
||||
|
||||
import org.springframework.ldap.support.LdapUtils;
|
||||
|
||||
/**
|
||||
* A CollectingNameClassPairCallbackHandler to wrap an {@link AttributesMapper}.
|
||||
* That is, the found object is extracted from the {@link Attributes} of each
|
||||
@@ -32,15 +32,15 @@ import org.springframework.ldap.support.LdapUtils;
|
||||
* @author Ulrik Sandberg
|
||||
* @since 1.2
|
||||
*/
|
||||
public class AttributesMapperCallbackHandler extends CollectingNameClassPairCallbackHandler {
|
||||
private AttributesMapper mapper;
|
||||
public class AttributesMapperCallbackHandler<T> extends CollectingNameClassPairCallbackHandler<T> {
|
||||
private AttributesMapper<T> mapper;
|
||||
|
||||
/**
|
||||
* Constructs a new instance around the specified {@link AttributesMapper}.
|
||||
*
|
||||
* @param mapper the target mapper.
|
||||
*/
|
||||
public AttributesMapperCallbackHandler(AttributesMapper mapper) {
|
||||
public AttributesMapperCallbackHandler(AttributesMapper<T> mapper) {
|
||||
this.mapper = mapper;
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ public class AttributesMapperCallbackHandler extends CollectingNameClassPairCall
|
||||
* @param nameClassPair a <code> SearchResult</code> instance.
|
||||
* @return the Object returned from the mapper.
|
||||
*/
|
||||
public Object getObjectFromNameClassPair(NameClassPair nameClassPair) {
|
||||
public T getObjectFromNameClassPair(NameClassPair nameClassPair) {
|
||||
if (!(nameClassPair instanceof SearchResult)) {
|
||||
throw new IllegalArgumentException("Parameter must be an instance of SearchResult");
|
||||
}
|
||||
|
||||
@@ -27,17 +27,17 @@ import java.util.List;
|
||||
*
|
||||
* @author Mattias Hellborg Arthursson
|
||||
*/
|
||||
public abstract class CollectingNameClassPairCallbackHandler implements
|
||||
public abstract class CollectingNameClassPairCallbackHandler<T> implements
|
||||
NameClassPairCallbackHandler {
|
||||
|
||||
private List list = new LinkedList();
|
||||
private List<T> list = new LinkedList<T>();
|
||||
|
||||
/**
|
||||
* Get the assembled list.
|
||||
*
|
||||
* @return the list of all assembled objects.
|
||||
*/
|
||||
public List getList() {
|
||||
public List<T> getList() {
|
||||
return list;
|
||||
}
|
||||
|
||||
@@ -59,6 +59,6 @@ public abstract class CollectingNameClassPairCallbackHandler implements
|
||||
* @return an object constructed from the data in the NameClassPair.
|
||||
* @throws NamingException if an error occurs.
|
||||
*/
|
||||
public abstract Object getObjectFromNameClassPair(
|
||||
public abstract T getObjectFromNameClassPair(
|
||||
NameClassPair nameClassPair) throws NamingException;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2005-2010 the original author or authors.
|
||||
* 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.
|
||||
@@ -36,7 +36,7 @@ import javax.naming.directory.DirContext;
|
||||
*
|
||||
* @author Mattias Hellborg Arthursson
|
||||
*/
|
||||
public interface ContextExecutor {
|
||||
public interface ContextExecutor<T> {
|
||||
/**
|
||||
* Perform any operation on the context.
|
||||
*
|
||||
@@ -46,5 +46,5 @@ public interface ContextExecutor {
|
||||
* @throws NamingException
|
||||
* if the operation resulted in one.
|
||||
*/
|
||||
Object executeWithContext(DirContext ctx) throws NamingException;
|
||||
T executeWithContext(DirContext ctx) throws NamingException;
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ import javax.naming.directory.SearchResult;
|
||||
*
|
||||
* @author Mattias Hellborg Arthursson
|
||||
*/
|
||||
public interface ContextMapper {
|
||||
public interface ContextMapper<T> {
|
||||
/**
|
||||
* Map a single LDAP Context to an object. The supplied Object
|
||||
* <code>ctx</code> is the object from a single {@link SearchResult},
|
||||
@@ -63,5 +63,5 @@ public interface ContextMapper {
|
||||
* @return an object built from the data in the context.
|
||||
* @throws NamingException if an error occurs.
|
||||
*/
|
||||
Object mapFromContext(Object ctx) throws NamingException;
|
||||
T mapFromContext(Object ctx) throws NamingException;
|
||||
}
|
||||
|
||||
@@ -30,9 +30,9 @@ import javax.naming.NamingException;
|
||||
* @author Ulrik Sandberg
|
||||
* @since 1.2
|
||||
*/
|
||||
public class ContextMapperCallbackHandler extends
|
||||
CollectingNameClassPairCallbackHandler {
|
||||
private ContextMapper mapper;
|
||||
public class ContextMapperCallbackHandler<T> extends
|
||||
CollectingNameClassPairCallbackHandler<T> {
|
||||
private ContextMapper<T> mapper;
|
||||
|
||||
/**
|
||||
* Constructs a new instance wrapping the supplied {@link ContextMapper}.
|
||||
@@ -40,7 +40,7 @@ public class ContextMapperCallbackHandler extends
|
||||
* @param mapper
|
||||
* the mapper to be called for each entry.
|
||||
*/
|
||||
public ContextMapperCallbackHandler(ContextMapper mapper) {
|
||||
public ContextMapperCallbackHandler(ContextMapper<T> mapper) {
|
||||
Assert.notNull(mapper, "Mapper must not be empty");
|
||||
this.mapper = mapper;
|
||||
}
|
||||
@@ -55,7 +55,7 @@ public class ContextMapperCallbackHandler extends
|
||||
* @throws NamingException if an error occurs.
|
||||
* @throws ObjectRetrievalException if the object of the nameClassPair is null.
|
||||
*/
|
||||
public Object getObjectFromNameClassPair(NameClassPair nameClassPair) throws NamingException {
|
||||
public T getObjectFromNameClassPair(NameClassPair nameClassPair) throws NamingException {
|
||||
if (!(nameClassPair instanceof Binding)) {
|
||||
throw new IllegalArgumentException("Parameter must be an instance of Binding");
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2005-2010 the original author or authors.
|
||||
* 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.
|
||||
@@ -17,14 +17,12 @@ package org.springframework.ldap.core;
|
||||
|
||||
import java.io.StringReader;
|
||||
|
||||
import org.springframework.ldap.core.DnParserImpl;
|
||||
|
||||
/**
|
||||
* A factory for creating DnParser instances. The actual implementation of
|
||||
* DnParser is generated using javacc and should not be constructed directly.
|
||||
*
|
||||
* @author Mattias Hellborg Arthursson
|
||||
*
|
||||
* @deprecated {@link DistinguishedName} and associated classes are deprecated as of 2.0.
|
||||
*/
|
||||
public class DefaultDnParserFactory {
|
||||
/**
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2005-2010 the original author or authors.
|
||||
* 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.
|
||||
@@ -27,7 +27,7 @@ import javax.naming.NamingException;
|
||||
* @author Mattias Hellborg Arthursson
|
||||
*
|
||||
*/
|
||||
public class DefaultNameClassPairMapper implements NameClassPairMapper {
|
||||
public class DefaultNameClassPairMapper implements NameClassPairMapper<String> {
|
||||
|
||||
/**
|
||||
* Gets the Name from the supplied NameClassPair and returns it as the
|
||||
@@ -37,7 +37,8 @@ public class DefaultNameClassPairMapper implements NameClassPairMapper {
|
||||
* the NameClassPair to transform.
|
||||
* @return the Name string from the NameClassPair.
|
||||
*/
|
||||
public Object mapFromNameClassPair(NameClassPair nameClassPair)
|
||||
@Override
|
||||
public String mapFromNameClassPair(NameClassPair nameClassPair)
|
||||
throws NamingException {
|
||||
|
||||
return nameClassPair.getName();
|
||||
|
||||
@@ -24,7 +24,7 @@ import java.beans.PropertyEditorSupport;
|
||||
*
|
||||
* @author Mattias Hellborg Arthursson
|
||||
* @since 1.2
|
||||
* @deprecated {@link DistinguishedName and associated classes are deprecated as of 2.0}.
|
||||
* @deprecated {@link DistinguishedName} and associated classes are deprecated as of 2.0.
|
||||
*/
|
||||
public class DistinguishedNameEditor extends PropertyEditorSupport {
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ package org.springframework.ldap.core;
|
||||
* A parser for RFC2253-compliant Distinguished Names.
|
||||
*
|
||||
* @author Mattias Hellborg Arthursson
|
||||
* @deprecated {@link DistinguishedName and associated classes are deprecated as of 2.0}.
|
||||
* @deprecated {@link DistinguishedName} and associated classes are deprecated as of 2.0.
|
||||
*/
|
||||
public interface DnParser {
|
||||
/**
|
||||
|
||||
@@ -29,7 +29,7 @@ import java.util.List;
|
||||
* @see <a href="http://www.watersprings.org/pub/id/draft-kashi-incremental-00.txt">Incremental Retrieval of Multi-valued Properties</a>
|
||||
* @see {@link org.springframework.ldap.core.support.DefaultIncrementalAttributesMapper}
|
||||
*/
|
||||
public interface IncrementalAttributesMapper extends AttributesMapper {
|
||||
public interface IncrementalAttributesMapper<T extends IncrementalAttributesMapper> extends AttributesMapper<T> {
|
||||
/**
|
||||
* Get all of the collected values for the specified attribute.
|
||||
*
|
||||
@@ -37,7 +37,7 @@ public interface IncrementalAttributesMapper extends AttributesMapper {
|
||||
* @return the collected values for the specified attribute. Will be <code>null</code>
|
||||
* if the requested attribute has not been returned by the server (attribute did not exist).
|
||||
*/
|
||||
List getValues(String attributeName);
|
||||
List<Object> getValues(String attributeName);
|
||||
|
||||
/**
|
||||
* Get all collected values for all managed attributes as an Attributes instance.
|
||||
@@ -73,5 +73,5 @@ public interface IncrementalAttributesMapper extends AttributesMapper {
|
||||
* @return this instance.
|
||||
* @throws javax.naming.NamingException
|
||||
*/
|
||||
Object mapFromAttributes(Attributes attributes) throws NamingException;
|
||||
T mapFromAttributes(Attributes attributes) throws NamingException;
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ public class LdapEntryIdentification {
|
||||
* returned by {@link DirContext#getNameInNamespace()}.
|
||||
* @param relativeDn the DN of the identified entry relative to the base
|
||||
* LDAP path, e.g. as returned by {@link DirContextOperations#getDn()}.
|
||||
* @deprecated {@link DistinguishedName and associated classes and methods are deprecated as of 2.0}.
|
||||
* @deprecated {@link DistinguishedName} and associated classes and methods are deprecated as of 2.0.
|
||||
* use {@link #LdapEntryIdentification(javax.naming.ldap.LdapName, javax.naming.ldap.LdapName)} instead.
|
||||
*/
|
||||
public LdapEntryIdentification(DistinguishedName absoluteDn, DistinguishedName relativeDn) {
|
||||
@@ -97,7 +97,7 @@ public class LdapEntryIdentification {
|
||||
* Get the DN of the identified entry relative to the base LDAP path, e.g.
|
||||
* as returned by {@link DirContextOperations#getDn()}.
|
||||
* @return the relative DN.
|
||||
* @deprecated {@link DistinguishedName and associated classes and methods are deprecated as of 2.0}.
|
||||
* @deprecated {@link DistinguishedName} and associated classes and methods are deprecated as of 2.0.
|
||||
* use {@link #getRelativeName()} instead.
|
||||
*/
|
||||
public DistinguishedName getRelativeDn() {
|
||||
@@ -108,7 +108,7 @@ public class LdapEntryIdentification {
|
||||
* Get the absolute DN of the identified entry, e.g. as returned by
|
||||
* {@link DirContext#getNameInNamespace()}.
|
||||
* @return the absolute DN.
|
||||
* @deprecated {@link DistinguishedName and associated classes and methods are deprecated as of 2.0}.
|
||||
* @deprecated {@link DistinguishedName} and associated classes and methods are deprecated as of 2.0.
|
||||
* use {@link #getAbsoluteName()} instead.
|
||||
*/
|
||||
public DistinguishedName getAbsoluteDn() {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2005-2010 the original author or authors.
|
||||
* 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.
|
||||
@@ -24,9 +24,9 @@ import org.springframework.ldap.support.LdapUtils;
|
||||
* @author Mattias Hellborg Arthursson
|
||||
* @since 1.3
|
||||
*/
|
||||
public class LdapEntryIdentificationContextMapper implements ContextMapper {
|
||||
public class LdapEntryIdentificationContextMapper implements ContextMapper<LdapEntryIdentification> {
|
||||
|
||||
public Object mapFromContext(Object ctx) {
|
||||
public LdapEntryIdentification mapFromContext(Object ctx) {
|
||||
DirContextOperations adapter = (DirContextOperations) ctx;
|
||||
return new LdapEntryIdentification(
|
||||
LdapUtils.newLdapName(adapter.getNameInNamespace()),
|
||||
|
||||
@@ -106,7 +106,7 @@ public interface LdapOperations {
|
||||
* @see #search(Name, String, AttributesMapper)
|
||||
* @see #search(Name, String, ContextMapper)
|
||||
*/
|
||||
Object executeReadOnly(ContextExecutor ce) throws NamingException;
|
||||
<T> T executeReadOnly(ContextExecutor<T> ce) throws NamingException;
|
||||
|
||||
/**
|
||||
* Perform an operation (or series of operations) on a read-write context.
|
||||
@@ -126,7 +126,7 @@ public interface LdapOperations {
|
||||
* @see #rename(Name, Name)
|
||||
* @see #modifyAttributes(Name, ModificationItem[])
|
||||
*/
|
||||
Object executeReadWrite(ContextExecutor ce) throws NamingException;
|
||||
<T> T executeReadWrite(ContextExecutor<T> ce) throws NamingException;
|
||||
|
||||
/**
|
||||
* Search for all objects matching the supplied filter. Each
|
||||
@@ -211,7 +211,7 @@ public interface LdapOperations {
|
||||
* <code>NameNotFoundException</code> will be ignored. Instead this is
|
||||
* interpreted that no entries were found.
|
||||
*/
|
||||
List search(String base, String filter, SearchControls controls, AttributesMapper mapper,
|
||||
<T> List<T> search(String base, String filter, SearchControls controls, AttributesMapper<T> mapper,
|
||||
DirContextProcessor processor) throws NamingException;
|
||||
|
||||
/**
|
||||
@@ -235,7 +235,7 @@ public interface LdapOperations {
|
||||
* <code>NameNotFoundException</code> will be ignored. Instead this is
|
||||
* interpreted that no entries were found.
|
||||
*/
|
||||
List search(Name base, String filter, SearchControls controls, AttributesMapper mapper,
|
||||
<T> List<T> search(Name base, String filter, SearchControls controls, AttributesMapper<T> mapper,
|
||||
DirContextProcessor processor) throws NamingException;
|
||||
|
||||
/**
|
||||
@@ -409,7 +409,7 @@ public interface LdapOperations {
|
||||
* <code>NameNotFoundException</code> will be ignored. Instead this is
|
||||
* interpreted that no entries were found.
|
||||
*/
|
||||
List search(Name base, String filter, int searchScope, String[] attrs, AttributesMapper mapper)
|
||||
<T> List<T> search(Name base, String filter, int searchScope, String[] attrs, AttributesMapper<T> mapper)
|
||||
throws NamingException;
|
||||
|
||||
/**
|
||||
@@ -432,7 +432,7 @@ public interface LdapOperations {
|
||||
* <code>NameNotFoundException</code> will be ignored. Instead this is
|
||||
* interpreted that no entries were found.
|
||||
*/
|
||||
List search(String base, String filter, int searchScope, String[] attrs, AttributesMapper mapper)
|
||||
<T> List<T> search(String base, String filter, int searchScope, String[] attrs, AttributesMapper<T> mapper)
|
||||
throws NamingException;
|
||||
|
||||
/**
|
||||
@@ -452,7 +452,7 @@ public interface LdapOperations {
|
||||
* <code>NameNotFoundException</code> will be ignored. Instead this is
|
||||
* interpreted that no entries were found.
|
||||
*/
|
||||
List search(Name base, String filter, int searchScope, AttributesMapper mapper) throws NamingException;
|
||||
<T> List<T> search(Name base, String filter, int searchScope, AttributesMapper<T> mapper) throws NamingException;
|
||||
|
||||
/**
|
||||
* Search for all objects matching the supplied filter. The Attributes in
|
||||
@@ -471,7 +471,7 @@ public interface LdapOperations {
|
||||
* <code>NameNotFoundException</code> will be ignored. Instead this is
|
||||
* interpreted that no entries were found.
|
||||
*/
|
||||
List search(String base, String filter, int searchScope, AttributesMapper mapper) throws NamingException;
|
||||
<T> List<T> search(String base, String filter, int searchScope, AttributesMapper<T> mapper) throws NamingException;
|
||||
|
||||
/**
|
||||
* Search for all objects matching the supplied filter. The Attributes in
|
||||
@@ -488,7 +488,7 @@ public interface LdapOperations {
|
||||
* <code>NameNotFoundException</code> will be ignored. Instead this is
|
||||
* interpreted that no entries were found.
|
||||
*/
|
||||
List search(Name base, String filter, AttributesMapper mapper) throws NamingException;
|
||||
<T> List<T> search(Name base, String filter, AttributesMapper<T> mapper) throws NamingException;
|
||||
|
||||
/**
|
||||
* Search for all objects matching the supplied filter. The Attributes in
|
||||
@@ -505,7 +505,7 @@ public interface LdapOperations {
|
||||
* <code>NameNotFoundException</code> will be ignored. Instead this is
|
||||
* interpreted that no entries were found.
|
||||
*/
|
||||
List search(String base, String filter, AttributesMapper mapper) throws NamingException;
|
||||
<T> List<T> search(String base, String filter, AttributesMapper<T> mapper) throws NamingException;
|
||||
|
||||
/**
|
||||
* Search for all objects matching the supplied filter. The
|
||||
@@ -527,7 +527,7 @@ public interface LdapOperations {
|
||||
* <code>NameNotFoundException</code> will be ignored. Instead this is
|
||||
* interpreted that no entries were found.
|
||||
*/
|
||||
List search(Name base, String filter, int searchScope, String[] attrs, ContextMapper mapper) throws NamingException;
|
||||
<T> List<T> search(Name base, String filter, int searchScope, String[] attrs, ContextMapper<T> mapper) throws NamingException;
|
||||
|
||||
/**
|
||||
* Search for all objects matching the supplied filter. The
|
||||
@@ -549,7 +549,7 @@ public interface LdapOperations {
|
||||
* <code>NameNotFoundException</code> will be ignored. Instead this is
|
||||
* interpreted that no entries were found.
|
||||
*/
|
||||
List search(String base, String filter, int searchScope, String[] attrs, ContextMapper mapper)
|
||||
<T> List<T> search(String base, String filter, int searchScope, String[] attrs, ContextMapper<T> mapper)
|
||||
throws NamingException;
|
||||
|
||||
/**
|
||||
@@ -569,7 +569,7 @@ public interface LdapOperations {
|
||||
* <code>NameNotFoundException</code> will be ignored. Instead this is
|
||||
* interpreted that no entries were found.
|
||||
*/
|
||||
List search(Name base, String filter, int searchScope, ContextMapper mapper) throws NamingException;
|
||||
<T> List<T> search(Name base, String filter, int searchScope, ContextMapper<T> mapper) throws NamingException;
|
||||
|
||||
/**
|
||||
* Search for all objects matching the supplied filter. The
|
||||
@@ -588,7 +588,7 @@ public interface LdapOperations {
|
||||
* <code>NameNotFoundException</code> will be ignored. Instead this is
|
||||
* interpreted that no entries were found.
|
||||
*/
|
||||
List search(String base, String filter, int searchScope, ContextMapper mapper) throws NamingException;
|
||||
<T> List<T> search(String base, String filter, int searchScope, ContextMapper<T> mapper) throws NamingException;
|
||||
|
||||
/**
|
||||
* Search for all objects matching the supplied filter. The
|
||||
@@ -606,7 +606,7 @@ public interface LdapOperations {
|
||||
* <code>NameNotFoundException</code> will be ignored. Instead this is
|
||||
* interpreted that no entries were found.
|
||||
*/
|
||||
List search(Name base, String filter, ContextMapper mapper) throws NamingException;
|
||||
<T> List<T> search(Name base, String filter, ContextMapper<T> mapper) throws NamingException;
|
||||
|
||||
/**
|
||||
* Search for all objects matching the supplied filter. The
|
||||
@@ -624,7 +624,7 @@ public interface LdapOperations {
|
||||
* <code>NameNotFoundException</code> will be ignored. Instead this is
|
||||
* interpreted that no entries were found.
|
||||
*/
|
||||
List search(String base, String filter, ContextMapper mapper) throws NamingException;
|
||||
<T> List<T> search(String base, String filter, ContextMapper<T> mapper) throws NamingException;
|
||||
|
||||
/**
|
||||
* Search for all objects matching the supplied filter. The
|
||||
@@ -642,7 +642,7 @@ public interface LdapOperations {
|
||||
* <code>NameNotFoundException</code> will be ignored. Instead this is
|
||||
* interpreted that no entries were found.
|
||||
*/
|
||||
List search(String base, String filter, SearchControls controls, ContextMapper mapper) throws NamingException;
|
||||
<T> List<T> search(String base, String filter, SearchControls controls, ContextMapper<T> mapper) throws NamingException;
|
||||
|
||||
/**
|
||||
* Search for all objects matching the supplied filter. The Object returned
|
||||
@@ -663,7 +663,7 @@ public interface LdapOperations {
|
||||
* <code>NameNotFoundException</code> will be ignored. Instead this is
|
||||
* interpreted that no entries were found.
|
||||
*/
|
||||
List search(Name base, String filter, SearchControls controls, ContextMapper mapper) throws NamingException;
|
||||
<T> List<T> search(Name base, String filter, SearchControls controls, ContextMapper<T> mapper) throws NamingException;
|
||||
|
||||
/**
|
||||
* Search for all objects matching the supplied filter. The Attributes
|
||||
@@ -681,7 +681,7 @@ public interface LdapOperations {
|
||||
* <code>NameNotFoundException</code> will be ignored. Instead this is
|
||||
* interpreted that no entries were found.
|
||||
*/
|
||||
List search(String base, String filter, SearchControls controls, AttributesMapper mapper) throws NamingException;
|
||||
<T> List<T> search(String base, String filter, SearchControls controls, AttributesMapper<T> mapper) throws NamingException;
|
||||
|
||||
/**
|
||||
* Search for all objects matching the supplied filter. The Attributes
|
||||
@@ -699,7 +699,7 @@ public interface LdapOperations {
|
||||
* <code>NameNotFoundException</code> will be ignored. Instead this is
|
||||
* interpreted that no entries were found.
|
||||
*/
|
||||
List search(Name base, String filter, SearchControls controls, AttributesMapper mapper) throws NamingException;
|
||||
<T> List<T> search(Name base, String filter, SearchControls controls, AttributesMapper<T> mapper) throws NamingException;
|
||||
|
||||
/**
|
||||
* Perform a non-recursive listing of the children of the given
|
||||
@@ -744,7 +744,7 @@ public interface LdapOperations {
|
||||
* <code>NameNotFoundException</code> will be ignored. Instead this is
|
||||
* interpreted that no entries were found.
|
||||
*/
|
||||
List list(String base, NameClassPairMapper mapper) throws NamingException;
|
||||
<T> List<T> list(String base, NameClassPairMapper<T> mapper) throws NamingException;
|
||||
|
||||
/**
|
||||
* Perform a non-recursive listing of the children of the given
|
||||
@@ -761,7 +761,7 @@ public interface LdapOperations {
|
||||
* <code>NameNotFoundException</code> will be ignored. Instead this is
|
||||
* interpreted that no entries were found.
|
||||
*/
|
||||
List list(Name base, NameClassPairMapper mapper) throws NamingException;
|
||||
<T> List<T> list(Name base, NameClassPairMapper<T> mapper) throws NamingException;
|
||||
|
||||
/**
|
||||
* Perform a non-recursive listing of the children of the given
|
||||
@@ -774,7 +774,7 @@ public interface LdapOperations {
|
||||
* <code>NameNotFoundException</code> will be ignored. Instead this is
|
||||
* interpreted that no entries were found.
|
||||
*/
|
||||
List list(String base) throws NamingException;
|
||||
List<String> list(String base) throws NamingException;
|
||||
|
||||
/**
|
||||
* Perform a non-recursive listing of the children of the given
|
||||
@@ -787,7 +787,7 @@ public interface LdapOperations {
|
||||
* <code>NameNotFoundException</code> will be ignored. Instead this is
|
||||
* interpreted that no entries were found.
|
||||
*/
|
||||
List list(Name base) throws NamingException;
|
||||
List<String> list(Name base) throws NamingException;
|
||||
|
||||
/**
|
||||
* Perform a non-recursive listing of the children of the given
|
||||
@@ -832,7 +832,7 @@ public interface LdapOperations {
|
||||
* <code>NameNotFoundException</code> will be ignored. Instead this is
|
||||
* interpreted that no entries were found.
|
||||
*/
|
||||
List listBindings(String base, NameClassPairMapper mapper) throws NamingException;
|
||||
<T> List<T> listBindings(String base, NameClassPairMapper<T> mapper) throws NamingException;
|
||||
|
||||
/**
|
||||
* Perform a non-recursive listing of the children of the given
|
||||
@@ -849,7 +849,7 @@ public interface LdapOperations {
|
||||
* <code>NameNotFoundException</code> will be ignored. Instead this is
|
||||
* interpreted that no entries were found.
|
||||
*/
|
||||
List listBindings(Name base, NameClassPairMapper mapper) throws NamingException;
|
||||
<T> List<T> listBindings(Name base, NameClassPairMapper<T> mapper) throws NamingException;
|
||||
|
||||
/**
|
||||
* Perform a non-recursive listing of children of the given
|
||||
@@ -862,7 +862,7 @@ public interface LdapOperations {
|
||||
* <code>NameNotFoundException</code> will be ignored. Instead this is
|
||||
* interpreted that no entries were found.
|
||||
*/
|
||||
List listBindings(final String base) throws NamingException;
|
||||
List<String> listBindings(final String base) throws NamingException;
|
||||
|
||||
/**
|
||||
* Perform a non-recursive listing of children of the given
|
||||
@@ -875,7 +875,7 @@ public interface LdapOperations {
|
||||
* <code>NameNotFoundException</code> will be ignored. Instead this is
|
||||
* interpreted that no entries were found.
|
||||
*/
|
||||
List listBindings(final Name base) throws NamingException;
|
||||
List<String> listBindings(final Name base) throws NamingException;
|
||||
|
||||
/**
|
||||
* Perform a non-recursive listing of the children of the given
|
||||
@@ -891,7 +891,7 @@ public interface LdapOperations {
|
||||
* <code>NameNotFoundException</code> will be ignored. Instead this is
|
||||
* interpreted that no entries were found.
|
||||
*/
|
||||
List listBindings(String base, ContextMapper mapper) throws NamingException;
|
||||
<T> List<T> listBindings(String base, ContextMapper<T> mapper) throws NamingException;
|
||||
|
||||
/**
|
||||
* Perform a non-recursive listing of the children of the given
|
||||
@@ -907,7 +907,7 @@ public interface LdapOperations {
|
||||
* <code>NameNotFoundException</code> will be ignored. Instead this is
|
||||
* interpreted that no entries were found.
|
||||
*/
|
||||
List listBindings(Name base, ContextMapper mapper) throws NamingException;
|
||||
<T> List<T> listBindings(Name base, ContextMapper<T> mapper) throws NamingException;
|
||||
|
||||
/**
|
||||
* Lookup the supplied DN and return the found object. This will typically
|
||||
@@ -945,7 +945,7 @@ public interface LdapOperations {
|
||||
* @return the object returned from the mapper.
|
||||
* @throws NamingException if any error occurs.
|
||||
*/
|
||||
Object lookup(Name dn, AttributesMapper mapper) throws NamingException;
|
||||
<T> T lookup(Name dn, AttributesMapper<T> mapper) throws NamingException;
|
||||
|
||||
/**
|
||||
* Convenience method to get the attributes of a specified DN and
|
||||
@@ -957,7 +957,7 @@ public interface LdapOperations {
|
||||
* @return the object returned from the mapper.
|
||||
* @throws NamingException if any error occurs.
|
||||
*/
|
||||
Object lookup(String dn, AttributesMapper mapper) throws NamingException;
|
||||
<T> T lookup(String dn, AttributesMapper<T> mapper) throws NamingException;
|
||||
|
||||
/**
|
||||
* Convenience method to lookup a specified DN and automatically pass the
|
||||
@@ -969,7 +969,7 @@ public interface LdapOperations {
|
||||
* @return the object returned from the mapper.
|
||||
* @throws NamingException if any error occurs.
|
||||
*/
|
||||
Object lookup(Name dn, ContextMapper mapper) throws NamingException;
|
||||
<T> T lookup(Name dn, ContextMapper<T> mapper) throws NamingException;
|
||||
|
||||
/**
|
||||
* Convenience method to lookup a specified DN and automatically pass the
|
||||
@@ -981,7 +981,7 @@ public interface LdapOperations {
|
||||
* @return the object returned from the mapper.
|
||||
* @throws NamingException if any error occurs.
|
||||
*/
|
||||
Object lookup(String dn, ContextMapper mapper) throws NamingException;
|
||||
<T> T lookup(String dn, ContextMapper<T> mapper) throws NamingException;
|
||||
|
||||
/**
|
||||
* Convenience method to get the specified attributes of a specified DN and
|
||||
@@ -994,7 +994,7 @@ public interface LdapOperations {
|
||||
* @return the object returned from the mapper.
|
||||
* @throws NamingException if any error occurs.
|
||||
*/
|
||||
Object lookup(Name dn, String[] attributes, AttributesMapper mapper) throws NamingException;
|
||||
<T> T lookup(Name dn, String[] attributes, AttributesMapper<T> mapper) throws NamingException;
|
||||
|
||||
/**
|
||||
* Convenience method to get the specified attributes of a specified DN and
|
||||
@@ -1007,7 +1007,7 @@ public interface LdapOperations {
|
||||
* @return the object returned from the mapper.
|
||||
* @throws NamingException if any error occurs.
|
||||
*/
|
||||
Object lookup(String dn, String[] attributes, AttributesMapper mapper) throws NamingException;
|
||||
<T> T lookup(String dn, String[] attributes, AttributesMapper<T> mapper) throws NamingException;
|
||||
|
||||
/**
|
||||
* Convenience method to get the specified attributes of a specified DN and
|
||||
@@ -1020,7 +1020,7 @@ public interface LdapOperations {
|
||||
* @return the object returned from the mapper.
|
||||
* @throws NamingException if any error occurs.
|
||||
*/
|
||||
Object lookup(Name dn, String[] attributes, ContextMapper mapper) throws NamingException;
|
||||
<T> T lookup(Name dn, String[] attributes, ContextMapper<T> mapper) throws NamingException;
|
||||
|
||||
/**
|
||||
* Convenience method to get the specified attributes of a specified DN and
|
||||
@@ -1033,7 +1033,7 @@ public interface LdapOperations {
|
||||
* @return the object returned from the mapper.
|
||||
* @throws NamingException if any error occurs.
|
||||
*/
|
||||
Object lookup(String dn, String[] attributes, ContextMapper mapper) throws NamingException;
|
||||
<T> T lookup(String dn, String[] attributes, ContextMapper<T> mapper) throws NamingException;
|
||||
|
||||
/**
|
||||
* Modify an entry in the LDAP tree using the supplied
|
||||
@@ -1501,7 +1501,7 @@ public interface LdapOperations {
|
||||
* @throws IncorrectResultSizeDataAccessException if the result is not one unique entry
|
||||
* @since 1.3
|
||||
*/
|
||||
Object searchForObject(Name base, String filter, ContextMapper mapper);
|
||||
<T> T searchForObject(Name base, String filter, ContextMapper<T> mapper);
|
||||
|
||||
/**
|
||||
* Perform a search for a unique entry matching the specified search
|
||||
@@ -1516,5 +1516,5 @@ public interface LdapOperations {
|
||||
* @throws IncorrectResultSizeDataAccessException if the result is not one unique entry
|
||||
* @since 1.3
|
||||
*/
|
||||
Object searchForObject(String base, String filter, ContextMapper mapper);
|
||||
<T> T searchForObject(String base, String filter, ContextMapper<T> mapper);
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ import java.util.Set;
|
||||
*
|
||||
* @author Adam Skogman
|
||||
* @author Mattias Hellborg Arthursson
|
||||
* @deprecated {@link DistinguishedName and associated classes are deprecated as of 2.0}.
|
||||
* @deprecated {@link DistinguishedName} and associated classes are deprecated as of 2.0.
|
||||
*/
|
||||
public class LdapRdn implements Serializable, Comparable {
|
||||
private static final long serialVersionUID = 5681397547245228750L;
|
||||
|
||||
@@ -30,7 +30,7 @@ import java.net.URISyntaxException;
|
||||
* LdapRdnComponent represents one of these attributes.
|
||||
*
|
||||
* @author Mattias Hellborg Arthursson
|
||||
* @deprecated {@link DistinguishedName and associated classes are deprecated as of 2.0}.
|
||||
* @deprecated {@link DistinguishedName} and associated classes are deprecated as of 2.0.
|
||||
*/
|
||||
public class LdapRdnComponent implements Comparable, Serializable {
|
||||
private static final long serialVersionUID = -3296747972616243038L;
|
||||
|
||||
@@ -397,7 +397,7 @@ public class LdapTemplate implements LdapOperations, InitializingBean {
|
||||
* java.lang.String, int, java.lang.String[],
|
||||
* org.springframework.ldap.core.AttributesMapper)
|
||||
*/
|
||||
public List search(Name base, String filter, int searchScope, String[] attrs, AttributesMapper mapper) {
|
||||
public <T> List<T> search(Name base, String filter, int searchScope, String[] attrs, AttributesMapper<T> mapper) {
|
||||
return search(base, filter, getDefaultSearchControls(searchScope, DONT_RETURN_OBJ_FLAG, attrs), mapper);
|
||||
}
|
||||
|
||||
@@ -407,7 +407,7 @@ public class LdapTemplate implements LdapOperations, InitializingBean {
|
||||
* java.lang.String, int, java.lang.String[],
|
||||
* org.springframework.ldap.core.AttributesMapper)
|
||||
*/
|
||||
public List search(String base, String filter, int searchScope, String[] attrs, AttributesMapper mapper) {
|
||||
public <T> List<T> search(String base, String filter, int searchScope, String[] attrs, AttributesMapper<T> mapper) {
|
||||
return search(base, filter, getDefaultSearchControls(searchScope, DONT_RETURN_OBJ_FLAG, attrs), mapper);
|
||||
}
|
||||
|
||||
@@ -416,7 +416,7 @@ public class LdapTemplate implements LdapOperations, InitializingBean {
|
||||
* org.springframework.ldap.core.LdapOperations#search(javax.naming.Name,
|
||||
* java.lang.String, int, org.springframework.ldap.core.AttributesMapper)
|
||||
*/
|
||||
public List search(Name base, String filter, int searchScope, AttributesMapper mapper) {
|
||||
public <T> List<T> search(Name base, String filter, int searchScope, AttributesMapper<T> mapper) {
|
||||
|
||||
return search(base, filter, searchScope, ALL_ATTRIBUTES, mapper);
|
||||
}
|
||||
@@ -426,7 +426,7 @@ public class LdapTemplate implements LdapOperations, InitializingBean {
|
||||
* org.springframework.ldap.core.LdapOperations#search(java.lang.String,
|
||||
* java.lang.String, int, org.springframework.ldap.core.AttributesMapper)
|
||||
*/
|
||||
public List search(String base, String filter, int searchScope, AttributesMapper mapper) {
|
||||
public <T> List<T> search(String base, String filter, int searchScope, AttributesMapper<T> mapper) {
|
||||
|
||||
return search(base, filter, searchScope, ALL_ATTRIBUTES, mapper);
|
||||
}
|
||||
@@ -436,7 +436,7 @@ public class LdapTemplate implements LdapOperations, InitializingBean {
|
||||
* org.springframework.ldap.core.LdapOperations#search(javax.naming.Name,
|
||||
* java.lang.String, org.springframework.ldap.core.AttributesMapper)
|
||||
*/
|
||||
public List search(Name base, String filter, AttributesMapper mapper) {
|
||||
public <T> List<T> search(Name base, String filter, AttributesMapper<T> mapper) {
|
||||
|
||||
return search(base, filter, DEFAULT_SEARCH_SCOPE, mapper);
|
||||
}
|
||||
@@ -446,7 +446,7 @@ public class LdapTemplate implements LdapOperations, InitializingBean {
|
||||
* org.springframework.ldap.core.LdapOperations#search(java.lang.String,
|
||||
* java.lang.String, org.springframework.ldap.core.AttributesMapper)
|
||||
*/
|
||||
public List search(String base, String filter, AttributesMapper mapper) {
|
||||
public <T> List<T> search(String base, String filter, AttributesMapper<T> mapper) {
|
||||
|
||||
return search(base, filter, DEFAULT_SEARCH_SCOPE, mapper);
|
||||
}
|
||||
@@ -457,7 +457,7 @@ public class LdapTemplate implements LdapOperations, InitializingBean {
|
||||
* java.lang.String, int, java.lang.String[],
|
||||
* org.springframework.ldap.core.ContextMapper)
|
||||
*/
|
||||
public List search(Name base, String filter, int searchScope, String[] attrs, ContextMapper mapper) {
|
||||
public <T> List<T> search(Name base, String filter, int searchScope, String[] attrs, ContextMapper<T> mapper) {
|
||||
|
||||
return search(base, filter, getDefaultSearchControls(searchScope, RETURN_OBJ_FLAG, attrs), mapper);
|
||||
}
|
||||
@@ -468,7 +468,7 @@ public class LdapTemplate implements LdapOperations, InitializingBean {
|
||||
* java.lang.String, int, java.lang.String[],
|
||||
* org.springframework.ldap.core.ContextMapper)
|
||||
*/
|
||||
public List search(String base, String filter, int searchScope, String[] attrs, ContextMapper mapper) {
|
||||
public <T> List<T> search(String base, String filter, int searchScope, String[] attrs, ContextMapper<T> mapper) {
|
||||
|
||||
return search(base, filter, getDefaultSearchControls(searchScope, RETURN_OBJ_FLAG, attrs), mapper);
|
||||
}
|
||||
@@ -478,7 +478,7 @@ public class LdapTemplate implements LdapOperations, InitializingBean {
|
||||
* org.springframework.ldap.core.LdapOperations#search(javax.naming.Name,
|
||||
* java.lang.String, int, org.springframework.ldap.core.ContextMapper)
|
||||
*/
|
||||
public List search(Name base, String filter, int searchScope, ContextMapper mapper) {
|
||||
public <T> List<T> search(Name base, String filter, int searchScope, ContextMapper<T> mapper) {
|
||||
|
||||
return search(base, filter, searchScope, ALL_ATTRIBUTES, mapper);
|
||||
}
|
||||
@@ -488,7 +488,7 @@ public class LdapTemplate implements LdapOperations, InitializingBean {
|
||||
* org.springframework.ldap.core.LdapOperations#search(java.lang.String,
|
||||
* java.lang.String, int, org.springframework.ldap.core.ContextMapper)
|
||||
*/
|
||||
public List search(String base, String filter, int searchScope, ContextMapper mapper) {
|
||||
public <T> List<T> search(String base, String filter, int searchScope, ContextMapper<T> mapper) {
|
||||
|
||||
return search(base, filter, searchScope, ALL_ATTRIBUTES, mapper);
|
||||
}
|
||||
@@ -498,7 +498,7 @@ public class LdapTemplate implements LdapOperations, InitializingBean {
|
||||
* org.springframework.ldap.core.LdapOperations#search(javax.naming.Name,
|
||||
* java.lang.String, org.springframework.ldap.core.ContextMapper)
|
||||
*/
|
||||
public List search(Name base, String filter, ContextMapper mapper) {
|
||||
public <T> List<T> search(Name base, String filter, ContextMapper<T> mapper) {
|
||||
|
||||
return search(base, filter, DEFAULT_SEARCH_SCOPE, mapper);
|
||||
}
|
||||
@@ -508,7 +508,7 @@ public class LdapTemplate implements LdapOperations, InitializingBean {
|
||||
* org.springframework.ldap.core.LdapOperations#search(java.lang.String,
|
||||
* java.lang.String, org.springframework.ldap.core.ContextMapper)
|
||||
*/
|
||||
public List search(String base, String filter, ContextMapper mapper) {
|
||||
public <T> List<T> search(String base, String filter, ContextMapper<T> mapper) {
|
||||
|
||||
return search(base, filter, DEFAULT_SEARCH_SCOPE, mapper);
|
||||
}
|
||||
@@ -519,7 +519,7 @@ public class LdapTemplate implements LdapOperations, InitializingBean {
|
||||
* java.lang.String, javax.naming.directory.SearchControls,
|
||||
* org.springframework.ldap.core.ContextMapper)
|
||||
*/
|
||||
public List search(String base, String filter, SearchControls controls, ContextMapper mapper) {
|
||||
public <T> List<T> search(String base, String filter, SearchControls controls, ContextMapper<T> mapper) {
|
||||
|
||||
return search(base, filter, controls, mapper, new NullDirContextProcessor());
|
||||
}
|
||||
@@ -530,7 +530,7 @@ public class LdapTemplate implements LdapOperations, InitializingBean {
|
||||
* java.lang.String, javax.naming.directory.SearchControls,
|
||||
* org.springframework.ldap.core.ContextMapper)
|
||||
*/
|
||||
public List search(Name base, String filter, SearchControls controls, ContextMapper mapper) {
|
||||
public <T> List<T> search(Name base, String filter, SearchControls controls, ContextMapper<T> mapper) {
|
||||
|
||||
return search(base, filter, controls, mapper, new NullDirContextProcessor());
|
||||
}
|
||||
@@ -541,7 +541,7 @@ public class LdapTemplate implements LdapOperations, InitializingBean {
|
||||
* java.lang.String, javax.naming.directory.SearchControls,
|
||||
* org.springframework.ldap.core.AttributesMapper)
|
||||
*/
|
||||
public List search(Name base, String filter, SearchControls controls, AttributesMapper mapper) {
|
||||
public <T> List<T> search(Name base, String filter, SearchControls controls, AttributesMapper<T> mapper) {
|
||||
|
||||
return search(base, filter, controls, mapper, new NullDirContextProcessor());
|
||||
}
|
||||
@@ -552,7 +552,7 @@ public class LdapTemplate implements LdapOperations, InitializingBean {
|
||||
* java.lang.String, javax.naming.directory.SearchControls,
|
||||
* org.springframework.ldap.core.AttributesMapper)
|
||||
*/
|
||||
public List search(String base, String filter, SearchControls controls, AttributesMapper mapper) {
|
||||
public <T> List<T> search(String base, String filter, SearchControls controls, AttributesMapper<T> mapper) {
|
||||
return search(base, filter, controls, mapper, new NullDirContextProcessor());
|
||||
}
|
||||
|
||||
@@ -565,9 +565,9 @@ public class LdapTemplate implements LdapOperations, InitializingBean {
|
||||
* org.springframework.ldap.core.AttributesMapper,
|
||||
* org.springframework.ldap.core.DirContextProcessor)
|
||||
*/
|
||||
public List search(String base, String filter, SearchControls controls, AttributesMapper mapper,
|
||||
public <T> List<T> search(String base, String filter, SearchControls controls, AttributesMapper<T> mapper,
|
||||
DirContextProcessor processor) {
|
||||
AttributesMapperCallbackHandler handler = new AttributesMapperCallbackHandler(mapper);
|
||||
AttributesMapperCallbackHandler<T> handler = new AttributesMapperCallbackHandler<T>(mapper);
|
||||
search(base, filter, controls, handler, processor);
|
||||
|
||||
return handler.getList();
|
||||
@@ -582,9 +582,9 @@ public class LdapTemplate implements LdapOperations, InitializingBean {
|
||||
* org.springframework.ldap.core.AttributesMapper,
|
||||
* org.springframework.ldap.core.DirContextProcessor)
|
||||
*/
|
||||
public List search(Name base, String filter, SearchControls controls, AttributesMapper mapper,
|
||||
public <T> List<T> search(Name base, String filter, SearchControls controls, AttributesMapper<T> mapper,
|
||||
DirContextProcessor processor) {
|
||||
AttributesMapperCallbackHandler handler = new AttributesMapperCallbackHandler(mapper);
|
||||
AttributesMapperCallbackHandler<T> handler = new AttributesMapperCallbackHandler<T>(mapper);
|
||||
search(base, filter, controls, handler, processor);
|
||||
|
||||
return handler.getList();
|
||||
@@ -658,8 +658,8 @@ public class LdapTemplate implements LdapOperations, InitializingBean {
|
||||
* @see org.springframework.ldap.core.LdapOperations#list(java.lang.String,
|
||||
* org.springframework.ldap.core.NameClassPairMapper)
|
||||
*/
|
||||
public List list(String base, NameClassPairMapper mapper) {
|
||||
CollectingNameClassPairCallbackHandler handler = new MappingCollectingNameClassPairCallbackHandler(mapper);
|
||||
public <T> List<T> list(String base, NameClassPairMapper<T> mapper) {
|
||||
CollectingNameClassPairCallbackHandler<T> handler = new MappingCollectingNameClassPairCallbackHandler<T>(mapper);
|
||||
list(base, handler);
|
||||
return handler.getList();
|
||||
}
|
||||
@@ -668,8 +668,8 @@ public class LdapTemplate implements LdapOperations, InitializingBean {
|
||||
* @see org.springframework.ldap.core.LdapOperations#list(javax.naming.Name,
|
||||
* org.springframework.ldap.core.NameClassPairMapper)
|
||||
*/
|
||||
public List list(Name base, NameClassPairMapper mapper) {
|
||||
CollectingNameClassPairCallbackHandler handler = new MappingCollectingNameClassPairCallbackHandler(mapper);
|
||||
public <T> List<T> list(Name base, NameClassPairMapper<T> mapper) {
|
||||
CollectingNameClassPairCallbackHandler<T> handler = new MappingCollectingNameClassPairCallbackHandler<T>(mapper);
|
||||
list(base, handler);
|
||||
return handler.getList();
|
||||
}
|
||||
@@ -677,14 +677,14 @@ public class LdapTemplate implements LdapOperations, InitializingBean {
|
||||
/*
|
||||
* @see org.springframework.ldap.core.LdapOperations#list(javax.naming.Name)
|
||||
*/
|
||||
public List list(final Name base) {
|
||||
public List<String> list(final Name base) {
|
||||
return list(base, new DefaultNameClassPairMapper());
|
||||
}
|
||||
|
||||
/*
|
||||
* @see org.springframework.ldap.core.LdapOperations#list(java.lang.String)
|
||||
*/
|
||||
public List list(final String base) {
|
||||
public List<String> list(final String base) {
|
||||
return list(base, new DefaultNameClassPairMapper());
|
||||
}
|
||||
|
||||
@@ -723,8 +723,8 @@ public class LdapTemplate implements LdapOperations, InitializingBean {
|
||||
* org.springframework.ldap.core.LdapOperations#listBindings(java.lang.String
|
||||
* , org.springframework.ldap.core.NameClassPairMapper)
|
||||
*/
|
||||
public List listBindings(String base, NameClassPairMapper mapper) {
|
||||
CollectingNameClassPairCallbackHandler handler = new MappingCollectingNameClassPairCallbackHandler(mapper);
|
||||
public <T> List<T> listBindings(String base, NameClassPairMapper<T> mapper) {
|
||||
CollectingNameClassPairCallbackHandler<T> handler = new MappingCollectingNameClassPairCallbackHandler<T>(mapper);
|
||||
listBindings(base, handler);
|
||||
return handler.getList();
|
||||
}
|
||||
@@ -734,8 +734,8 @@ public class LdapTemplate implements LdapOperations, InitializingBean {
|
||||
* org.springframework.ldap.core.LdapOperations#listBindings(javax.naming
|
||||
* .Name, org.springframework.ldap.core.NameClassPairMapper)
|
||||
*/
|
||||
public List listBindings(Name base, NameClassPairMapper mapper) {
|
||||
CollectingNameClassPairCallbackHandler handler = new MappingCollectingNameClassPairCallbackHandler(mapper);
|
||||
public <T> List<T> listBindings(Name base, NameClassPairMapper<T> mapper) {
|
||||
CollectingNameClassPairCallbackHandler<T> handler = new MappingCollectingNameClassPairCallbackHandler<T>(mapper);
|
||||
listBindings(base, handler);
|
||||
return handler.getList();
|
||||
}
|
||||
@@ -745,7 +745,7 @@ public class LdapTemplate implements LdapOperations, InitializingBean {
|
||||
* org.springframework.ldap.core.LdapOperations#listBindings(java.lang.String
|
||||
* )
|
||||
*/
|
||||
public List listBindings(final String base) {
|
||||
public List<String> listBindings(final String base) {
|
||||
return listBindings(base, new DefaultNameClassPairMapper());
|
||||
}
|
||||
|
||||
@@ -754,7 +754,7 @@ public class LdapTemplate implements LdapOperations, InitializingBean {
|
||||
* org.springframework.ldap.core.LdapOperations#listBindings(javax.naming
|
||||
* .Name)
|
||||
*/
|
||||
public List listBindings(final Name base) {
|
||||
public List<String> listBindings(final Name base) {
|
||||
return listBindings(base, new DefaultNameClassPairMapper());
|
||||
}
|
||||
|
||||
@@ -763,9 +763,9 @@ public class LdapTemplate implements LdapOperations, InitializingBean {
|
||||
* org.springframework.ldap.core.LdapOperations#listBindings(java.lang.String
|
||||
* , org.springframework.ldap.core.ContextMapper)
|
||||
*/
|
||||
public List listBindings(String base, ContextMapper mapper) {
|
||||
public <T> List<T> listBindings(String base, ContextMapper<T> mapper) {
|
||||
|
||||
ContextMapperCallbackHandler handler = new ContextMapperCallbackHandler(mapper);
|
||||
ContextMapperCallbackHandler<T> handler = new ContextMapperCallbackHandler<T>(mapper);
|
||||
listBindings(base, handler);
|
||||
|
||||
return handler.getList();
|
||||
@@ -776,33 +776,27 @@ public class LdapTemplate implements LdapOperations, InitializingBean {
|
||||
* org.springframework.ldap.core.LdapOperations#listBindings(javax.naming
|
||||
* .Name, org.springframework.ldap.core.ContextMapper)
|
||||
*/
|
||||
public List listBindings(Name base, ContextMapper mapper) {
|
||||
public <T> List<T> listBindings(Name base, ContextMapper<T> mapper) {
|
||||
|
||||
ContextMapperCallbackHandler handler = new ContextMapperCallbackHandler(mapper);
|
||||
ContextMapperCallbackHandler<T> handler = new ContextMapperCallbackHandler<T>(mapper);
|
||||
listBindings(base, handler);
|
||||
|
||||
return handler.getList();
|
||||
}
|
||||
|
||||
/*
|
||||
* @seeorg.springframework.ldap.core.LdapOperations#executeReadOnly(org.
|
||||
* springframework.ldap.core.DirContextProcessor)
|
||||
*/
|
||||
public Object executeReadOnly(ContextExecutor ce) {
|
||||
@Override
|
||||
public <T> T executeReadOnly(ContextExecutor<T> ce) {
|
||||
DirContext ctx = contextSource.getReadOnlyContext();
|
||||
return executeWithContext(ce, ctx);
|
||||
}
|
||||
|
||||
/*
|
||||
* @seeorg.springframework.ldap.core.LdapOperations#executeReadWrite(org.
|
||||
* springframework.ldap.core.DirContextProcessor)
|
||||
*/
|
||||
public Object executeReadWrite(ContextExecutor ce) {
|
||||
@Override
|
||||
public <T> T executeReadWrite(ContextExecutor<T> ce) {
|
||||
DirContext ctx = contextSource.getReadWriteContext();
|
||||
return executeWithContext(ce, ctx);
|
||||
}
|
||||
|
||||
private Object executeWithContext(ContextExecutor ce, DirContext ctx) {
|
||||
private <T> T executeWithContext(ContextExecutor<T> ce, DirContext ctx) {
|
||||
try {
|
||||
return ce.executeWithContext(ctx);
|
||||
}
|
||||
@@ -843,9 +837,9 @@ public class LdapTemplate implements LdapOperations, InitializingBean {
|
||||
* org.springframework.ldap.core.LdapOperations#lookup(javax.naming.Name,
|
||||
* org.springframework.ldap.core.AttributesMapper)
|
||||
*/
|
||||
public Object lookup(final Name dn, final AttributesMapper mapper) {
|
||||
return executeReadOnly(new ContextExecutor() {
|
||||
public Object executeWithContext(DirContext ctx) throws javax.naming.NamingException {
|
||||
public <T> T lookup(final Name dn, final AttributesMapper<T> mapper) {
|
||||
return executeReadOnly(new ContextExecutor<T>() {
|
||||
public T executeWithContext(DirContext ctx) throws javax.naming.NamingException {
|
||||
Attributes attributes = ctx.getAttributes(dn);
|
||||
return mapper.mapFromAttributes(attributes);
|
||||
}
|
||||
@@ -857,10 +851,10 @@ public class LdapTemplate implements LdapOperations, InitializingBean {
|
||||
* org.springframework.ldap.core.LdapOperations#lookup(java.lang.String,
|
||||
* org.springframework.ldap.core.AttributesMapper)
|
||||
*/
|
||||
public Object lookup(final String dn, final AttributesMapper mapper) {
|
||||
public <T> T lookup(final String dn, final AttributesMapper<T> mapper) {
|
||||
|
||||
return executeReadOnly(new ContextExecutor() {
|
||||
public Object executeWithContext(DirContext ctx) throws javax.naming.NamingException {
|
||||
return executeReadOnly(new ContextExecutor<T>() {
|
||||
public T executeWithContext(DirContext ctx) throws javax.naming.NamingException {
|
||||
Attributes attributes = ctx.getAttributes(dn);
|
||||
return mapper.mapFromAttributes(attributes);
|
||||
}
|
||||
@@ -872,9 +866,9 @@ public class LdapTemplate implements LdapOperations, InitializingBean {
|
||||
* org.springframework.ldap.core.LdapOperations#lookup(javax.naming.Name,
|
||||
* org.springframework.ldap.core.ContextMapper)
|
||||
*/
|
||||
public Object lookup(final Name dn, final ContextMapper mapper) {
|
||||
return executeReadOnly(new ContextExecutor() {
|
||||
public Object executeWithContext(DirContext ctx) throws javax.naming.NamingException {
|
||||
public <T> T lookup(final Name dn, final ContextMapper<T> mapper) {
|
||||
return executeReadOnly(new ContextExecutor<T>() {
|
||||
public T executeWithContext(DirContext ctx) throws javax.naming.NamingException {
|
||||
Object object = ctx.lookup(dn);
|
||||
return mapper.mapFromContext(object);
|
||||
}
|
||||
@@ -886,10 +880,10 @@ public class LdapTemplate implements LdapOperations, InitializingBean {
|
||||
* org.springframework.ldap.core.LdapOperations#lookup(java.lang.String,
|
||||
* org.springframework.ldap.core.ContextMapper)
|
||||
*/
|
||||
public Object lookup(final String dn, final ContextMapper mapper) {
|
||||
public <T> T lookup(final String dn, final ContextMapper<T> mapper) {
|
||||
|
||||
return executeReadOnly(new ContextExecutor() {
|
||||
public Object executeWithContext(DirContext ctx) throws javax.naming.NamingException {
|
||||
return executeReadOnly(new ContextExecutor<T>() {
|
||||
public T executeWithContext(DirContext ctx) throws javax.naming.NamingException {
|
||||
Object object = ctx.lookup(dn);
|
||||
return mapper.mapFromContext(object);
|
||||
}
|
||||
@@ -901,10 +895,10 @@ public class LdapTemplate implements LdapOperations, InitializingBean {
|
||||
* org.springframework.ldap.core.LdapOperations#lookup(javax.naming.Name,
|
||||
* java.lang.String[], org.springframework.ldap.core.AttributesMapper)
|
||||
*/
|
||||
public Object lookup(final Name dn, final String[] attributes, final AttributesMapper mapper) {
|
||||
public <T> T lookup(final Name dn, final String[] attributes, final AttributesMapper<T> mapper) {
|
||||
|
||||
return executeReadOnly(new ContextExecutor() {
|
||||
public Object executeWithContext(DirContext ctx) throws javax.naming.NamingException {
|
||||
return executeReadOnly(new ContextExecutor<T>() {
|
||||
public T executeWithContext(DirContext ctx) throws javax.naming.NamingException {
|
||||
Attributes filteredAttributes = ctx.getAttributes(dn, attributes);
|
||||
return mapper.mapFromAttributes(filteredAttributes);
|
||||
}
|
||||
@@ -916,9 +910,9 @@ public class LdapTemplate implements LdapOperations, InitializingBean {
|
||||
* org.springframework.ldap.core.LdapOperations#lookup(java.lang.String,
|
||||
* java.lang.String[], org.springframework.ldap.core.AttributesMapper)
|
||||
*/
|
||||
public Object lookup(final String dn, final String[] attributes, final AttributesMapper mapper) {
|
||||
return executeReadOnly(new ContextExecutor() {
|
||||
public Object executeWithContext(DirContext ctx) throws javax.naming.NamingException {
|
||||
public <T> T lookup(final String dn, final String[] attributes, final AttributesMapper<T> mapper) {
|
||||
return executeReadOnly(new ContextExecutor<T>() {
|
||||
public T executeWithContext(DirContext ctx) throws javax.naming.NamingException {
|
||||
Attributes filteredAttributes = ctx.getAttributes(dn, attributes);
|
||||
return mapper.mapFromAttributes(filteredAttributes);
|
||||
}
|
||||
@@ -930,10 +924,10 @@ public class LdapTemplate implements LdapOperations, InitializingBean {
|
||||
* org.springframework.ldap.core.LdapOperations#lookup(javax.naming.Name,
|
||||
* java.lang.String[], org.springframework.ldap.core.ContextMapper)
|
||||
*/
|
||||
public Object lookup(final Name dn, final String[] attributes, final ContextMapper mapper) {
|
||||
public <T> T lookup(final Name dn, final String[] attributes, final ContextMapper<T> mapper) {
|
||||
|
||||
return executeReadOnly(new ContextExecutor() {
|
||||
public Object executeWithContext(DirContext ctx) throws javax.naming.NamingException {
|
||||
return executeReadOnly(new ContextExecutor<T>() {
|
||||
public T executeWithContext(DirContext ctx) throws javax.naming.NamingException {
|
||||
Attributes filteredAttributes = ctx.getAttributes(dn, attributes);
|
||||
DirContextAdapter contextAdapter = new DirContextAdapter(filteredAttributes, dn);
|
||||
return mapper.mapFromContext(contextAdapter);
|
||||
@@ -946,10 +940,10 @@ public class LdapTemplate implements LdapOperations, InitializingBean {
|
||||
* org.springframework.ldap.core.LdapOperations#lookup(java.lang.String,
|
||||
* java.lang.String[], org.springframework.ldap.core.ContextMapper)
|
||||
*/
|
||||
public Object lookup(final String dn, final String[] attributes, final ContextMapper mapper) {
|
||||
public <T> T lookup(final String dn, final String[] attributes, final ContextMapper<T> mapper) {
|
||||
|
||||
return executeReadOnly(new ContextExecutor() {
|
||||
public Object executeWithContext(DirContext ctx) throws javax.naming.NamingException {
|
||||
return executeReadOnly(new ContextExecutor<T>() {
|
||||
public T executeWithContext(DirContext ctx) throws javax.naming.NamingException {
|
||||
Attributes filteredAttributes = ctx.getAttributes(dn, attributes);
|
||||
LdapName name = LdapUtils.newLdapName(dn);
|
||||
DirContextAdapter contextAdapter = new DirContextAdapter(filteredAttributes, name);
|
||||
@@ -993,7 +987,7 @@ public class LdapTemplate implements LdapOperations, InitializingBean {
|
||||
*/
|
||||
public void bind(final Name dn, final Object obj, final Attributes attributes) {
|
||||
|
||||
executeReadWrite(new ContextExecutor() {
|
||||
executeReadWrite(new ContextExecutor<Object>() {
|
||||
public Object executeWithContext(DirContext ctx) throws javax.naming.NamingException {
|
||||
ctx.bind(dn, obj, attributes);
|
||||
return null;
|
||||
@@ -1007,7 +1001,7 @@ public class LdapTemplate implements LdapOperations, InitializingBean {
|
||||
*/
|
||||
public void bind(final String dn, final Object obj, final Attributes attributes) {
|
||||
|
||||
executeReadWrite(new ContextExecutor() {
|
||||
executeReadWrite(new ContextExecutor<Object>() {
|
||||
public Object executeWithContext(DirContext ctx) throws javax.naming.NamingException {
|
||||
ctx.bind(dn, obj, attributes);
|
||||
return null;
|
||||
@@ -1060,7 +1054,7 @@ public class LdapTemplate implements LdapOperations, InitializingBean {
|
||||
}
|
||||
|
||||
private void doUnbind(final Name dn) {
|
||||
executeReadWrite(new ContextExecutor() {
|
||||
executeReadWrite(new ContextExecutor<Object>() {
|
||||
public Object executeWithContext(DirContext ctx) throws javax.naming.NamingException {
|
||||
ctx.unbind(dn);
|
||||
return null;
|
||||
@@ -1069,7 +1063,7 @@ public class LdapTemplate implements LdapOperations, InitializingBean {
|
||||
}
|
||||
|
||||
private void doUnbind(final String dn) {
|
||||
executeReadWrite(new ContextExecutor() {
|
||||
executeReadWrite(new ContextExecutor<Object>() {
|
||||
public Object executeWithContext(DirContext ctx) throws javax.naming.NamingException {
|
||||
ctx.unbind(dn);
|
||||
return null;
|
||||
@@ -1078,7 +1072,7 @@ public class LdapTemplate implements LdapOperations, InitializingBean {
|
||||
}
|
||||
|
||||
private void doUnbindRecursively(final Name dn) {
|
||||
executeReadWrite(new ContextExecutor() {
|
||||
executeReadWrite(new ContextExecutor<Object>() {
|
||||
public Object executeWithContext(DirContext ctx) {
|
||||
deleteRecursively(ctx, LdapUtils.newLdapName(dn));
|
||||
return null;
|
||||
@@ -1087,7 +1081,7 @@ public class LdapTemplate implements LdapOperations, InitializingBean {
|
||||
}
|
||||
|
||||
private void doUnbindRecursively(final String dn) {
|
||||
executeReadWrite(new ContextExecutor() {
|
||||
executeReadWrite(new ContextExecutor<Object>() {
|
||||
public Object executeWithContext(DirContext ctx) throws javax.naming.NamingException {
|
||||
deleteRecursively(ctx, LdapUtils.newLdapName(dn));
|
||||
return null;
|
||||
@@ -1281,12 +1275,12 @@ public class LdapTemplate implements LdapOperations, InitializingBean {
|
||||
*
|
||||
* @author Mattias Hellborg Arthursson
|
||||
*/
|
||||
public final static class MappingCollectingNameClassPairCallbackHandler extends
|
||||
CollectingNameClassPairCallbackHandler {
|
||||
public final static class MappingCollectingNameClassPairCallbackHandler<T> extends
|
||||
CollectingNameClassPairCallbackHandler<T> {
|
||||
|
||||
private NameClassPairMapper mapper;
|
||||
private NameClassPairMapper<T> mapper;
|
||||
|
||||
public MappingCollectingNameClassPairCallbackHandler(NameClassPairMapper mapper) {
|
||||
public MappingCollectingNameClassPairCallbackHandler(NameClassPairMapper<T> mapper) {
|
||||
this.mapper = mapper;
|
||||
}
|
||||
|
||||
@@ -1294,7 +1288,7 @@ public class LdapTemplate implements LdapOperations, InitializingBean {
|
||||
* @seeorg.springframework.ldap.CollectingNameClassPairCallbackHandler#
|
||||
* getObjectFromNameClassPair(javax.naming.NameClassPair)
|
||||
*/
|
||||
public Object getObjectFromNameClassPair(NameClassPair nameClassPair) {
|
||||
public T getObjectFromNameClassPair(NameClassPair nameClassPair) {
|
||||
try {
|
||||
return mapper.mapFromNameClassPair(nameClassPair);
|
||||
}
|
||||
@@ -1493,7 +1487,7 @@ public class LdapTemplate implements LdapOperations, InitializingBean {
|
||||
|
||||
try {
|
||||
DirContext ctx = contextSource.getContext(entryIdentification.getAbsoluteDn().toString(), password);
|
||||
executeWithContext(new ContextExecutor() {
|
||||
executeWithContext(new ContextExecutor<Object>() {
|
||||
public Object executeWithContext(DirContext ctx) throws javax.naming.NamingException {
|
||||
callback.executeWithContext(ctx, entryIdentification);
|
||||
return null;
|
||||
@@ -1515,8 +1509,8 @@ public class LdapTemplate implements LdapOperations, InitializingBean {
|
||||
* org.springframework.ldap.core.LdapOperations#searchForObject(javax.naming
|
||||
* .Name, java.lang.String, org.springframework.ldap.core.ContextMapper)
|
||||
*/
|
||||
public Object searchForObject(Name base, String filter, ContextMapper mapper) {
|
||||
List result = search(base, filter, mapper);
|
||||
public <T> T searchForObject(Name base, String filter, ContextMapper<T> mapper) {
|
||||
List<T> result = search(base, filter, mapper);
|
||||
if (result.size() == 0) {
|
||||
throw new EmptyResultDataAccessException(1);
|
||||
}
|
||||
@@ -1534,7 +1528,7 @@ public class LdapTemplate implements LdapOperations, InitializingBean {
|
||||
* org.springframework.ldap.core.LdapOperations#searchForObject(java.lang
|
||||
* .String, java.lang.String, org.springframework.ldap.core.ContextMapper)
|
||||
*/
|
||||
public Object searchForObject(String base, String filter, ContextMapper mapper) {
|
||||
public <T> T searchForObject(String base, String filter, ContextMapper<T> mapper) {
|
||||
return searchForObject(LdapUtils.newLdapName(base), filter, mapper);
|
||||
}
|
||||
|
||||
|
||||
@@ -40,5 +40,4 @@ public interface NameClassPairCallbackHandler {
|
||||
* @throws NamingException if an error occurs.
|
||||
*/
|
||||
void handleNameClassPair(NameClassPair nameClassPair) throws NamingException;
|
||||
;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2005-2010 the original author or authors.
|
||||
* 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.
|
||||
@@ -24,7 +24,7 @@ import javax.naming.NamingException;
|
||||
*
|
||||
* @author Mattias Hellborg Arthursson
|
||||
*/
|
||||
public interface NameClassPairMapper {
|
||||
public interface NameClassPairMapper<T> {
|
||||
/**
|
||||
* Map <code>NameClassPair</code> to an Object. The supplied
|
||||
* <code>NameClassPair</code> is one of the results from a search
|
||||
@@ -39,6 +39,6 @@ public interface NameClassPairMapper {
|
||||
* @throws NamingException
|
||||
* if one is encountered in the operation.
|
||||
*/
|
||||
Object mapFromNameClassPair(NameClassPair nameClassPair)
|
||||
T mapFromNameClassPair(NameClassPair nameClassPair)
|
||||
throws NamingException;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2005-2010 the original author or authors.
|
||||
* 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.
|
||||
@@ -29,7 +29,7 @@ import org.springframework.ldap.core.DirContextOperations;
|
||||
* @author Mattias Hellborg Arthursson
|
||||
*
|
||||
*/
|
||||
public abstract class AbstractContextMapper implements ContextMapper {
|
||||
public abstract class AbstractContextMapper<T> implements ContextMapper<T> {
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
@@ -39,7 +39,7 @@ public abstract class AbstractContextMapper implements ContextMapper {
|
||||
* used, causing the objects passed in be anything else than
|
||||
* {@link DirContextOperations} instances.
|
||||
*/
|
||||
public final Object mapFromContext(Object ctx) {
|
||||
public final T mapFromContext(Object ctx) {
|
||||
return doMapFromContext((DirContextOperations) ctx);
|
||||
}
|
||||
|
||||
@@ -53,6 +53,6 @@ public abstract class AbstractContextMapper implements ContextMapper {
|
||||
* the context to map to an object.
|
||||
* @return an object built from the data in the context.
|
||||
*/
|
||||
protected abstract Object doMapFromContext(DirContextOperations ctx);
|
||||
protected abstract T doMapFromContext(DirContextOperations ctx);
|
||||
|
||||
}
|
||||
|
||||
@@ -301,7 +301,7 @@ public abstract class AbstractContextSource implements BaseLdapPathContextSource
|
||||
|
||||
/**
|
||||
* @return
|
||||
* @deprecated {@link DistinguishedName and associated classes and methods are deprecated as of 2.0}.
|
||||
* @deprecated {@link DistinguishedName} and associated classes and methods are deprecated as of 2.0.
|
||||
*/
|
||||
@Override
|
||||
public DistinguishedName getBaseLdapPath() {
|
||||
|
||||
@@ -37,7 +37,7 @@ import org.springframework.ldap.core.DistinguishedName;
|
||||
*
|
||||
* @author Mattias Hellborg Arthursson
|
||||
* @since 1.2
|
||||
* @deprecated {@link DistinguishedName and associated classes and methods are deprecated as of 2.0}.
|
||||
* @deprecated {@link DistinguishedName} and associated classes and methods are deprecated as of 2.0.
|
||||
* Use {@link BaseLdapNameAware} instead.
|
||||
*/
|
||||
public interface BaseLdapPathAware {
|
||||
|
||||
@@ -124,7 +124,7 @@ public class BaseLdapPathBeanPostProcessor implements BeanPostProcessor, Applica
|
||||
* <code>ApplicationContext</code>.
|
||||
*
|
||||
* @param basePath the base path.
|
||||
* @deprecated {@link DistinguishedName and associated classes and methods are deprecated as of 2.0}.
|
||||
* @deprecated {@link DistinguishedName} and associated classes and methods are deprecated as of 2.0.
|
||||
*/
|
||||
public void setBasePath(DistinguishedName basePath) {
|
||||
this.basePath = LdapUtils.newLdapName(basePath);
|
||||
|
||||
@@ -35,7 +35,7 @@ public interface BaseLdapPathSource {
|
||||
*
|
||||
* @return the base LDAP path as a {@link DistinguishedName}. The path will
|
||||
* be empty if no base path is specified.
|
||||
* @deprecated {@link DistinguishedName and associated classes and methods are deprecated as of 2.0}.
|
||||
* @deprecated {@link DistinguishedName} and associated classes and methods are deprecated as of 2.0.
|
||||
* Use {@link #getBaseLdapName()} instead.
|
||||
*/
|
||||
DistinguishedName getBaseLdapPath();
|
||||
|
||||
@@ -18,7 +18,6 @@ package org.springframework.ldap.core.support;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.ldap.core.AttributesMapper;
|
||||
import org.springframework.ldap.core.IncrementalAttributesMapper;
|
||||
import org.springframework.ldap.core.LdapOperations;
|
||||
import org.springframework.ldap.support.LdapUtils;
|
||||
@@ -33,7 +32,6 @@ import javax.naming.directory.BasicAttributes;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.LinkedList;
|
||||
@@ -75,38 +73,44 @@ import java.util.Set;
|
||||
* @see #lookupAttributeValues(org.springframework.ldap.core.LdapOperations, javax.naming.Name, String)
|
||||
* @since 1.3.2
|
||||
*/
|
||||
public class DefaultIncrementalAttributesMapper implements AttributesMapper, IncrementalAttributesMapper {
|
||||
public class DefaultIncrementalAttributesMapper implements IncrementalAttributesMapper<DefaultIncrementalAttributesMapper> {
|
||||
private final static Log log = LogFactory.getLog(DefaultIncrementalAttributesMapper.class);
|
||||
|
||||
private Map stateMap = new LinkedHashMap();
|
||||
private Set rangedAttributesInNextIteration = new LinkedHashSet();
|
||||
private Map<String, IncrementalAttributeState> stateMap = new LinkedHashMap<String, IncrementalAttributeState>();
|
||||
private Set<String> rangedAttributesInNextIteration = new LinkedHashSet<String>();
|
||||
|
||||
/**
|
||||
* This guy will be used when an unmapped attribute is encountered. This really should never happen,
|
||||
* but this saves us a number of null checks.
|
||||
*/
|
||||
private final static IncrementalAttributeState NOT_FOUND_ATTRIBUTE_STATE = new IncrementalAttributeState() {
|
||||
@Override
|
||||
public String getRequestedAttributeName() {
|
||||
throw new UnsupportedOperationException("This method should never be called");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasMore() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void calculateNextRange(RangeOption responseRange) {
|
||||
// Nothing to do here
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAttributeNameForQuery() {
|
||||
throw new UnsupportedOperationException("This method should never be called");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processValues(Attributes attributes, String attributeName) throws NamingException {
|
||||
// Nothing to do here
|
||||
}
|
||||
|
||||
public List getValues() {
|
||||
@Override
|
||||
public List<Object> getValues() {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
@@ -154,20 +158,20 @@ public class DefaultIncrementalAttributesMapper implements AttributesMapper, Inc
|
||||
* values are managed.
|
||||
*/
|
||||
public DefaultIncrementalAttributesMapper(int pageSize, String[] attributeNames) {
|
||||
for (int i = 0; i < attributeNames.length; i++) {
|
||||
String attributeName = attributeNames[i];
|
||||
for (String attributeName : attributeNames) {
|
||||
this.stateMap.put(attributeName, new DefaultIncrementalAttributeState(attributeName, pageSize));
|
||||
this.rangedAttributesInNextIteration.add(attributeName);
|
||||
}
|
||||
}
|
||||
|
||||
public final Object mapFromAttributes(Attributes attributes) throws NamingException {
|
||||
@Override
|
||||
public final DefaultIncrementalAttributesMapper mapFromAttributes(Attributes attributes) throws NamingException {
|
||||
if (!hasMore()) {
|
||||
throw new IllegalStateException("No more attributes!");
|
||||
}
|
||||
|
||||
// Reset the affected attributes.
|
||||
rangedAttributesInNextIteration = new HashSet();
|
||||
rangedAttributesInNextIteration = new HashSet<String>();
|
||||
|
||||
NamingEnumeration attributeNameEnum = attributes.getIDs();
|
||||
while (attributeNameEnum.hasMore()) {
|
||||
@@ -179,9 +183,7 @@ public class DefaultIncrementalAttributesMapper implements AttributesMapper, Inc
|
||||
// No range specification for this attribute
|
||||
state.processValues(attributes, attributeName);
|
||||
} else {
|
||||
for (int i = 0; i < attributeNameSplit.length; i++) {
|
||||
String option = attributeNameSplit[i];
|
||||
|
||||
for (String option : attributeNameSplit) {
|
||||
RangeOption responseRange = RangeOption.parse(option);
|
||||
|
||||
if (responseRange != null) {
|
||||
@@ -208,22 +210,21 @@ public class DefaultIncrementalAttributesMapper implements AttributesMapper, Inc
|
||||
return (IncrementalAttributeState) mappedState;
|
||||
}
|
||||
|
||||
public final List getValues(String attributeName) {
|
||||
@Override
|
||||
public final List<Object> getValues(String attributeName) {
|
||||
return getState(attributeName).getValues();
|
||||
}
|
||||
|
||||
public Attributes getCollectedAttributes() {
|
||||
@Override
|
||||
public final Attributes getCollectedAttributes() {
|
||||
BasicAttributes attributes = new BasicAttributes();
|
||||
|
||||
Set attributeNames = stateMap.keySet();
|
||||
for (Iterator iterator = attributeNames.iterator(); iterator.hasNext(); ) {
|
||||
String attributeName = (String) iterator.next();
|
||||
|
||||
Set<String> attributeNames = stateMap.keySet();
|
||||
for (String attributeName : attributeNames) {
|
||||
BasicAttribute oneAttribute = new BasicAttribute(attributeName);
|
||||
List values = getValues(attributeName);
|
||||
if (values != null) {
|
||||
for (Iterator valueIterator = values.iterator(); valueIterator.hasNext(); ) {
|
||||
Object oneValue = valueIterator.next();
|
||||
for (Object oneValue : values) {
|
||||
oneAttribute.add(oneValue);
|
||||
}
|
||||
}
|
||||
@@ -234,16 +235,17 @@ public class DefaultIncrementalAttributesMapper implements AttributesMapper, Inc
|
||||
return attributes;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean hasMore() {
|
||||
return rangedAttributesInNextIteration.size() > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final String[] getAttributesForLookup() {
|
||||
String[] result = new String[rangedAttributesInNextIteration.size()];
|
||||
int index = 0;
|
||||
for (Iterator iterator = rangedAttributesInNextIteration.iterator(); iterator.hasNext(); ) {
|
||||
String next = (String) iterator.next();
|
||||
IncrementalAttributeState state = (IncrementalAttributeState) stateMap.get(next);
|
||||
for (String next : rangedAttributesInNextIteration) {
|
||||
IncrementalAttributeState state = stateMap.get(next);
|
||||
result[index++] = state.getAttributeNameForQuery();
|
||||
}
|
||||
|
||||
@@ -315,7 +317,7 @@ public class DefaultIncrementalAttributesMapper implements AttributesMapper, Inc
|
||||
* @return a list with all attribute values found for the requested attribute.
|
||||
* Never <code>null</code>, an empty list indicates that the attribute was not set or empty.
|
||||
*/
|
||||
public static List lookupAttributeValues(LdapOperations ldapOperations, String dn, String attribute) {
|
||||
public static List<Object> lookupAttributeValues(LdapOperations ldapOperations, String dn, String attribute) {
|
||||
return lookupAttributeValues(ldapOperations, LdapUtils.newLdapName(dn), attribute);
|
||||
}
|
||||
|
||||
@@ -328,8 +330,8 @@ public class DefaultIncrementalAttributesMapper implements AttributesMapper, Inc
|
||||
* @return a list with all attribute values found for the requested attribute.
|
||||
* Never <code>null</code>, an empty list indicates that the attribute was not set or empty.
|
||||
*/
|
||||
public static List lookupAttributeValues(LdapOperations ldapOperations, Name dn, String attribute) {
|
||||
List values = loopForAllAttributeValues(ldapOperations, dn, new String[]{attribute}).getValues(attribute);
|
||||
public static List<Object> lookupAttributeValues(LdapOperations ldapOperations, Name dn, String attribute) {
|
||||
List<Object> values = loopForAllAttributeValues(ldapOperations, dn, new String[]{attribute}).getValues(attribute);
|
||||
if(values == null) {
|
||||
values = Collections.emptyList();
|
||||
}
|
||||
@@ -352,7 +354,7 @@ public class DefaultIncrementalAttributesMapper implements AttributesMapper, Inc
|
||||
*/
|
||||
private final static class DefaultIncrementalAttributeState implements IncrementalAttributeState {
|
||||
private final String actualAttributeName;
|
||||
private List values = null;
|
||||
private List<Object> values = null;
|
||||
private final int pageSize;
|
||||
boolean more = true;
|
||||
|
||||
@@ -364,14 +366,17 @@ public class DefaultIncrementalAttributesMapper implements AttributesMapper, Inc
|
||||
this.requestRange = new RangeOption(0, pageSize);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasMore() {
|
||||
return more;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRequestedAttributeName() {
|
||||
return actualAttributeName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void calculateNextRange(RangeOption responseRange) {
|
||||
more = requestRange.compareTo(responseRange) > 0;
|
||||
|
||||
@@ -380,6 +385,7 @@ public class DefaultIncrementalAttributesMapper implements AttributesMapper, Inc
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAttributeNameForQuery() {
|
||||
StringBuilder attributeBuilder = new StringBuilder(actualAttributeName);
|
||||
|
||||
@@ -391,6 +397,7 @@ public class DefaultIncrementalAttributesMapper implements AttributesMapper, Inc
|
||||
return attributeBuilder.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processValues(Attributes attributes, String attributeName) throws NamingException {
|
||||
Attribute attribute = attributes.get(attributeName);
|
||||
NamingEnumeration valueEnum = attribute.getAll();
|
||||
@@ -403,13 +410,14 @@ public class DefaultIncrementalAttributesMapper implements AttributesMapper, Inc
|
||||
|
||||
private void initValuesIfApplicable() {
|
||||
if (values == null) {
|
||||
values = new LinkedList();
|
||||
values = new LinkedList<Object>();
|
||||
}
|
||||
}
|
||||
|
||||
public List getValues() {
|
||||
@Override
|
||||
public List<Object> getValues() {
|
||||
if (values != null) {
|
||||
return new ArrayList(values);
|
||||
return new ArrayList<Object>(values);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
@@ -430,6 +438,6 @@ public class DefaultIncrementalAttributesMapper implements AttributesMapper, Inc
|
||||
|
||||
void processValues(Attributes attributes, String attributeName) throws NamingException;
|
||||
|
||||
List getValues();
|
||||
List<Object> getValues();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,12 +1,28 @@
|
||||
package org.springframework.ldap.core.support;
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
import javax.naming.NamingException;
|
||||
import javax.naming.directory.DirContext;
|
||||
package org.springframework.ldap.core.support;
|
||||
|
||||
import org.springframework.ldap.core.AuthenticatedLdapEntryContextCallback;
|
||||
import org.springframework.ldap.core.LdapEntryIdentification;
|
||||
import org.springframework.ldap.support.LdapUtils;
|
||||
|
||||
import javax.naming.NamingException;
|
||||
import javax.naming.directory.DirContext;
|
||||
|
||||
/**
|
||||
* Attempts to perform an LDAP operation in the authenticated context, because
|
||||
* Active Directory might allow bind with incorrect password (specifically empty
|
||||
@@ -19,7 +35,7 @@ import org.springframework.ldap.support.LdapUtils;
|
||||
public class LookupAttemptingCallback implements AuthenticatedLdapEntryContextCallback {
|
||||
public void executeWithContext(DirContext ctx, LdapEntryIdentification ldapEntryIdentification) {
|
||||
try {
|
||||
ctx.lookup(ldapEntryIdentification.getRelativeDn());
|
||||
ctx.lookup(ldapEntryIdentification.getRelativeName());
|
||||
}
|
||||
catch (NamingException e) {
|
||||
// rethrow, because we aren't allowed to throw checked exceptions.
|
||||
|
||||
@@ -28,7 +28,7 @@ import java.util.regex.Matcher;
|
||||
* @see DefaultIncrementalAttributesMapper
|
||||
* @since 1.3.2
|
||||
*/
|
||||
class RangeOption implements Comparable {
|
||||
class RangeOption implements Comparable<RangeOption> {
|
||||
public static final int TERMINAL_END_OF_RANGE = -1;
|
||||
public static final int TERMINAL_MISSING = -2;
|
||||
|
||||
@@ -124,14 +124,7 @@ class RangeOption implements Comparable {
|
||||
return new RangeOption(initial, terminal);
|
||||
}
|
||||
|
||||
public int compareTo(Object o) {
|
||||
RangeOption that;
|
||||
if (o instanceof RangeOption) {
|
||||
that = (RangeOption) o;
|
||||
} else {
|
||||
throw new IllegalArgumentException("A RangeOption instance cannot be compared to " + o.getClass());
|
||||
}
|
||||
|
||||
public int compareTo(RangeOption that) {
|
||||
if (this.getInitial() != that.getInitial())
|
||||
throw new IllegalStateException("Ranges cannot be compared, range-initial not the same: " + this.toString() + " vs " + that.toString());
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2005-2010 the original author or authors.
|
||||
* 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.
|
||||
@@ -43,6 +43,7 @@ import java.util.NoSuchElementException;
|
||||
* the framework, but also useful for custom code.
|
||||
*
|
||||
* @author Ulrik Sandberg
|
||||
* @author Mattias Hellborg Arthursson
|
||||
* @since 1.2
|
||||
*/
|
||||
public final class LdapUtils {
|
||||
|
||||
Reference in New Issue
Block a user