Class LDAPFilterDescriptor
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... }
- Version:
- 1.0
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final int
The Default scope is used when a scope is not defined in the filter file.private int
private String
private String
private String
private String
private String
private LDAPIntFilterSet
private Vector
<LDAPIntFilterSet> -
Constructor Summary
ConstructorsConstructorDescriptionLDAPFilterDescriptor
(String strFile) Creates an LDAPFilterDescriptor object from an existing filter configuration file.LDAPFilterDescriptor
(StringBuffer strBuffer) Creates an LDAPFilterDescriptor object from an existing StringBuffer.LDAPFilterDescriptor
(URL url) Creates an LDAPFilterDescriptor object from a URL. -
Method Summary
Modifier and TypeMethodDescriptiongetFilters
(String strTagPat, String strValue) Return all the filters which match the strTagPat (regular expression), and the user input (strValue)private void
This function initializes the LDAPFilterDescriptor.private BadFilterException
MakeException
(String strMsg) just a utility method to create an exception.private void
void
setFilterAffixes
(String strPrefix, String strAffix) Prepend the parameter (strPrefix) and append the second parameter (strAffix) to every filter that is returned by the getFilters() method.toString()
Output a text dump of this filter descriptor.
-
Field Details
-
m_vFilterSet
-
m_strLine
-
m_nLine
private int m_nLine -
m_strPrefix
-
m_strAffix
-
m_tmpFilterSet
-
m_strLastMatchPattern
-
m_strLastDelimiter
-
DEFAULT_SCOPE
private static final int DEFAULT_SCOPEThe Default scope is used when a scope is not defined in the filter file. The scope is the only "optional" parameter in the file.- See Also:
-
-
Constructor Details
-
LDAPFilterDescriptor
Creates an LDAPFilterDescriptor object from an existing filter configuration file. This file has the format as defined in the ldapfilter.conf(5) man page.- Throws:
BadFilterException
- One of the filters was not generated properly. Most likely this is due to an improperly formatted ldapfilter.conf file.FileNotFoundException
-
LDAPFilterDescriptor
Creates an LDAPFilterDescriptor object from an existing StringBuffer. This file has the format as defined in the ldapfilter.conf(5) man page.- Throws:
BadFilterException
- One of the filters was not generated properly. Most likely this is due to an improperly formatted ldapfilter.conf file.
-
LDAPFilterDescriptor
Creates an LDAPFilterDescriptor object from a URL. This file has the format as defined in the ldapfilter.conf(5) man page.- Throws:
BadFilterException
- One of the filters was not generated properly. Most likely this is due to an improperly formatted ldapfilter.conf file.IOException
-
-
Method Details
-
init
This function initializes the LDAPFilterDescriptor. It's called internally, and should never be called directly by the developer.- Throws:
BadFilterException
-
setFilter
private void setFilter(Pattern patComment, Pattern patData, Vector<String> vStrings) throws IOException, BadFilterException - Throws:
IOException
BadFilterException
-
MakeException
just a utility method to create an exception. -
toString
Output a text dump of this filter descriptor. It cycles through all of the internal LDAPIntFilterSet objects and calls their toString() methods. -
getFilters
Return all the filters which match the strTagPat (regular expression), and the user input (strValue)- Throws:
IllegalArgumentException
-
setFilterAffixes
Prepend the parameter (strPrefix) and append the second parameter (strAffix) to every filter that is returned by the getFilters() method.
-