protected function onFailure(RealmInterface $realm, HttpServletRequestInterface $servletRequest, HttpServletResponseInterface $servletResponse)
{
// load the session from the request
if ($session = $servletRequest->getSession()) {
// prepare the ArrayList for the login errors
$formErrors = new ArrayList();
// transform the realm's exception stack into simple error messages
foreach ($realm->getExceptionStack() as $e) {
$formErrors->add($e->getMessage());
}
// add the error messages to the session
$session->putData(Constants::FORM_ERRORS, $formErrors);
}
// forward to the configured error page
$this->forwardToErrorPage($servletRequest, $servletResponse);
}