summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Core/Authorization/Voter/AbstractVoter.php8
-rw-r--r--Core/Authorization/Voter/AuthenticatedVoter.php20
-rw-r--r--Core/Authorization/Voter/ExpressionVoter.php18
-rw-r--r--Core/Authorization/Voter/RoleVoter.php18
-rw-r--r--Core/Tests/Authorization/AccessDecisionManagerTest.php20
-rw-r--r--Core/Tests/Authorization/Voter/AuthenticatedVoterTest.php6
-rw-r--r--Core/Tests/Authorization/Voter/ExpressionVoterTest.php9
-rw-r--r--Core/Tests/Authorization/Voter/RoleVoterTest.php7
8 files changed, 7 insertions, 99 deletions
diff --git a/Core/Authorization/Voter/AbstractVoter.php b/Core/Authorization/Voter/AbstractVoter.php
index ee73d29..71f570f 100644
--- a/Core/Authorization/Voter/AbstractVoter.php
+++ b/Core/Authorization/Voter/AbstractVoter.php
@@ -11,7 +11,6 @@
namespace Symfony\Component\Security\Core\Authorization\Voter;
-use Symfony\Component\Security\Core\User\UserInterface;
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
/**
@@ -89,11 +88,8 @@ abstract class AbstractVoter implements VoterInterface
}
/**
- * Perform a single access check operation on a given attribute, object and (optionally) user
- * It is safe to assume that $attribute and $object's class pass supportsAttribute/supportsClass
- * $user can be one of the following:
- * a UserInterface object (fully authenticated user)
- * a string (anonymously authenticated user).
+ * Perform a single access check operation on a given attribute, object and token.
+ * It is safe to assume that $attribute and $object's class pass supports method call.
*
* @param string $attribute
* @param object $object
diff --git a/Core/Authorization/Voter/AuthenticatedVoter.php b/Core/Authorization/Voter/AuthenticatedVoter.php
index 5847e0d..762e9bc 100644
--- a/Core/Authorization/Voter/AuthenticatedVoter.php
+++ b/Core/Authorization/Voter/AuthenticatedVoter.php
@@ -44,27 +44,13 @@ class AuthenticatedVoter implements VoterInterface
/**
* {@inheritdoc}
*/
- public function supportsAttribute($attribute)
- {
- return null !== $attribute && (self::IS_AUTHENTICATED_FULLY === $attribute || self::IS_AUTHENTICATED_REMEMBERED === $attribute || self::IS_AUTHENTICATED_ANONYMOUSLY === $attribute);
- }
-
- /**
- * {@inheritdoc}
- */
- public function supportsClass($class)
- {
- return true;
- }
-
- /**
- * {@inheritdoc}
- */
public function vote(TokenInterface $token, $object, array $attributes)
{
$result = VoterInterface::ACCESS_ABSTAIN;
foreach ($attributes as $attribute) {
- if (!$this->supportsAttribute($attribute)) {
+ if (null === $attribute || (self::IS_AUTHENTICATED_FULLY !== $attribute
+ && self::IS_AUTHENTICATED_REMEMBERED !== $attribute
+ && self::IS_AUTHENTICATED_ANONYMOUSLY !== $attribute)) {
continue;
}
diff --git a/Core/Authorization/Voter/ExpressionVoter.php b/Core/Authorization/Voter/ExpressionVoter.php
index 98b8f50..0842856 100644
--- a/Core/Authorization/Voter/ExpressionVoter.php
+++ b/Core/Authorization/Voter/ExpressionVoter.php
@@ -52,28 +52,12 @@ class ExpressionVoter implements VoterInterface
/**
* {@inheritdoc}
*/
- public function supportsAttribute($attribute)
- {
- return $attribute instanceof Expression;
- }
-
- /**
- * {@inheritdoc}
- */
- public function supportsClass($class)
- {
- return true;
- }
-
- /**
- * {@inheritdoc}
- */
public function vote(TokenInterface $token, $object, array $attributes)
{
$result = VoterInterface::ACCESS_ABSTAIN;
$variables = null;
foreach ($attributes as $attribute) {
- if (!$this->supportsAttribute($attribute)) {
+ if (!$attribute instanceof Expression) {
continue;
}
diff --git a/Core/Authorization/Voter/RoleVoter.php b/Core/Authorization/Voter/RoleVoter.php
index 722675d..74e2363 100644
--- a/Core/Authorization/Voter/RoleVoter.php
+++ b/Core/Authorization/Voter/RoleVoter.php
@@ -35,29 +35,13 @@ class RoleVoter implements VoterInterface
/**
* {@inheritdoc}
*/
- public function supportsAttribute($attribute)
- {
- return 0 === strpos($attribute, $this->prefix);
- }
-
- /**
- * {@inheritdoc}
- */
- public function supportsClass($class)
- {
- return true;
- }
-
- /**
- * {@inheritdoc}
- */
public function vote(TokenInterface $token, $object, array $attributes)
{
$result = VoterInterface::ACCESS_ABSTAIN;
$roles = $this->extractRoles($token);
foreach ($attributes as $attribute) {
- if (!$this->supportsAttribute($attribute)) {
+ if (0 !== strpos($attribute, $this->prefix)) {
continue;
}
diff --git a/Core/Tests/Authorization/AccessDecisionManagerTest.php b/Core/Tests/Authorization/AccessDecisionManagerTest.php
index 9c23672..72bae0a 100644
--- a/Core/Tests/Authorization/AccessDecisionManagerTest.php
+++ b/Core/Tests/Authorization/AccessDecisionManagerTest.php
@@ -137,24 +137,4 @@ class AccessDecisionManagerTest extends \PHPUnit_Framework_TestCase
return $voter;
}
-
- protected function getVoterSupportsClass($ret)
- {
- $voter = $this->getMock('Symfony\Component\Security\Core\Authorization\Voter\VoterInterface');
- $voter->expects($this->any())
- ->method('supportsClass')
- ->will($this->returnValue($ret));
-
- return $voter;
- }
-
- protected function getVoterSupportsAttribute($ret)
- {
- $voter = $this->getMock('Symfony\Component\Security\Core\Authorization\Voter\VoterInterface');
- $voter->expects($this->any())
- ->method('supportsAttribute')
- ->will($this->returnValue($ret));
-
- return $voter;
- }
}
diff --git a/Core/Tests/Authorization/Voter/AuthenticatedVoterTest.php b/Core/Tests/Authorization/Voter/AuthenticatedVoterTest.php
index 4679c0f..60e2a19 100644
--- a/Core/Tests/Authorization/Voter/AuthenticatedVoterTest.php
+++ b/Core/Tests/Authorization/Voter/AuthenticatedVoterTest.php
@@ -17,12 +17,6 @@ use Symfony\Component\Security\Core\Authorization\Voter\VoterInterface;
class AuthenticatedVoterTest extends \PHPUnit_Framework_TestCase
{
- public function testSupportsClass()
- {
- $voter = new AuthenticatedVoter($this->getResolver());
- $this->assertTrue($voter->supportsClass('stdClass'));
- }
-
/**
* @dataProvider getVoteTests
*/
diff --git a/Core/Tests/Authorization/Voter/ExpressionVoterTest.php b/Core/Tests/Authorization/Voter/ExpressionVoterTest.php
index dc8ea79..5296296 100644
--- a/Core/Tests/Authorization/Voter/ExpressionVoterTest.php
+++ b/Core/Tests/Authorization/Voter/ExpressionVoterTest.php
@@ -17,15 +17,6 @@ use Symfony\Component\Security\Core\Role\Role;
class ExpressionVoterTest extends \PHPUnit_Framework_TestCase
{
- public function testSupportsAttribute()
- {
- $expression = $this->createExpression();
- $expressionLanguage = $this->getMock('Symfony\Component\Security\Core\Authorization\ExpressionLanguage');
- $voter = new ExpressionVoter($expressionLanguage, $this->createTrustResolver(), $this->createRoleHierarchy());
-
- $this->assertTrue($voter->supportsAttribute($expression));
- }
-
/**
* @dataProvider getVoteTests
*/
diff --git a/Core/Tests/Authorization/Voter/RoleVoterTest.php b/Core/Tests/Authorization/Voter/RoleVoterTest.php
index 03ab2da..9982bdf 100644
--- a/Core/Tests/Authorization/Voter/RoleVoterTest.php
+++ b/Core/Tests/Authorization/Voter/RoleVoterTest.php
@@ -17,13 +17,6 @@ use Symfony\Component\Security\Core\Role\Role;
class RoleVoterTest extends \PHPUnit_Framework_TestCase
{
- public function testSupportsClass()
- {
- $voter = new RoleVoter();
-
- $this->assertTrue($voter->supportsClass('Foo'));
- }
-
/**
* @dataProvider getVoteTests
*/