Java Reference
In-Depth Information
small special-purpose set of classes, you can build lightweight, testable JNDI com-
ponents, and then hook them into your DAO implementation without exposing
the data source.
Understanding LDAP terminology
Before launching into a complete example of building an LDAP directory-based
DAO implementation, let's review some terminology. LDAP is intentionally vague,
because it is intended to be a very flexible general-purpose protocol for accessing
a repository of hierarchical data.
The basic building block of an LDAP directory is called an entry , which can con-
tain data (called attributes ), other entries, or both. Every entry has exactly one par-
ent and is uniquely identified by a Distinguished Name ( DN ), which is unique
across the entire directory. The data elements in that entry are defined by one or
more object classes that the entry represents.
The data stored in LDAP directory entries are made up of attributes, which are
name/value pairs that are virtually identical to Java's Map interface. The object
class (or classes) of the entry will determine which optional attributes the entry
can have, as well as which required attributes it must have.
For example, if we want to create a contact manager that manages normal
LDAP entities with a Java application, we might have a bean to represent an entry,
and that bean would look like this:
public class Contact {
private String userId;
private String mail;
private String description;
private String firstName;
private String lastName;
// Getters and Setters to make properties...
}
One approach to storing this object in an LDAP directory would be to simply seri-
alize the Java object into the directory. For our example, we are not going to do
that for two reasons. One reason is that we want to be able to use our directory to
interoperate with other, potentially non-Java systems. The other is that we want to
take advantage of LDAP -based queries—we want to use the database as it was
intended to be used.
Mapping from Java to LDAP
As mentioned earlier, every LDAP directory entry represents one or more object
classes. These object classes define groups of attributes. Because of the similarity
Search WWH ::




Custom Search