Package org.ldaptive.auth
Class AggregateDnResolver
- java.lang.Object
-
- org.ldaptive.AbstractFreezable
-
- org.ldaptive.auth.AggregateDnResolver
-
- All Implemented Interfaces:
DnResolver
,Freezable
public final class AggregateDnResolver extends AbstractFreezable implements DnResolver
Looks up a user's DN using multiple DN resolvers. Each DN resolver is invoked on a separate thread. If multiple DNs are allowed then the first one retrieved is returned.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
AggregateDnResolver.Builder
-
Field Summary
Fields Modifier and Type Field Description private boolean
allowMultipleDns
Whether to throw an exception if multiple DNs are found.private CallableWorker<String>
callableWorker
To submit operations to.private Map<String,DnResolver>
dnResolvers
Labeled DN resolvers.private Logger
logger
Logger for this class.
-
Constructor Summary
Constructors Constructor Description AggregateDnResolver()
Default constructor.AggregateDnResolver(Map<String,DnResolver> resolvers)
Creates a new aggregate dn resolver.AggregateDnResolver(Map<String,DnResolver> resolvers, ExecutorService es)
Creates a new aggregate dn resolver.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addDnResolver(String label, DnResolver resolver)
Adds a DN resolver with the supplied label.static AggregateDnResolver.Builder
builder()
Creates a builder for this class.EntryResolver
createEntryResolver(EntryResolver resolver)
Creates an aggregate entry resolver using the labels from the DN resolver and the supplied entry resolver.void
freeze()
Freezes this object, making it immutable.boolean
getAllowMultipleDns()
Returns whether DN resolution should fail if multiple DNs are found.Map<String,DnResolver>
getDnResolvers()
Returns the DN resolvers to aggregate over.String
resolve(User user)
Attempts to find the LDAP DN for the supplied user.void
setAllowMultipleDns(boolean b)
Sets whether DN resolution should fail if multiple DNs are found If false an exception will be thrown ifresolve(User)
finds that more than one DN resolver returns a DN.void
setDnResolvers(Map<String,DnResolver> resolvers)
Sets the DN resolvers to aggregate over.void
shutdown()
InvokesExecutorService.shutdown()
on the underlying executor service.-
Methods inherited from class org.ldaptive.AbstractFreezable
assertMutable, freeze, freeze, isFrozen
-
-
-
-
Field Detail
-
logger
private final Logger logger
Logger for this class.
-
callableWorker
private final CallableWorker<String> callableWorker
To submit operations to.
-
dnResolvers
private final Map<String,DnResolver> dnResolvers
Labeled DN resolvers.
-
allowMultipleDns
private boolean allowMultipleDns
Whether to throw an exception if multiple DNs are found.
-
-
Constructor Detail
-
AggregateDnResolver
public AggregateDnResolver()
Default constructor.
-
AggregateDnResolver
public AggregateDnResolver(Map<String,DnResolver> resolvers)
Creates a new aggregate dn resolver.- Parameters:
resolvers
- dn resolvers
-
AggregateDnResolver
public AggregateDnResolver(Map<String,DnResolver> resolvers, ExecutorService es)
Creates a new aggregate dn resolver.- Parameters:
resolvers
- dn resolverses
- executor service for invoking DN resolvers
-
-
Method Detail
-
freeze
public void freeze()
Description copied from interface:Freezable
Freezes this object, making it immutable.- Specified by:
freeze
in interfaceFreezable
- Overrides:
freeze
in classAbstractFreezable
-
getDnResolvers
public Map<String,DnResolver> getDnResolvers()
Returns the DN resolvers to aggregate over.- Returns:
- map of label to dn resolver
-
setDnResolvers
public void setDnResolvers(Map<String,DnResolver> resolvers)
Sets the DN resolvers to aggregate over.- Parameters:
resolvers
- to set
-
addDnResolver
public void addDnResolver(String label, DnResolver resolver)
Adds a DN resolver with the supplied label.- Parameters:
label
- of the resolverresolver
- DN resolver
-
getAllowMultipleDns
public boolean getAllowMultipleDns()
Returns whether DN resolution should fail if multiple DNs are found.- Returns:
- whether an exception will be thrown if multiple DNs are found
-
setAllowMultipleDns
public void setAllowMultipleDns(boolean b)
Sets whether DN resolution should fail if multiple DNs are found If false an exception will be thrown ifresolve(User)
finds that more than one DN resolver returns a DN. Otherwise, the first DN found is returned.- Parameters:
b
- whether multiple DNs are allowed
-
createEntryResolver
public EntryResolver createEntryResolver(EntryResolver resolver)
Creates an aggregate entry resolver using the labels from the DN resolver and the supplied entry resolver.- Parameters:
resolver
- used for every label- Returns:
- aggregate entry resolver
-
resolve
public String resolve(User user) throws LdapException
Description copied from interface:DnResolver
Attempts to find the LDAP DN for the supplied user.- Specified by:
resolve
in interfaceDnResolver
- Parameters:
user
- to find DN for- Returns:
- user DN
- Throws:
LdapException
- if an LDAP error occurs
-
shutdown
public void shutdown()
InvokesExecutorService.shutdown()
on the underlying executor service.
-
builder
public static AggregateDnResolver.Builder builder()
Creates a builder for this class.- Returns:
- new builder
-
-