public class LDAPFilterDescriptor
extends java.lang.Object
Once you read in a filter file to create an object of this class,
you can access the filter information through the methods that create
LDAPFilterList and LDAPFilter objects.
(You do not need to manually construct these objects yourself.)
This class (along with the other LDAP filter classes) provide functionality equivalent to the LDAP filter functions in the LDAP C API.
The format of the file/URL/buffer must be that as defined in the ldapfilter.conf(5) man page from the University of Michigan LDAP-3.3 distribution.
The LDAP filter classes provide a powerful way to configure LDAP clients by modifying a configuration file.
The following is a short example for how to use the LDAP filter classes.
// ... Setup LDAPConnection up here ...LDAPFilterDescriptor filterDescriptor;
// Create the LDAPFilterDescriptor given the file // "ldapfilter.conf". try { filterDescriptor = new LDAPFilterDescriptor ( "ldapfilter.conf" );
// Now retrieve the Filters in the form of an // LDAPFilterList LDAPFilterList filterList = new filterDescriptor.getFilters("match_tag", "string_user_typed");
// For each filter, do the search. Normally, you wouldn't // do the search if the first filter matched, but this is // just showing the enumeration type aspects of // LDAPFilterList LDAPFilter filter; while ( filterList.hasMoreElements() ) { filter = filterList.next(); LDAPResults results = LDAPConnection.search ( strBase, // base DN filter.getScope(), // scope filter.getFilter(), // completed filter null, // all attribs false ); // attrsOnly? }
// ...more processing here... } catch ( BadFilterException e ) { System.out.println ( e.toString() ); System.exit ( 0 ); } catch ( IOException e ) { // ...handle exception here... }
LDAPFilterList,
LDAPFilter| Constructor and Description |
|---|
LDAPFilterDescriptor(java.lang.String strFile)
Creates an LDAPFilterDescriptor object from an existing filter
configuration file.
|
LDAPFilterDescriptor(java.lang.StringBuffer strBuffer)
Creates an LDAPFilterDescriptor object from an existing
StringBuffer.
|
LDAPFilterDescriptor(java.net.URL url)
Creates an LDAPFilterDescriptor object from a URL.
|
| Modifier and Type | Method and Description |
|---|---|
LDAPFilterList |
getFilters(java.lang.String strTagPat,
java.lang.String strValue)
Return all the filters which match the strTagPat (regular
expression), and the user input (strValue)
|
void |
setFilterAffixes(java.lang.String strPrefix,
java.lang.String strAffix)
Prepend the parameter (strPrefix) and append the second
parameter (strAffix) to every filter that is returned by the
getFilters() method.
|
java.lang.String |
toString()
Output a text dump of this filter descriptor.
|
public LDAPFilterDescriptor(java.lang.String strFile)
throws java.io.FileNotFoundException,
BadFilterException
BadFilterException - One of the filters was not generated properly. Most likely
this is due to an improperly formatted ldapfilter.conf file.java.io.FileNotFoundExceptionpublic LDAPFilterDescriptor(java.lang.StringBuffer strBuffer)
throws BadFilterException
BadFilterException - One of the filters was not generated properly. Most likely
this is due to an improperly formatted ldapfilter.conf file.public LDAPFilterDescriptor(java.net.URL url)
throws java.io.IOException,
BadFilterException
BadFilterException - One of the filters was not generated properly. Most likely
this is due to an improperly formatted ldapfilter.conf file.java.io.IOExceptionpublic java.lang.String toString()
toString in class java.lang.ObjectLDAPIntFilterSet.toString()public LDAPFilterList getFilters(java.lang.String strTagPat, java.lang.String strValue) throws java.lang.IllegalArgumentException
java.lang.IllegalArgumentExceptionpublic void setFilterAffixes(java.lang.String strPrefix,
java.lang.String strAffix)