}
public Person login(String email, String password) throws RemoteException, LoginException
{
IPersonHome home = getPersonHome();
IPerson person = null;
Person result = null;
try
{
person = home.findByEmail(email);
}
catch (FinderException ex)
{
throw new LoginException("Unknown e-mail address.", false);
}
if (!person.getPassword().equals(password))
throw new LoginException("Invalid password.", true);
try
{
result = getPerson((Integer) person.getPrimaryKey());
}
catch (FinderException ex)
{
throw new LoginException("Could not read person.", false);
}
if (result.isLockedOut())
throw new LoginException("You have been locked out of the Virtual Library.", false);
// Set the last access time for any subsequent login.
person.setLastAccess(new Timestamp(System.currentTimeMillis()));
return result;
}