/**
  * @see \Ableron\Lib\Event\EventHandlerInterface::handle()
  */
 public function handle(EventInterface $event)
 {
     // clear failed login attempts
     /** @var \Ableron\Modules\Core\Events\LoginAttemptSuccessfulEvent $event */
     if (($loginAttemptsEntity = BruteForceProtectionService::getLoginAttemptsByUsername($event->getUsername())) !== null) {
         Application::getPersistenceManager()->getEntityManager()->remove($loginAttemptsEntity);
     }
 }
 /**
  * @see \Ableron\Lib\Event\EventHandlerInterface::handle()
  */
 public function handle(EventInterface $event)
 {
     /** @var \Ableron\Modules\Core\Events\LoginValidatingDataEvent $event */
     if (($loginAttemptsEntity = BruteForceProtectionService::getLoginAttemptsByUsername($event->getUsername())) !== null) {
         if ($loginAttemptsEntity->getFailedAttemptsCount() >= 5 && $loginAttemptsEntity->getLastAttemptTime()->add(new \DateInterval('PT2M')) >= DateUtil::getCurrentUtcDateTime()) {
             throw new FormParameterException(array(), 'bruteForceProtector.backend.message.possibleBruteForceDetected');
         }
     }
 }
 /**
  * @see \Ableron\Lib\Event\EventHandlerInterface::handle()
  */
 public function handle(EventInterface $event)
 {
     // only take care of login attempts where both username and password are set
     /** @var \Ableron\Modules\Core\Events\LoginAttemptFailedEvent $event */
     if ($event->getUsername() !== '' && $event->getPassword() !== '') {
         // log failed login attempt
         if (($loginAttemptsEntity = BruteForceProtectionService::getLoginAttemptsByUsername($event->getUsername())) !== null) {
             $loginAttemptsEntity->addFailedAttempt();
         } else {
             Application::getPersistenceManager()->getEntityManager()->persist(new LoginAttemptsEntity($event->getUsername()));
         }
     }
 }