Thanks Wolf,
When I add:
jndiProps.put(Context.SECURITY_PRINCIPAL, "foo");
jndiProps.put(Context.SECURITY_CREDENTIALS, "bar");
the code works properly. However, I do not want to specify the credentials in the hash table and want the context factory to use the credentials as set by my:
LoginContext lc = new LoginContext("client-login", new UsernamePasswordHandler(userName, password.toCharArray()));
lc.login();
From the link you provided, I do not see any references to JAAS. I still see username/password hardcodes as properties.