Completed
Push — ezp-30928-as_a_developer_i_wan... ( b10e65 )
by
unknown
33:52 queued 18:51
created

RememberMeRepositoryAuthenticationProvider   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 0
Metric Value
dl 0
loc 27
rs 10
c 0
b 0
f 0
wmc 3
lcom 1
cbo 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A authenticate() 0 13 2
A setPermissionResolver() 0 4 1
1
<?php
2
3
/**
4
 * File containing the RememberMeRepositoryAuthenticationProvider class.
5
 *
6
 * @copyright Copyright (C) eZ Systems AS. All rights reserved.
7
 * @license For full copyright and license information view LICENSE file distributed with this source code.
8
 */
9
namespace eZ\Publish\Core\MVC\Symfony\Security\Authentication;
10
11
use eZ\Publish\API\Repository\PermissionResolver;
12
use Symfony\Component\Security\Core\Authentication\Provider\RememberMeAuthenticationProvider;
13
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
14
use Symfony\Component\Security\Core\Exception\AuthenticationException;
15
16
class RememberMeRepositoryAuthenticationProvider extends RememberMeAuthenticationProvider
17
{
18
    /** @var \eZ\Publish\API\Repository\PermissionResolver */
19
    private $permissionResolver;
20
21
    public function setPermissionResolver(PermissionResolver $permissionResolver)
22
    {
23
        $this->permissionResolver = $permissionResolver;
24
    }
25
26
    /**
27
     * {@inheritdoc}
28
     */
29
    public function authenticate(TokenInterface $token)
30
    {
31
        $authenticatedToken = parent::authenticate($token);
32
        if (empty($authenticatedToken)) {
33
            throw new AuthenticationException('The token is not supported by this authentication provider.');
34
        }
35
36
        $this->permissionResolver->setCurrentUserReference(
37
            $authenticatedToken->getUser()->getAPIUser()
38
        );
39
40
        return $authenticatedToken;
41
    }
42
}
43