The AuthHttpENEConnection class has a login method to query the LDAP directory for authentication.
The LDAP server’s URL is obtained from the serverInfo parameter (or parameters) in the Access Control configuration file.
If the user is not in the LDAP directory, the authentication will fail and the user will not be allowed access to the Endeca implementation.
//Create a CallbackHandler CallbackHandler cbh = new StaticCallbackHandler(name,pass); // Query the LDAP server to authenticate this user try { nec.login(cbh); } catch (ENEAuthenticationException exp) { System.err.println(exp); exp.printStackTrace(); System.err.println("LDAP Authentication failed"); System.exit(1); }
The StaticCallbackHandler object provides the user name and password. If the login attempt fails, an ENEAuthenticationException exception is thrown.
Login(IAuthCredentialRequestHandler handler)where handler is an IAuthCredentialRequestHandler object instance that provides the mechanism to obtain credentials for authentication purposes.
//Authenticate the user nec.Login(new StaticCredentialRequestHandler(user, pass));
The StaticCredentialRequestHandler object provides the user name and password. If the login attempt fails, an ENEAuthenticationException exception is thrown.