예제 #1
0
 public function isGranted($attributes, $object = null)
 {
     if (!is_array($attributes)) {
         $attributes = [$attributes];
     }
     return $this->accessDecisionManager->decide($this->token, $attributes, $object);
 }
예제 #2
0
 public function testOneAbstainIsFail()
 {
     $voters = [new AlwaysVoter(VoterInterface::ACCESS_ABSTAIN)];
     $this->sut = new AccessDecisionManager($voters);
     $token = $this->getMock('Symfony\\Component\\Security\\Core\\Authentication\\Token\\TokenInterface');
     $this->assertFalse($this->sut->decide($token, ['DUMMY']));
 }
예제 #3
0
 /**
  * {@inheritdoc}
  */
 public function decide(TokenInterface $token, array $attributes, $object = null)
 {
     $result = parent::decide($token, $attributes, $object);
     if (false === $result && true === $this->_tryBBTokenOnDenied && null !== $this->_application && null !== $this->_application->getBBUserToken()) {
         $result = parent::decide($this->_application->getBBUserToken(), $attributes, $object);
     }
     return $result;
 }
 /**
  * @dataProvider getStrategyTests
  */
 public function testStrategies($strategy, $voters, $allowIfAllAbstainDecisions, $allowIfEqualGrantedDeniedDecisions, $expected)
 {
     $token = $this->getMock('Symfony\\Component\\Security\\Core\\Authentication\\Token\\TokenInterface');
     $manager = new AccessDecisionManager($voters, $strategy, $allowIfAllAbstainDecisions, $allowIfEqualGrantedDeniedDecisions);
     $this->assertSame($expected, $manager->decide($token, array('ROLE_FOO')));
 }
 /**
  * @dataProvider getStrategiesWith2RolesTests
  */
 public function testStrategiesWith2Roles($token, $strategy, $voter, $expected)
 {
     $manager = new AccessDecisionManager(array($voter), $strategy);
     $this->assertSame($expected, $manager->decide($token, array('ROLE_FOO', 'ROLE_BAR')));
 }
예제 #6
0
 public function isGranted($permission, $resource = null)
 {
     $token = IdentityToken::FromIdentity($this->getIdentity());
     return $this->accessDecisionManager->decide($token, [$permission], $resource);
 }