1 | <?php |
||
16 | class ShibbolethSwitchUserPersistenceSubscriber implements EventSubscriberInterface, LoggerAwareInterface |
||
17 | { |
||
18 | use LoggerTrait; |
||
19 | |||
20 | protected $session; |
||
21 | protected $tokenStorage; |
||
22 | protected $shibbolethServiceProvider; |
||
23 | protected $userProvider; |
||
24 | protected $userChecker; |
||
25 | protected $accessDecisionManager; |
||
26 | protected $usernameParameter; |
||
27 | protected $role; |
||
28 | protected $sessionKey; |
||
29 | protected $eventDispatcher; |
||
30 | |||
31 | public function __construct( |
||
43 | |||
44 | public static function getSubscribedEvents() |
||
51 | |||
52 | public function onKernelRequest() |
||
69 | |||
70 | public function onUserSwitch(SwitchUserEvent $event) |
||
71 | { |
||
72 | if ($event instanceof ShibbolethSwitchUserEvent) { |
||
73 | if ($event->getTargetUser()->getUsername() !== $this->shibbolethServiceProvider->getUsername()) { |
||
74 | $this->session->set($this->sessionKey, $event->getToken()); |
||
75 | $this->log(sprintf('Token persisted in session for username "%s": %s', $event->getTargetUser()->getUsername(), $event->getToken())); |
||
76 | } else { |
||
77 | $this->session->remove($this->sessionKey); |
||
78 | $this->log(sprintf('Token removed from session: %s', $event->getToken())); |
||
79 | } |
||
80 | } |
||
81 | } |
||
82 | |||
83 | public function supportsToken(TokenInterface $token) |
||
89 | } |
||
90 |