Skip to content

Commit 1e8236c

Browse files
committed
[Security] added AccessMapInterface
1 parent a5013bc commit 1e8236c

File tree

6 files changed

+46
-13
lines changed

6 files changed

+46
-13
lines changed

src/Symfony/Component/Security/Http/AccessMap.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
*
2121
* @author Fabien Potencier <fabien@symfony.com>
2222
*/
23-
class AccessMap
23+
class AccessMap implements AccessMapInterface
2424
{
2525
private $map = array();
2626

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Component\Security\Http;
13+
14+
use Symfony\Component\HttpFoundation\Request;
15+
16+
/**
17+
* AccessMap allows configuration of different access control rules for
18+
* specific parts of the website.
19+
*
20+
* @author Fabien Potencier <fabien@symfony.com>
21+
* @author Kris Wallsmith <kris@symfony.com>
22+
*/
23+
interface AccessMapInterface
24+
{
25+
/**
26+
* Returns security attributes and required channel for the supplied request.
27+
*
28+
* @param Request $request The current request
29+
*
30+
* @return array A tuple of security attributes and the required channel
31+
*/
32+
function getPatterns(Request $request);
33+
}

src/Symfony/Component/Security/Http/Firewall/AccessListener.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
use Symfony\Component\Security\Core\SecurityContextInterface;
1515
use Symfony\Component\Security\Core\Authorization\AccessDecisionManagerInterface;
16-
use Symfony\Component\Security\Http\AccessMap;
16+
use Symfony\Component\Security\Http\AccessMapInterface;
1717
use Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface;
1818
use Symfony\Component\HttpKernel\Log\LoggerInterface;
1919
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
@@ -33,7 +33,7 @@ class AccessListener implements ListenerInterface
3333
private $authManager;
3434
private $logger;
3535

36-
public function __construct(SecurityContextInterface $context, AccessDecisionManagerInterface $accessDecisionManager, AccessMap $map, AuthenticationManagerInterface $authManager, LoggerInterface $logger = null)
36+
public function __construct(SecurityContextInterface $context, AccessDecisionManagerInterface $accessDecisionManager, AccessMapInterface $map, AuthenticationManagerInterface $authManager, LoggerInterface $logger = null)
3737
{
3838
$this->context = $context;
3939
$this->accessDecisionManager = $accessDecisionManager;

src/Symfony/Component/Security/Http/Firewall/ChannelListener.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
namespace Symfony\Component\Security\Http\Firewall;
1313

14-
use Symfony\Component\Security\Http\AccessMap;
14+
use Symfony\Component\Security\Http\AccessMapInterface;
1515
use Symfony\Component\Security\Http\EntryPoint\AuthenticationEntryPointInterface;
1616
use Symfony\Component\HttpKernel\Log\LoggerInterface;
1717
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
@@ -28,7 +28,7 @@ class ChannelListener implements ListenerInterface
2828
private $authenticationEntryPoint;
2929
private $logger;
3030

31-
public function __construct(AccessMap $map, AuthenticationEntryPointInterface $authenticationEntryPoint, LoggerInterface $logger = null)
31+
public function __construct(AccessMapInterface $map, AuthenticationEntryPointInterface $authenticationEntryPoint, LoggerInterface $logger = null)
3232
{
3333
$this->map = $map;
3434
$this->authenticationEntryPoint = $authenticationEntryPoint;

tests/Symfony/Tests/Component/Security/Http/Firewall/AccessListenerTest.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public function testHandleWhenTheAccessDecisionManagerDecidesToRefuseAccess()
1313
{
1414
$request = $this->getMock('Symfony\Component\HttpFoundation\Request', array(), array(), '', false, false);
1515

16-
$accessMap = $this->getMock('Symfony\Component\Security\Http\AccessMap');
16+
$accessMap = $this->getMock('Symfony\Component\Security\Http\AccessMapInterface');
1717
$accessMap
1818
->expects($this->any())
1919
->method('getPatterns')
@@ -64,7 +64,7 @@ public function testHandleWhenTheTokenIsNotAuthenticated()
6464
{
6565
$request = $this->getMock('Symfony\Component\HttpFoundation\Request', array(), array(), '', false, false);
6666

67-
$accessMap = $this->getMock('Symfony\Component\Security\Http\AccessMap');
67+
$accessMap = $this->getMock('Symfony\Component\Security\Http\AccessMapInterface');
6868
$accessMap
6969
->expects($this->any())
7070
->method('getPatterns')
@@ -135,7 +135,7 @@ public function testHandleWhenThereIsNoAccessMapEntryMatchingTheRequest()
135135
{
136136
$request = $this->getMock('Symfony\Component\HttpFoundation\Request', array(), array(), '', false, false);
137137

138-
$accessMap = $this->getMock('Symfony\Component\Security\Http\AccessMap');
138+
$accessMap = $this->getMock('Symfony\Component\Security\Http\AccessMapInterface');
139139
$accessMap
140140
->expects($this->any())
141141
->method('getPatterns')
@@ -188,7 +188,7 @@ public function testHandleWhenTheSecurityContextHasNoToken()
188188
$listener = new AccessListener(
189189
$context,
190190
$this->getMock('Symfony\Component\Security\Core\Authorization\AccessDecisionManagerInterface'),
191-
$this->getMock('Symfony\Component\Security\Http\AccessMap'),
191+
$this->getMock('Symfony\Component\Security\Http\AccessMapInterface'),
192192
$this->getMock('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface')
193193
);
194194

tests/Symfony/Tests/Component/Security/Http/Firewall/ChannelListenerTest.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public function testHandleWithNotSecuredRequestAndHttpChannel()
1717
->will($this->returnValue(false))
1818
;
1919

20-
$accessMap = $this->getMock('Symfony\Component\Security\Http\AccessMap');
20+
$accessMap = $this->getMock('Symfony\Component\Security\Http\AccessMapInterface');
2121
$accessMap
2222
->expects($this->any())
2323
->method('getPatterns')
@@ -55,7 +55,7 @@ public function testHandleWithSecuredRequestAndHttpsChannel()
5555
->will($this->returnValue(true))
5656
;
5757

58-
$accessMap = $this->getMock('Symfony\Component\Security\Http\AccessMap');
58+
$accessMap = $this->getMock('Symfony\Component\Security\Http\AccessMapInterface');
5959
$accessMap
6060
->expects($this->any())
6161
->method('getPatterns')
@@ -95,7 +95,7 @@ public function testHandleWithNotSecuredRequestAndHttpsChannel()
9595

9696
$response = new Response();
9797

98-
$accessMap = $this->getMock('Symfony\Component\Security\Http\AccessMap');
98+
$accessMap = $this->getMock('Symfony\Component\Security\Http\AccessMapInterface');
9999
$accessMap
100100
->expects($this->any())
101101
->method('getPatterns')
@@ -138,7 +138,7 @@ public function testHandleWithSecuredRequestAndHttpChannel()
138138

139139
$response = new Response();
140140

141-
$accessMap = $this->getMock('Symfony\Component\Security\Http\AccessMap');
141+
$accessMap = $this->getMock('Symfony\Component\Security\Http\AccessMapInterface');
142142
$accessMap
143143
->expects($this->any())
144144
->method('getPatterns')

0 commit comments

Comments
 (0)