LDAP Intergration
neillane Nov 9, 2005 5:45 AMI am in the process of trying to do a proof of concept for application logins.
Background:
Application running on JBoss-4.0.3, using form based authentication to a Fedora-DS LDAP server for login.
I have modified the LoginModulesTestCase from the wiki to do the following:
AppConfigurationEntry[] testLdap()
{
String name = "org.jboss.security.auth.spi.LdapExtLoginModule";
HashMap options = new HashMap();
options.put("java.naming.factory.initial", "com.sun.jndi.ldap.LdapCtxFactory");
options.put("java.naming.provider.url", "ldap://192.168.1.2:389/,o=,dc=,dc=,dc=");
options.put("java.naming.security.authentication", "simple");
options.put("bindDN", "cn=bob");
options.put("bindCredential", "pwd");
options.put("baseCtxDN", "");
options.put("baseFilter", "(cn={0})");
AppConfigurationEntry ace = new AppConfigurationEntry(name,
AppConfigurationEntry.LoginModuleControlFlag.REQUIRED, options);
AppConfigurationEntry[] entry = {ace};
return entry;
}
The Test does the most simple of tasks
public void testLdap() throws Exception
{
UsernamePasswordHandler handler = new UsernamePasswordHandler("bob", "pwd");
LoginContext lc = new LoginContext("testLdap", handler);
try
{
lc.login();
Subject subject = lc.getSubject();
}
catch (LoginException e)
{
System.out.println("Login Exception caught");
e.printStackTrace();
}
lc.logout();
}
When I get to the Login() I get the following exception
23:22:20,265 INFO [STDOUT] Login Exception caught
23:22:20,265 INFO [STDOUT] javax.security.auth.login.FailedLoginException: Pass
word Incorrect/Password Required
23:22:20,265 INFO [STDOUT] at org.jboss.security.auth.spi.UsernamePasswordL
oginModule.login(UsernamePasswordLoginModule.java:189)
23:22:20,265 INFO [STDOUT] at sun.reflect.NativeMethodAccessorImpl.invoke0(
Native Method)
23:22:20,265 INFO [STDOUT] at sun.reflect.NativeMethodAccessorImpl.invoke(U
nknown Source)
23:22:20,265 INFO [STDOUT] at sun.reflect.DelegatingMethodAccessorImpl.invo
ke(Unknown Source)
23:22:20,265 INFO [STDOUT] at java.lang.reflect.Method.invoke(Unknown Sourc
e)
23:22:20,265 INFO [STDOUT] at javax.security.auth.login.LoginContext.invoke
(Unknown Source)
23:22:20,265 INFO [STDOUT] at javax.security.auth.login.LoginContext.access
$000(Unknown Source)
23:22:20,265 INFO [STDOUT] at javax.security.auth.login.LoginContext$4.run(
Unknown Source)
23:22:20,265 INFO [STDOUT] at java.security.AccessController.doPrivileged(N
ative Method)
23:22:20,265 INFO [STDOUT] at javax.security.auth.login.LoginContext.invoke
Module(Unknown Source)
23:22:20,265 INFO [STDOUT] at javax.security.auth.login.LoginContext.login(
Unknown Source)
Please could someone let me know if I am doing something fundamentally wrong, as this should be the simple part.
Thanks