JAAS with LDAP
Hi,
I've been thru the tutorial and written my own CallbackHandler but when debugging the handle method is never entered.
Here's a code snippet
LoginContext lc =null;
try
{
LocalCallbackHandler localCallbackHandler =new LocalCallbackHandler(user, pwd);
lc =new LoginContext("LDAP", localCallbackHandler);
}
catch (LoginException innerException)
{
System.out.println("Error creating LoginContext");
}
lc.login();
and...
class LocalCallbackHandlerimplements CallbackHandler
{
private String user;
private String password;
public LocalCallbackHandler(String user, String password)
{
this.user = user;
this.password = password;
}
publicvoid handle(Callback[] callbacks)throws UnsupportedCallbackException
{
for (int i = 0; i < callbacks.length; i++)
{
if (callbacks[i]instanceof TextOutputCallback)
{
TextOutputCallback toc = (TextOutputCallback)callbacks[i];
System.out.println(toc.getMessage());
}
elseif (callbacks[i]instanceof NameCallback)
{
NameCallback nc = (NameCallback)callbacks[i];
nc.setName(user);
}
elseif (callbacks[i]instanceof PasswordCallback)
{
PasswordCallback pc = (PasswordCallback)callbacks[i];
pc.setPassword(password.toCharArray());
}
else
{
thrownew UnsupportedCallbackException
(callbacks[i],"Unrecognized Callback");
}
}
}
}
There is no problem creating the LoginContext. Is there a reason my callback handler isnt used?
Ted.

