Overview

Namespaces

  • Mapbender
    • Component
      • HTTP
    • CoreBundle
      • Command
      • Component
        • Exception
      • Controller
      • DataFixtures
        • ORM
      • DependencyInjection
      • Element
        • Type
      • Entity
      • EventListener
      • Extension
      • Form
        • DataTransformer
        • EventListener
        • Type
      • Security
      • Template
    • DrupalIntegrationBundle
      • DependencyInjection
      • Security
        • Authentication
          • Provider
          • Token
        • Authorization
          • Voter
        • Factory
        • Firewall
        • User
      • Session
    • KmlBundle
      • Element
    • ManagerBundle
      • Controller
      • Form
        • DataTransformer
        • Type
    • MonitoringBundle
      • Command
      • Component
      • Controller
      • DependencyInjection
      • Entity
      • EventListener
      • Form
    • PrintBundle
      • Component
      • Controller
    • WmcBundle
      • Component
        • Exception
      • Element
        • Type
      • Entity
      • Form
        • EventListener
        • Type
    • WmsBundle
      • Component
        • Exception
      • Controller
      • DependencyInjection
      • Element
        • Type
      • Entity
      • Event
      • Form
        • EventListener
        • Type
    • WmtsBundle
      • Component
        • Exception
      • Controller
      • Entity
      • Form
        • Type
  • None
  • PHP

Classes

  • DrupalListener
  • Overview
  • Namespace
  • Class
  • Tree
  • Deprecated
  • Todo
  • Download
 1: <?php
 2: 
 3: namespace Mapbender\DrupalIntegrationBundle\Security\Firewall;
 4: 
 5: use Symfony\Component\HttpFoundation\Response;
 6: use Symfony\Component\HttpKernel\Event\GetResponseEvent;
 7: use Symfony\Component\Security\Http\Firewall\ListenerInterface;
 8: use Symfony\Component\Security\Core\Exception\AuthenticationException;
 9: use Symfony\Component\Security\Core\SecurityContextInterface;
10: use Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface;
11: use Mapbender\DrupalIntegrationBundle\Security\Authentication\Token\DrupalUserToken;
12: use Mapbender\DrupalIntegrationBundle\Security\User\DrupalUser;
13: 
14: 
15: class DrupalListener implements ListenerInterface
16: {
17:     protected $securityContext;
18:     protected $authenticationManager;
19: 
20:     public function __construct(SecurityContextInterface $securityContext, AuthenticationManagerInterface $authenticationManager)
21:     {
22:         $this->securityContext = $securityContext;
23:         $this->authenticationManager = $authenticationManager;
24:     }
25: 
26:     public function handle(GetResponseEvent $event)
27:     {
28:         global $user;
29: 
30:         if(null !== $user && $user->uid != 0) {
31:             $drupalUser = new DrupalUser($user);
32:             $token = new DrupalUserToken($drupalUser);
33: 
34:             try {
35:                 //$authToken = $this->authenticationManager->authenticate($token);
36:                 $this->securityContext->setToken($token);
37:             } catch (AuthenticationException $failed) {
38:                 // Deny authentication with a '403 Forbidden' HTTP response
39:                 $response = new Response();
40:                 $response->setStatusCode(403);
41:                 $event->setResponse($response);
42:             }
43:         }
44:     }
45: }
46: 
Mapbender3 API documenation API documentation generated by ApiGen 2.8.0