- Lovin Varghese

Download Report

Transcript - Lovin Varghese

Java Naming and
Directory Interfaces
What is an Naming Services
A naming service is an entity that performs the
following tasks:
 It associates names with objects. Similar
to a telephone company’s associating a person’s
name with a specific residence’s telephone
number.
Application logic components
What is an Naming Services (Contd)
 It provides a facility to find an object
based on a name. This is similar to a telephone
operator finding a person’s telephone number
based on that person’s name and connecting the
two people together.
What is an Naming Services (Contd)
The common example of Naming Services is the
Domain Naming Service (DNS), this associate a name
with the IP address of the system. The users have to
remember the DNS name not the IP address. We do
have the File System naming service, which save or
opens a specific file based on the file name given.
What is an Directory Services
A directory service is a naming service that has
been extended and enhanced to provide directory
object operations for manipulating attributes. A
directory is a system of directory objects, all
connected. Some of the products are Netscape
Directory Server and Microsoft’s Active Directory.
Problems with Naming and Directory Services
Directory vendors differentiate their product
lines by offering different types of services.
Unfortunately, this leads to different naming and
directory standards. For example, directories based
on the
Lightweight Directory Access Protocol (LDAP)
are accessed differently than those based on
Network Information System(NIS)
or
Novell’s Network Directory System(NDS)
Enter Java Naming and Directory Interfaces
Java Naming and Directory Interfaces is a
system for Java-based clients to interact with naming
and directory systems
Benefits of JNDI
 JNDI is unified system to access all sorts of
directory service information, such as security
credentials, phone numbers, electronic and postal
mail addresses.…
 JNDI is a single API to access different
directories with different protocols.
 JNDI insulates the application from protocol
and implementation details.
 JNDI is extensible. Future providers of
directories can plug in their particular directory
services to JNDI without affecting your client code.
Benefits of JNDI (Contd)
 JNDI can read and write whole Java objects
from directories
 You can link different types of directories,
such as an LDAP directory with an NDS directory and
have the combination appear to be one large,
federated directory. The federated directory appears
to be on contiguous directory to the client.
 JNDI is supported by Sun Microsystems and
it is a standard Java extension.
JNDI Architecture
JNDI made up of two halves: the client API and
the Service Provider Interface(SPI).
The client API
allows Java code to perform directory operations.
This API is uniform for all types of directories. JNDI
architecture is somewhat like the Java Database
Connectivity (JDBC)
 In JDBC there is one uniform client API for
performing database operations.
 In JDBC, relational database vendors provide
JDBC drivers to access their particular database.
Available Service Providers
•
•
•
•
•
•
•
•
Lightweight Directory Access Protocol (LDAP)
Network Information service( NIS)
Novell Directory Services (NDS )
Service Location Protocol(SLP)
Corba Object Naming Service or COS Naming
File System
RMI Registry
Bea Weblogic Naming Service
Understanding the concepts behind JNDI
Naming Concepts
 Atomic Name
An atomic name is simple, basic, indivisible
component of a name.
For example :
In the string c:\MyCompany\java\Jndi.txt
Jndi.txt is an atomic name.
Understanding the concepts behind JNDI
Naming Concepts
 Compound Name
A compound name is zero or more atomic names
put together. In the previous example the entire string
“c:\MyCompany\java\Jndi.txt”
is a compound name.
Binding
A binding is an association of a name with an
object. For example the file autoexec.bat in the windows
file system has a binding to the file data on your hard
disk. Note that compound name like
C:\user\people\education\stg
Consists of multiple bindings one to user, one to people,
one to education and one to lovin.
Naming Service
How JNDI differs from other Naming Services
Domain Naming Service (DNS)
In DNS, names are built from components that are
separated by dots ("."). They read from right to left.
The name "www.lovinjava.com" names a machine
called "www" in the ”lovinjava.com" domain.
Likewise, the name ”lovinjava.com" names the
domain ”lovinjava" in the top-level domain "com."
How JNDI differs from other Naming Services
Lightweight Directory Access Protocol(LDAP)
In LDAP, the situation is slightly more
complicated. Names are built from components that
are separated by commas (","). Like DNS names, they
read from right to left. However, components in an
LDAP name must be specified as name/value pairs.
The name "cn=Lovin Varghese, o=STG, c=IN" names
the person "cn= Lovin Varghese " in the organization
" o=STG, c=IN." Likewise, the name "o=STG, c=IN"
names the organization "o=STG" in the country "c=IN"
.
Context
A context is an object that contains zero or more
bindings. A context represents a set of bindings
within a naming service that all share the same
naming convention. A Context object provides the
methods for binding names to objects and unbinding
names from objects, for renaming objects, and for
listing the bindings.
Namespace
A namespace is all the names contained within
that naming system.
Composite Name
A composite name is a name that spans multiple
naming systems. For example on the web the URL
http://lovinjava.com/products/product.jsp
is composed from the following namespaces:
http : comes from the URL scheme-id namespace.
This namespace defines the protocol you use to
communicate.
Lovinjava.com uses the Domain Name Service(DNS)
to translate machine names into IP address.
Products and products.jsp are from the file system
namespace on the web server machine.
Initial Context
One question commonly asked which namespace
do you first look in when traversing the string
http://lovinjava.com/products/product.jsp
The starting point of exploring a namespace is
called an initial context. An initial context simply is the
first context you happen to use. An initial context is a
starting point for performing all naming and directory
operations.
Directory Service
A directory service associates names with objects
and also allows such objects to have attributes. Thus,
you not only can look up an object by its name but
also get the object's attributes or search for the object
based on its attributes.
Directory Service
Directory Services
A directory service manages a directory of entries.
An entry also has attributes associated with it; an
attribute consists of a name or identifier and one or
more values. These attributes describe the entry. For
example, the entry for an individual might have the
following attributes (note the two email addresses):
Name: John Doe
Address: 123 Somewhere Street
Email: [email protected]
Email: [email protected]
Directory Services
Directory services are simple databases. Like their
relational cousins, many common directory services
provide search and filter functionality. Instead of
locating an entry only by name, these directory
services allow you to locate entries based on a set of
search criteria.
JNDI Api references
 javax.naming
 javax.naming.directory
 javax.naming.event
 javax.naming.ldap
 javax.naming.spi
Presented By
Lovin Varghese,
Technical Manager,
Software Technology Group Ltd.
Email id : [email protected]