Using jndi in user authentication
by, 07-07-2012 at 05:28 PM (880 Views)
JNDI is used as naming service. It is commonly used to give security mechanism to make users authenticated to access the system resources. Credentials and user information is stored in directory services as entries. It is worthy to point it out that security model is not defined by JNDI however security model is used which has been defined in directory service.
Default initialContext is involved in creation of new Context that is in use of anonymous clients.
When a user is authenticated, ID as well as Password shall combine and pass being a parameter, to InitialContext. When password doesn’t match, javax.naming.NoPermission would be get thrown towards clients. How a user could be authenticated has been given below, along with JNDI server “Weblogic default”.Java Code:// Connect to the default naming server as a default user Context ctx = new InitialContext();
Java Code:// Set up the environment properties for the user Properties prop = new Properties(); // Login use both user id, and password passed as Strings prop.put(Context. SECURITY_PRINCIPAL, "Laura"); prop.put(Context. SECURITY_CREDENTIALS, "whiskers");