{@inheritdoc}

@param mixed          $attribute The attribute to vote on.
@param mixed          $subject   The subject to vote on.
@param TokenInterface $token     The user token.

@return bool
513793
protected function voteOnAttribute($attribute, $subject, TokenInterface $token): bool
    {
        $user = $token->getUser();

        if (!$user instanceof UserInterface) {
            return false;
        }

        $groupable = $subject;

        switch ($attribute) {
            case self::VIEW:
                return $this->canView($groupable, $token);
            case self::EDIT:
                return $this->canEdit($groupable, $token);
        }
    }
44000
final public function isGranted($attributes, $subject = null)
    {
        if (null === ($token = $this->tokenStorage->getToken())) {
            throw new AuthenticationCredentialsNotFoundException('The token storage contains no authentication token. One possible reason may be that there is no firewall configured for this URL.');
        }

        if ($this->alwaysAuthenticate || !$token->isAuthenticated()) {
            $this->tokenStorage->setToken($token = $this->authenticationManager->authenticate($token));
        }

        if (!\is_array($attributes)) {
            $attributes = [$attributes];
        }

        return $this->accessDecisionManager->decide($token, $attributes, $subject);
    }
1057660
public function checkCreation(TokenInterface $token, $object)
    {
        return $this->manager->isAllowedBadgeManagement($token, $object->getBadge());
    }
1373882
protected function voteOnAttribute($attribute, $subject,
                                       TokenInterface $token)
    {
        $granted = true;
        $uroles  = array();
        foreach ($token->getRoles() as $role) {
            $uroles[] = $role->getRole();
        }
        foreach ($this->subjectPrefixes as $prefix => $proles) {
            if (substr($subject, 0, strlen($prefix)) != $prefix) {
                continue;
            }
            $granted = false;
            if (count(array_intersect($uroles, $proles)) > 0) {
                return true;
            }
        }
        return $granted;
    }
137117
protected function containsRole(TokenInterface $token, ReadNodeInterface $subject)
    {
        $tokenRoles = $this->roleHierarchy->getReachableRoles($token->getRoles());;
        foreach ($tokenRoles as $key => $role) {
            if ($role instanceof RoleInterface) {
                $tokenRoles[$key] = $role->getRole();
            }
        }

        return empty($subject->getFrontRoles())
            || ($this->accessDecisionManger->decide($token, array('IS_AUTHENTICATED_FULLY'))
                && !empty(array_intersect($tokenRoles, $subject->getFrontRoles())));
    }
117610
protected function supports($attribute, $subject)
    {
        $isSupportedAttribute = false;

        foreach ($this->getSupportedAttributes() as $supportedAttributeClass) {
            if ($attribute instanceof $supportedAttributeClass) {
                $isSupportedAttribute = true;
                break;
            }
        }

        return $isSupportedAttribute && $this->supportSubject($subject);
    }
561378
private function resolveAuthenticator(TokenInterface $token)
    {
        foreach ($this->authenticators as $authenticator) {
            if ($authenticator->supports($token)) {
                return $authenticator;
            }
        }

        return false;
    }
113785
protected function refreshUser(TokenInterface $token)
    {
        $user = $token->getUser();

        if (!$user instanceof UserInterface) {
            return;
        }

        $refreshedUser = $this->userProvider->refreshUser($user);
        $token->setUser($refreshedUser);

        return $token;
    }
554367
public function setTokenType(TokenTypeInterface $tokenType)
    {
        $this->issuer->setTokenType($tokenType);
        $this->checker->setTokenType($tokenType);
    }
754059
protected function voteForReadAction($subject, TokenInterface $token)
    {
        $contentType = $subject;
        if (is_object($subject)) {
            $contentType = $subject->getContentType();
        }

        return $this->isSubjectInPerimeter($contentType, $token->getUser(), ContentTypeInterface::ENTITY_TYPE);
    }
204842
private function checkEdit(TokenInterface $token, User $user)
    {
        //the user can edit himself too.
        //He just can add roles and stuff and this should be checked later
        if ($token->getUser() === $user) {
            return true;
        }

        return $this->isOrganizationManager($token, $user) ?
            VoterInterface::ACCESS_GRANTED : VoterInterface::ACCESS_DENIED;
    }
290805
public function vote(TokenInterface $token, $object, array $attributes)
    {
        if (!(($object instanceof Request) || $this->supportsAnyAttribute($attributes))) {
            return VoterInterface::ACCESS_ABSTAIN;
        }

        $requiredRole = $this->getRequiredRole($object);

        if (null === $requiredRole) {
            return VoterInterface::ACCESS_ABSTAIN;
        }

        $user = $token->getUser();

        if (!$user instanceof UserInformationInterface) {
            return VoterInterface::ACCESS_DENIED;
        }

        foreach ($user->getRoles() as $role) {
            if (strtoupper($role) == strtoupper($requiredRole)) {
                return VoterInterface::ACCESS_GRANTED;
            }
        }

        return VoterInterface::ACCESS_DENIED;
    }
1129557
public function vote(TokenInterface $token, $object, array $attributes)
    {
        if ($object instanceof DataInterface) {
            return $this->familyVoter->vote($token, $object->getFamily(), $attributes);
        }

        return VoterInterface::ACCESS_ABSTAIN;
    }
1194733
public function vote(TokenInterface $token, $object, array $attributes)
    {
        if ($object instanceof FieldFacet) {
            return $this->fieldFacetVote($object, $token, $attributes[0]);
        }

        return VoterInterface::ACCESS_ABSTAIN;
    }
508405
private function decideUnanimous(TokenInterface $token, array $attributes, $object = null)
    {
        $grant = 0;
        foreach ($this->voters as $voter) {
            foreach ($attributes as $attribute) {
                $result = $voter->vote($token, $object, [$attribute]);

                switch ($result) {
                    case VoterInterface::ACCESS_GRANTED:
                        ++$grant;

                        break;

                    case VoterInterface::ACCESS_DENIED:
                        return false;

                    default:
                        break;
                }
            }
        }

        // no deny votes
        if ($grant > 0) {
            return true;
        }

        return $this->allowIfAllAbstainDecisions;
    }
1062595
public function isGranted($attributes, $subject = null)
    {
        return $this->container->get('security.authorization_checker')
            ->isGranted($attributes, $subject);
    }
408440
public function onAuthenticationSuccess(Request $request, TokenInterface $token)
    {
        if ($request->isXmlHttpRequest()) {
            /** @var User $user */
            $user = $token->getUser();
            $roles = $token->getRoles();
            $outputRoles = array();

            foreach ($roles as $role) {
                $outputRoles[] = $this->translator->trans('roles.' . $role->getRole(), array(), 'CodeLoversAngularBundle');
            }

            $output = $this->generator->getUserData($request, $token);

            // notify listeners to allow output modification
            $event = new LoginEvent($user);
            $event->setOutput($output);

            $this->dispatcher->dispatch(AuthEvents::LOGIN_SUCCESS, $event);

            return new JsonResponse($event->getOutput());
        } else {
            if ($targetPath = $request->getSession()->get('_security.target_path')) {
                $url = $targetPath;
            } else {
                $url = $this->getDefaultUrl();
            }

            return new RedirectResponse($url);
        }
    }