LDAP + EJB Example!!

The Lightweight Directory Access Protocol, or LDAP , is an application protocol for querying and modifying directory services running over TCP/IP
A directory is a set of objects with similar attributes organized in a logical and hierarchical manner. The most common example is the telephone directory, which consists of a series of names (either of persons or organizations) organized alphabetically, with each name having an address and phone number attached. Due to this basic design (among other factors) LDAP is often used by other services for authentication

Is an LDAP information directory a database?
Just as a Database Management System (DBMS) from Sybase, Oracle, Informix, or Microsoft is used to process queries and updates to a relational database, an LDAP server is used to process queries and updates to an LDAP information directory. In other words, an LDAP information directory is a type of database, but it’s not a relational database. And unlike databases that are designed for processing hundreds or thousands of changes per minute – such as the Online Transaction Processing (OLTP) systems often used in e-commerce – LDAP directories are heavily optimized for read performance.

The LDAP protocol is both cross-platform and standards-based, so applications needn’t worry about the type of server hosting the directory. In fact, LDAP is finding much wider industry acceptance because of its status as an Internet standard. Most LDAP servers are simple to install, easily maintained, and easily optimized.

LDAP is particularly useful for storing information that you wish to read from many locations, but update infrequently. For example, your company could store all of the following very efficiently in an LDAP directory:

  • The company employee phone book and organizational chart
  • External customer contact information
  • Infrastructure services information, including NIS maps, email aliases, and so on
  • Configuration information for distributed software packages
  • Public certificates and security keys

A client starts an LDAP session by connecting to an LDAP server, by default on TCP Port 389. The client then sends operation requests to the server, and the server sends responses in turn. With some exceptions the client need not wait for a response before sending the next request, and the server may send the responses in any order.

