Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Visibility changes #198

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
6 commits merged into from
Mar 10, 2011
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@

namespace Symfony\Bundle\DoctrineMongoDBBundle\Security;

use Symfony\Component\Security\Core\User\AccountInterface;
use Symfony\Component\Security\Core\User\UserInterface;
use Symfony\Component\Security\Core\User\UserProviderInterface;
use Symfony\Component\Security\Core\Exception\UnsupportedAccountException;
use Symfony\Component\Security\Core\Exception\UnsupportedUserException;
use Symfony\Component\Security\Core\Exception\UsernameNotFoundException;

class DocumentUserProvider implements UserProviderInterface
Expand Down Expand Up @@ -59,13 +59,13 @@ public function loadUserByUsername($username)
/**
* {@inheritDoc}
*/
public function loadUserByAccount(AccountInterface $account)
public function loadUser(UserInterface $user)
{
if (!$account instanceof $this->class) {
throw new UnsupportedAccountException(sprintf('Instances of "%s" are not supported.', get_class($account)));
if (!$user instanceof $this->class) {
throw new UnsupportedUserException(sprintf('Instances of "%s" are not supported.', get_class($user)));
}

return $this->loadUserByUsername($account->getUsername());
return $this->loadUserByUsername($user->getUsername());
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
*/
class SecurityDataCollector extends DataCollector
{
protected $context;
private $context;

public function __construct(SecurityContextInterface $context = null)
{
Expand Down Expand Up @@ -53,7 +53,7 @@ public function collect(Request $request, Response $response, \Exception $except
$this->data = array(
'enabled' => true,
'authenticated' => $token->isAuthenticated(),
'user' => (string) $token,
'user' => $token->getUsername(),
'roles' => array_map(function ($role){ return $role->getRole();}, $token->getRoles()),
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public function getMainConfigTree(array $factories)
return $tb->buildTree();
}

protected function addAclSection($rootNode)
private function addAclSection($rootNode)
{
$rootNode
->arrayNode('acl')
Expand All @@ -68,7 +68,7 @@ protected function addAclSection($rootNode)
;
}

protected function addRoleHierarchySection($rootNode)
private function addRoleHierarchySection($rootNode)
{
$rootNode
->fixXmlConfig('role', 'role_hierarchy')
Expand All @@ -87,7 +87,7 @@ protected function addRoleHierarchySection($rootNode)
;
}

protected function addAccessControlSection($rootNode)
private function addAccessControlSection($rootNode)
{
$rootNode
->fixXmlConfig('rule', 'access_control')
Expand Down Expand Up @@ -122,7 +122,7 @@ protected function addAccessControlSection($rootNode)
;
}

protected function addFirewallsSection($rootNode, array $factories)
private function addFirewallsSection($rootNode, array $factories)
{
$firewallNodeBuilder =
$rootNode
Expand Down Expand Up @@ -186,7 +186,7 @@ protected function addFirewallsSection($rootNode, array $factories)
}
}

protected function addProvidersSection($rootNode)
private function addProvidersSection($rootNode)
{
$rootNode
->fixXmlConfig('provider')
Expand Down Expand Up @@ -225,7 +225,7 @@ protected function addProvidersSection($rootNode)
;
}

protected function addEncodersSection($rootNode)
private function addEncodersSection($rootNode)
{
$rootNode
->fixXmlConfig('encoder')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@
*/
class SecurityExtension extends Extension
{
protected $requestMatchers = array();
protected $contextListeners = array();
protected $listenerPositions = array('pre_auth', 'form', 'http', 'remember_me');
protected $configuration;
protected $factories;
private $requestMatchers = array();
private $contextListeners = array();
private $listenerPositions = array('pre_auth', 'form', 'http', 'remember_me');
private $configuration;
private $factories;

public function __construct()
{
Expand Down Expand Up @@ -107,7 +107,7 @@ public function load(array $configs, ContainerBuilder $container)
));
}

protected function aclLoad($config, ContainerBuilder $container)
private function aclLoad($config, ContainerBuilder $container)
{
$loader = new XmlFileLoader($container, new FileLocator(array(__DIR__.'/../Resources/config', __DIR__.'/Resources/config')));
$loader->load('security_acl.xml');
Expand All @@ -128,7 +128,7 @@ protected function aclLoad($config, ContainerBuilder $container)
* @param ContainerBuilder $container A ContainerBuilder instance
*/

protected function createRoleHierarchy($config, ContainerBuilder $container)
private function createRoleHierarchy($config, ContainerBuilder $container)
{
if (!isset($config['role_hierarchy'])) {
$container->remove('security.access.role_hierarchy_voter');
Expand All @@ -140,7 +140,7 @@ protected function createRoleHierarchy($config, ContainerBuilder $container)
$container->remove('security.access.simple_role_voter');
}

protected function createAuthorization($config, ContainerBuilder $container)
private function createAuthorization($config, ContainerBuilder $container)
{
if (!$config['access_control']) {
return;
Expand All @@ -165,7 +165,7 @@ protected function createAuthorization($config, ContainerBuilder $container)
}
}

protected function createFirewalls($config, ContainerBuilder $container)
private function createFirewalls($config, ContainerBuilder $container)
{
if (!isset($config['firewalls'])) {
return;
Expand Down Expand Up @@ -213,7 +213,7 @@ protected function createFirewalls($config, ContainerBuilder $container)
;
}

protected function createFirewall(ContainerBuilder $container, $id, $firewall, &$authenticationProviders, $providerIds, array $factories)
private function createFirewall(ContainerBuilder $container, $id, $firewall, &$authenticationProviders, $providerIds, array $factories)
{
// Matcher
$i = 0;
Expand Down Expand Up @@ -310,7 +310,7 @@ protected function createFirewall(ContainerBuilder $container, $id, $firewall, &
return array($matcher, $listeners, $exceptionListener);
}

protected function createContextListener($container, $contextKey)
private function createContextListener($container, $contextKey)
{
if (isset($this->contextListeners[$contextKey])) {
return $this->contextListeners[$contextKey];
Expand All @@ -323,7 +323,7 @@ protected function createContextListener($container, $contextKey)
return $this->contextListeners[$contextKey] = $listenerId;
}

protected function createAuthenticationListeners($container, $id, $firewall, &$authenticationProviders, $defaultProvider, array $factories)
private function createAuthenticationListeners($container, $id, $firewall, &$authenticationProviders, $defaultProvider, array $factories)
{
$listeners = array();
$hasListeners = false;
Expand Down Expand Up @@ -359,11 +359,11 @@ protected function createAuthenticationListeners($container, $id, $firewall, &$a
return array($listeners, $defaultEntryPoint);
}

protected function createEncoders($encoders, ContainerBuilder $container)
private function createEncoders($encoders, ContainerBuilder $container)
{
$encoderMap = array();
foreach ($encoders as $class => $encoder) {
$encoderMap[$class] = $this->createEncoder($class, $encoder, $container);
$encoderMap[$class] = $this->createEncoder($encoder, $container);
}

$container
Expand All @@ -372,7 +372,7 @@ protected function createEncoders($encoders, ContainerBuilder $container)
;
}

protected function createEncoder($accountClass, $config, ContainerBuilder $container)
private function createEncoder($config, ContainerBuilder $container)
{
// a custom encoder service
if (isset($config['id'])) {
Expand Down Expand Up @@ -403,7 +403,7 @@ protected function createEncoder($accountClass, $config, ContainerBuilder $conta
}

// Parses user providers and returns an array of their ids
protected function createUserProviders($config, ContainerBuilder $container)
private function createUserProviders($config, ContainerBuilder $container)
{
$providerIds = array();
foreach ($config['providers'] as $name => $provider) {
Expand All @@ -415,7 +415,7 @@ protected function createUserProviders($config, ContainerBuilder $container)
}

// Parses a <provider> tag and returns the id for the related user provider service
protected function createUserDaoProvider($name, $provider, ContainerBuilder $container, $master = true)
private function createUserDaoProvider($name, $provider, ContainerBuilder $container, $master = true)
{
$name = $this->getUserProviderId(strtolower($name));

Expand Down Expand Up @@ -468,12 +468,12 @@ protected function createUserDaoProvider($name, $provider, ContainerBuilder $con
return $name;
}

protected function getUserProviderId($name)
private function getUserProviderId($name)
{
return 'security.user.provider.concrete.'.$name;
}

protected function createExceptionListener($container, $config, $id, $defaultEntryPoint)
private function createExceptionListener($container, $config, $id, $defaultEntryPoint)
{
$exceptionListenerId = 'security.exception_listener.'.$id;
$listener = $container->setDefinition($exceptionListenerId, new DefinitionDecorator('security.exception_listener'));
Expand All @@ -489,7 +489,7 @@ protected function createExceptionListener($container, $config, $id, $defaultEnt
return $exceptionListenerId;
}

protected function createSwitchUserListener($container, $id, $config, $defaultProvider)
private function createSwitchUserListener($container, $id, $config, $defaultProvider)
{
$userProvider = isset($config['provider']) ? $this->getUserProviderId($config['provider']) : $defaultProvider;

Expand All @@ -503,7 +503,7 @@ protected function createSwitchUserListener($container, $id, $config, $defaultPr
return $switchUserListenerId;
}

protected function createRequestMatcher($container, $path = null, $host = null, $methods = null, $ip = null, array $attributes = array())
private function createRequestMatcher($container, $path = null, $host = null, $methods = null, $ip = null, array $attributes = array())
{
$serialized = serialize(array($path, $host, $methods, $ip, $attributes));
$id = 'security.request_matcher.'.md5($serialized).sha1($serialized);
Expand All @@ -527,7 +527,7 @@ protected function createRequestMatcher($container, $path = null, $host = null,
return $this->requestMatchers[$id] = new Reference($id);
}

protected function createListenerFactories(ContainerBuilder $container, $config)
private function createListenerFactories(ContainerBuilder $container, $config)
{
if (null !== $this->factories) {
return $this->factories;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<parameter key="security.context.class">Symfony\Component\Security\Core\SecurityContext</parameter>
<parameter key="security.context.always_authenticate">false</parameter>

<parameter key="security.account_checker.class">Symfony\Component\Security\Core\User\AccountChecker</parameter>
<parameter key="security.user_checker.class">Symfony\Component\Security\Core\User\UserChecker</parameter>

<parameter key="security.encoder_factory.generic.class">Symfony\Component\Security\Core\Encoder\EncoderFactory</parameter>
<parameter key="security.encoder.digest.class">Symfony\Component\Security\Core\Encoder\MessageDigestPasswordEncoder</parameter>
Expand Down Expand Up @@ -72,7 +72,7 @@

<service id="security.encoder_factory" alias="security.encoder_factory.generic"></service>

<service id="security.account_checker" class="%security.account_checker.class%" public="false" />
<service id="security.user_checker" class="%security.user_checker.class%" public="false" />


<!-- Authorization related services -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,14 +137,14 @@

<service id="security.authentication.provider.dao" class="%security.authentication.provider.dao.class%" abstract="true" public="false">
<argument /> <!-- User Provider -->
<argument type="service" id="security.account_checker" />
<argument type="service" id="security.user_checker" />
<argument /> <!-- Provider-shared Key -->
<argument type="service" id="security.encoder_factory" />
</service>

<service id="security.authentication.provider.pre_authenticated" class="%security.authentication.provider.pre_authenticated.class%" abstract="true" public="false">
<argument /> <!-- User Provider -->
<argument type="service" id="security.account_checker" />
<argument type="service" id="security.user_checker" />
</service>

<service id="security.exception_listener" class="%security.exception_listener.class%" public="false" abstract="true">
Expand All @@ -159,7 +159,7 @@
<service id="security.authentication.switchuser_listener" class="%security.authentication.switchuser_listener.class%" public="false" abstract="true">
<argument type="service" id="security.context" />
<argument /> <!-- User Provider -->
<argument type="service" id="security.account_checker" />
<argument type="service" id="security.user_checker" />
<argument /> <!-- Provider Key -->
<argument type="service" id="security.access.decision_manager" />
<argument type="service" id="logger" on-invalid="null" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
</service>

<service id="security.authentication.provider.rememberme" class="%security.authentication.provider.rememberme.class%" abstract="true" public="false">
<argument type="service" id="security.account_checker" />
<argument type="service" id="security.user_checker" />
</service>

<service id="security.rememberme.token.provider.in_memory" class="%security.rembemerme.token.provider.in_memory.class%" public="false"></service>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
*/
class FirewallContext
{
protected $listeners;
protected $exceptionListener;
private $listeners;
private $exceptionListener;

public function __construct(array $listeners, ExceptionListener $exceptionListener = null)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@
/**
* SecurityHelper provides read-only access to the security context.
*
* @author Fabien Potencier <[email protected]>
* @author Fabien Potencier <[email protected]>
*/
class SecurityHelper extends Helper
{
protected $context;
private $context;

/**
* Constructor.
Expand All @@ -34,7 +34,7 @@ public function __construct(SecurityContextInterface $context = null)
$this->context = $context;
}

public function vote($role, $object = null, $field = null)
public function isGranted($role, $object = null, $field = null)
{
if (null === $this->context) {
return false;
Expand All @@ -44,7 +44,7 @@ public function vote($role, $object = null, $field = null)
$object = new FieldVote($object, $field);
}

return $this->context->vote($role, $object);
return $this->context->isGranted($role, $object);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@
*/
class SecurityExtension extends \Twig_Extension
{
protected $context;
private $context;

public function __construct(SecurityContextInterface $context = null)
{
$this->context = $context;
}

public function vote($role, $object = null, $field = null)
public function isGranted($role, $object = null, $field = null)
{
if (null === $this->context) {
return false;
Expand All @@ -38,7 +38,7 @@ public function vote($role, $object = null, $field = null)
$object = new FieldVote($object, $field);
}

return $this->context->vote($role, $object);
return $this->context->isGranted($role, $object);
}

/**
Expand All @@ -47,7 +47,7 @@ public function vote($role, $object = null, $field = null)
public function getFunctions()
{
return array(
'has_role' => new \Twig_Function_Method($this, 'vote'),
'is_granted' => new \Twig_Function_Method($this, 'isGranted'),
);
}

Expand Down
Loading