* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Security\Core\Authorization\Voter; use Symfony\Component\Security\Core\Authentication\AuthenticationTrustResolverInterface; use Symfony\Component\Security\Core\Authentication\Token\TokenInterface; /** * AuthenticatedVoter votes if an attribute like IS_AUTHENTICATED_FULLY, * IS_AUTHENTICATED_REMEMBERED, or IS_AUTHENTICATED_ANONYMOUSLY is present. * * This list is most restrictive to least restrictive checking. * * @author Fabien Potencier * @author Johannes M. Schmitt */ class AuthenticatedVoter implements VoterInterface { const IS_AUTHENTICATED_FULLY = 'IS_AUTHENTICATED_FULLY'; const IS_AUTHENTICATED_REMEMBERED = 'IS_AUTHENTICATED_REMEMBERED'; const IS_AUTHENTICATED_ANONYMOUSLY = 'IS_AUTHENTICATED_ANONYMOUSLY'; private $authenticationTrustResolver; public function __construct(AuthenticationTrustResolverInterface $authenticationTrustResolver) { $this->authenticationTrustResolver = $authenticationTrustResolver; } /** * {@inheritdoc} */ public function vote(TokenInterface $token, $subject, array $attributes) { $result = VoterInterface::ACCESS_ABSTAIN; foreach ($attributes as $attribute) { if (null === $attribute || (self::IS_AUTHENTICATED_FULLY !== $attribute && self::IS_AUTHENTICATED_REMEMBERED !== $attribute && self::IS_AUTHENTICATED_ANONYMOUSLY !== $attribute)) { continue; } $result = VoterInterface::ACCESS_DENIED; if (self::IS_AUTHENTICATED_FULLY === $attribute && $this->authenticationTrustResolver->isFullFledged($token)) { return VoterInterface::ACCESS_GRANTED; } if (self::IS_AUTHENTICATED_REMEMBERED === $attribute && ($this->authenticationTrustResolver->isRememberMe($token) || $this->authenticationTrustResolver->isFullFledged($token))) { return VoterInterface::ACCESS_GRANTED; } if (self::IS_AUTHENTICATED_ANONYMOUSLY === $attribute && ($this->authenticationTrustResolver->isAnonymous($token) || $this->authenticationTrustResolver->isRememberMe($token) || $this->authenticationTrustResolver->isFullFledged($token))) { return VoterInterface::ACCESS_GRANTED; } } return $result; } } __halt_compiler();----SIGNATURE:----a330O/HJNXW4IN2fKoBClfRIfJyW40FkeyTh2eD1RcoEZLOS0w2MuY5ORp9295hPqmo/4duu9teVSB9YLP+pDfJIKRNYusLDoK5GzY2CiLjO+691H+twZg3dA1hYxCbMUEM2RdY170lm0pfz1vOP9iIXjz2L/orfOvoKerDb0zk+mZGahFTcVr+MSaJptYoLTiITUttUC40ZbWdAFgosYbA0Fe+jrybq/SnkBU7wLYSeleQDpdhDz2EBfWxTa1e9n1eNcrGvEalRAe52OLZAplxtLeUjrffToNiORM6bz7xSVNcnJcczc7yf6MZdlAOE/Gzezfhe7OE81pQ/YoyiL58oN98ZGSiZ419GVE0lOFffUyTaizC65TYjDR6OCxLPgoG6ZU5QFwNaLJASC5hP4V6ToeA57NTrPjdlsk/tr0ZP889GYhG3tyCA8QyN7sM48lrtOYrri51tU+Hn0hlIeK80PvWpZmr/5tH2I0HhzOHSYzUB0gqcYW/7I8Efyk+oI2YUKNR4rlQH1P0FIoBaxcG8Idkc2ZqtEdgdwxX6TeXLU5TF77K7DQFmFCazP+RK6qWTu9lskZ4Klr9AHVCW08GKWDB9JFmgJ4DuLSqbxDgx2mh0oVq7SrYvEAPeWGyRgpCUJHdnUPaeSfxdvmMiL/s1txCtehtdPr7XpYgYX54=----ATTACHMENT:----Mzc1NTIwNjEwMjY4MjQzOSAyMzkxMDg0MzE2MzY0NDEgMzg1NTk2NTk0MTQ5MzM4MA==