/**
  * @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()));
         }
     }
 }
예제 #4
0
 public function handle(EventInterface $event)
 {
     if ($event instanceof TestEvent) {
         throw new \Exception('Invoked TestEventHandler with additionalInformation=' . $event->getAdditionalInformation());
     }
 }
예제 #5
0
 /**
  * Fires an event which then will be dispatched to all event handlers
  * registered for the event.
  *
  * First executes all event handlers listening implicitly on the fired event
  * (i.e. event handlers registered to listen on event "*").
  * Then executes all event handlers listening explicitly on the fired event.
  *
  * In case an event handler is registered to listen on event "*" and
  * additionally registered to listen explicitly on an event, the event
  * handler will be executed multiple times.
  *
  * @param \Ableron\Lib\Event\EventInterface $event The event to fire
  * @return void
  */
 public function fireEvent(EventInterface $event)
 {
     foreach (array('*', $event->getName()) as $eventName) {
         if ($this->eventHandlers->containsKey($eventName)) {
             /** @var \Ableron\Lib\Event\EventHandlerInterface $eventHandler */
             foreach ($this->eventHandlers->get($eventName) as $eventHandler) {
                 $eventHandler->handle($event);
             }
         }
     }
 }