The client may request the following operations:

  • Start TLS – optionally protect the connection with Transport Layer Security (TLS), to have a more secure connection
  • Bind – authenticate and specify LDAP protocol version
  • Search – search for and/or retrieve directory entries
  • Compare – test if a named entry contains a given attribute value
  • Add a new entry
  • Delete an entry
  • Modify an entry
  • Modify Distinguished Name (DN) – move or rename an entry
  • Abandon – abort a previous request
  • Extended Operation – generic operation used to define other operations
  • Unbind – close the connection (not the inverse of Bind

Directory Structure:

The protocol accesses LDAP directories, which follow the 1993 edition of the X 500model:

  • A directory is a tree of directory entries.
  • An entry consists of a set of attributes.
  • An attribute has a name (an attribute type or attribute description) and one or more values. The attributes are defined in a schema (see below).
  • Each entry has a unique identifier: its Distinguished Name (DN). This consists of its Relative Distinguished Name (RDN) constructed from some attribute(s) in the entry, followed by the parent entry’s DN. Think of the DN as a full filename and the RDN as a relative filename in a folder.

Be aware that a DN may change over the lifetime of the entry, for instance, when entries are moved within a tree. To reliably and unambiguously identify entries, a UUID might be provided in the set of the entry’s operational attributes.

An entry can look like this when represented in LDIF format (LDAP itself is a binary protocol):

dn: cn=John Doe,dc=example,dc=com

cn: John Doe

givenName: John

sn: Doe

telephoneNumber: +1 888 555 6789

telephoneNumber: +1 888 555 1234

mail: john@example.com

manager: cn=Barbara Doe,dc=example,dc=com

objectClass: inetOrgPerson

objectClass: organizationalPerson

objectClass: person

objectClass: top

dn is the name of the entry; it’s not an attribute nor part of the entry. “cn=John Doe” is the entry’s RDN, and “dc=example,dc=com” is the DN of the parent entry. The other lines show the attributes in the entry. Attribute names are typically mnemonic strings, like “cn” for common name, “dc” for domain component, “mail” for e-mail address and “sn” for surname.

A server holds a subtree starting from a specific entry, e.g. “dc=example,dc=com” and its children. Servers may also hold references to other servers, so an attempt to access “ou=department,dc=example,dc=com” could return a referral or continuation reference to a server which holds that part of the directory tree. The client can then contact the other server. Some servers also support chaining, which means the server contacts the other server and returns the results to the client.

LDAP rarely defines any ordering: The server may return the values in an attribute, the attributes in an entry, and the entries found by a search operation in any order. This follows from the formal definitions – an entry is defined as a set of attributes, and an attribute is a set of values, and sets need not be ordered.

To learn about: How-To set up a LDAP server and its clients in Ubuntu, refer

http://www.debuntu.org/ldap-server-and-linux-ldap-clients

Example:

The organisation like an IT company will usually have all the details of the employees stored in the LDAP server. The admin can edit the info of any employee or update the data of the new employee. This LDAP server will have a hostname (IP). You need this hostname(ldap.ind.xyz.com) or IP when you want to do login authentication in some application using Java. This application is used by the employees in the organisation and so uses LDAP for authentication. You need to put “netscape-ldap-1.0.jar” in the classpath or include this jar in the java build path-> libraries in eclipse for that project. You can now write an EJB (stateless, session bean) which does the authentication for you and deploy it in JBoss. Using EJB Client, you can pass the employee name or id and get the authentication done. This EJB example can be found at: http://www.javaworld.com/javaworld/jw-08-2001/jw-0803-ejb.html?page=2#resources

Note: Use can even use JNDI to do authorisation with LDAP server instead of netscape-ldap-1.0.jar. However, from what i know, using netscape ldap is better.

What is JNDI?

JNDI is a standard Java package that provides a uniform API for accessing a wide range of services. It is somewhat similar to JDBC, which provides uniform access to different relational databases. Just as JDBC lets us write code that doesn’t care whether it’s talking to an Oracle database or a DB2 database, JNDI lets us write code that can access different directory and naming services, including the naming services provided by EJB servers. EJB servers are required to support JNDI by organizing beans into a directory structure and providing a JNDI driver, called a service provider, for accessing that directory structure. Using JNDI, an enterprise can organize its beans, services, data, and other resources in a unified directory.
The Java Naming and Directory Interface (JNDI) is an API for direct that allows clients to discover and lookup data and objects via a name.
The API provides:

  • a mechanism to bind an object to a name
  • a directory lookup interface that allows general queries
  • an event interface that allows clients to determine when directory entries have been modified
  • LDAP extensions to support the additional capabilities of an LDAP service.

The SPI portion allows support for practically any kind of naming or directory service including:

EJB – Stateless Session Bean Example

Consider Lightweight Directory Access Protocol (LDAP) stateless
session bean. Creating an EJB and using it consists of the following
steps:

1. Get the example.jar ready along with proper deployment
descriptors in the META-INF.
2. Deploy the jar into the EJB container/server.
3. Write the remote/local client.

Steps:

1. and 2. Ensure you have this ready under some common directory
or project:

HelloWorldLdap/
EjbLdapbean.class
EjbLdap.class
EjbLdapHome.class

META-INF/
ejb-jar.xml
xyz.xml : optional – usually contains the jndi name used for lookup
by the bean. This needs to be customized for the particular EJB
servers(where the Bean is deployed) like

1. BEA WebLogic 6.0 (Service Pack 2)-> Here the xyz.xml is called
weblogic-ejb-jar.xml
2. JBoss 2.2.1 -> Here the xyz.xml is called jboss.xml
Certain servers provide a GUI tool for deploying an EJB. In that
case, you need not include xyz.xml in the META-INF folder
yourself. The Deployment Wizard will ask you for a jndi lookup
name and auto. create a customized xyz.xml and put the

HelloWorldLdap/
EjbLdapbean.class
EjbLdap.class
EjbLdapHome.class

META-INF/
ejb-jar.xml
xyz.xml

into a jar and deploy it in some specific directory.
If you are not using any GUI tool, like in JBoss or WebLogic, then
you need to add xyz.xml yourself and create a jar using

jar cvf HelloWorldLdap.jar META-INF/ HelloWorldLdap/*.class

and then put this jar in the specific directory of the server. More
details about deployment can be found at:
http://www.javaworld.com/javaworld/jw-08-2001/jw-0803-
ejb.html?page=1

3. Write the remote or the local client to start using the EJB!

A glance at the imports you will need:

import java.io.*;
import java.util.*;
import javax.ejb.EJBHome;
import javax.naming.*; //JNDI
import javax.rmi.PortableRemoteObject;
import org.omg.CORBA.ORB;
import java.rmi.RemoteException;
import javax.ejb.CreateException;
import netscape.ldap.*;

Online OS – An upcoming concept


Ever wondered an online OS similar to Windows where you can access your own file system from anywhere? The idea is fabulous and yes, it is possible to do it now. There are various online or web OS available that give you free space up to 2 GB. But i tried Omnidrive today and am glad to say that it works great. You can upload files from your computer and create your own file hierarchy. You can even create your own text documents and edit them on the fly.

Net access with a decent speed and you can access your desktop from anywhere, anytime!!

Installing a Plug-in in Eclipse

1.0 Installing a Plug-in with an Update Site

 

 

 

Most plug-ins will have an update site, making it easy to add and update plug-ins within Eclipse. Steps 1.1 and 1.2 outline how to create an update site. Step 1.3 outlines how to update a plug-in from an already existent update site.

 

 

 

1.1 Find the URL of the update site for the plug-in.

 

 

 

1.2 Create an update site for the plug-in (The directions may vary slightly depending on what version of Eclipse you are using, but the idea is the same across all 3.x releases. These directions are specific to Eclipse 3.1)

 

 

 

1.1.1 Select Help > Software Updates > Find and Install. Select Search for new features to install. Click Next.

 

 

 

1.1.2 Click the New Remote Site button. Give the update site a name, such as the name of the plug-in, and type in the update site URL . Click OK. A new update site will be added to the list.

 

 

 

1.1.3 Check the update site that you want to update from (you may select more than one!). Click Finish.

 

 

 

Note: If your computer sits behind a proxy server you need to tell Eclipse how to pass through it. Refer to “Proxy Setting in Eclipse

 

 

 

1.1.4 If the update site has several mirrors (like the Eclipse update site) select the mirror you wish to update from. Click OK.

 

 

 

1.1.5 Press the + button next to the plug-in you want to install. This will list all possible features you can install. Select the features that you want to install. Click Next.

 

 

 

1.1.6 You will need to accept the terms of the licence agreement(s) of the feature(s) that you are installing. Click Next.

 

 

 

1.1.7 A list of feature(s) you are installing will be provided. Click Finish to start the install.

 

 

 

1.1.8 You will need to verify the features that you installed. Click Install or Install All to finish the installation.

 

 

 

1.1.9 You will now be asked to restart the workbench. Click Yes.

 

 

 

Refer:http://subclipse.tigris.org/install.html

 

 

 

2.0 Installing a Plug-in Manually

 

 

 

If a plug-in does not have an update site, then you will be able to download the plug-in as a zip file. To install the plug-in, unzip the file into the Eclipse installation directory (or the plug-in directory depending on how the plug-in is packaged).

 

 

 

3.0 Updating Installed Plug-ins

 

 

 

If you have already created an update site for a plug-in, it is easy to look for new updates.

 

 

 

1.1 Select Help > Software Updates > Find and Install.

 

 

 

1.2 Select Search for updates of currently installed features. Click Next.

 

 

 

1.3 Check the update sites that you want to check for new features. Select Finish.

 

 

 

1.4 If there are features to install then you will install the features as in step 1.1.5.

Proxy Settings in Eclipse

Your web browser is not the only application connected to the Internet. Eclipse has built-in Install/Update features for automatic plugin discovery, download and installation.Once you install a new Internet-aware plugin such as XMLBuddy , it may request access to the Internet. If your computer sits behind a proxy server you need to tell Eclipse how to pass through it.

This tip will explain how to set HTTP proxy in Eclipse.Setting HTTP proxy in Eclipse is fairly straightforward.

  1. Begin by navigating to Window | Preferences .
  2. Click Install/Update .
  3. Check Enable HTTP proxy connection
  4. Enter your proxy host in HTTP proxy host address: [bproxy in my case]
  5. Enter your proxy port in HTTP proxy host port: [8080 in my case]
  6. Click OK.

Windows XP Handsfree !

CTRL+RIGHT ARROW (Move the insertion point to the beginning of the next word)

CTRL+LEFT ARROW (Move the insertion point to the beginning of the previous word)

CTRL+DOWN ARROW (Move the insertion point to the beginning of the next paragraph)

CTRL+UP ARROW (Move the insertion point to the beginning of the previous paragraph)

CTRL+SHIFT with any of the arrow keys (Highlight a block of text)

SHIFT with any of the arrow keys (Select more than one item in a window or in a document)

ALT+ENTER (View the properties for the selected item)

F6 key (Cycle through the screen elements in a window or on the desktop)

CTRL+ESC (Display the Start menu)

F10 key (Activate the menu bar in the active program)

F5 key (Update the active window)

CTRL+SHIFT+ESC (Open Task Manager)

CTRL+TAB (Move forward through the tabs)

CTRL+SHIFT+TAB (Move backward through the tabs)

TAB (Move forward through the options)

SHIFT+TAB (Move backward through the options)

F1 key (Display Help)

Windows Logo (Display or hide the Start menu)

Windows Logo+BREAK (Display the System Properties dialog box)

Windows Logo+D (Display the desktop)

Windows Logo+M (Minimize all of the windows)

Windows Logo+SHIFT+M (Restore the minimized windows)

Windows Logo+E (Open My Computer in Explorer mode)

Windows Logo+F (Search for a file or a folder)

Windows Logo+F1 (Display Windows Help)

Windows Logo+ L (Lock the keyboard)

Windows Logo+R (Open the Run dialog box)

Windows Logo+U (Open Utility Manager)

CTRL+F10 (Maximize the active console window)

CTRL+F5 (Restore the active console window)

F2 key (Rename the selected item)

CTRL+F4 (Close the active console window)

Ctrl+Alt+Down Arrow (Turns screen upside-down)

Ctrl+Alt+Up Arrow (Turns screen rightside-up)

Ctrl+Alt+Right Arrow (Turn screen once, clockwise)

Ctrl+Alt+Left Arrow (Turns screen once, counter-clockwise)

Ctrl+Z (Undo)

Ctrl+Y (Redo)

Mozilla/IE Handsfree

Microsoft Internet Explorer navigation
F6 (Shift focus on the Address Bar)
CTRL+B (Open the Organize Favorites dialog box)
CTRL+E (Open the Search bar)
CTRL+F (Start the Find utility)
CTRL+H (Open the History bar)
CTRL+I (Open the Favorites bar)
CTRL+L (Open the Open dialog box = F6)
CTRL+N (Start another instance of the browser with the same Web address)
CTRL+O (Open the Open dialog box, the same as CTRL+L)
CTRL+P (Open the Print dialog box)
CTRL+R (Update the current Web page)
CTRL+W (Close the current window)

Windows Media Player Handsfree!

F9 – Increase the volume

F8 – Decrease the volume

CTRL+B – Play the previous item

CTRL+F – Play the next item

CTRL+SHIFT+B – Rewind

CTRL+SHIFT+F – Fast-forward

CTRL+SHIFT+G – Play faster than normal speed (time compression)

CTRL+SHIFT+N – Play at normal speed

CTRL+SHIFT+S – Play slower than normal speed (time expansion)

Note: Rewind and fast-forward are not available for all files.

Download Unveiled! – DownloadHelper!

DownloadHelper is a tool for web content extraction. Its purpose is to capture video and image files from many sites.

Just surf the Web as you are used to, when DownloadHelper detects it can do something for you, the icon gets animated and a menu allows you to download files by simply clicking an item

For instance, if you go to a YouTube page, you’ll be able to download the video directly on your file system. It also works with MySpace, Google videos, DailyMotion, Porkolt, iFilm, DreamHost and others.

When you are on a page containing links to images or movies, you can download some or all of them at once. Moving the mouse over the items in the menu will highlights the links directly in the page to make sure they are the ones you want to pick up.

DownloadHelper also allows you to download files one by one, so that you keep bandwidth to surf for other stuff to download.

To modify your preferences, like changing the download directory, right-click on the icon and choose “Preferences”.

When you first install the extension, your browser is redirected to a welcome page with links to a user manual at http://www.downloadhelper.net/manual.php and a faq at http://www.downloadhelper.net/faq.php

This does not change your homepage setting and the welcome page won’t appear anymore.

Support can be obtained from http://www.downloadhelper.net/support.php

Works with:

  • Firefox Firefox: 1.5 – 3.0a2

Install it from: https://addons.mozilla.org/en-US/firefox/addon/3006