{
String realmName = name.getMethodName();
createLoginModuleConfig(realmName);
delay();
CallbackHandler handler = new SimpleCallbackHandler("foo", "foo");
Subject s = new Subject();
//Using LoginFactory we can avoid providing Configuration and switching TCCL
LoginContext lc = loginContextFactory.createLoginContext(realmName, s, handler);
lc.login();
assertFalse(s.getPrincipals().isEmpty());
//Negative case. Login fails with incorrect password
try
{
LoginContext lc2 = loginContextFactory.createLoginContext(realmName, s,
new SimpleCallbackHandler("foo", "bar"));
lc2.login();
fail("Login should have failed");
}catch(LoginException e){
}