1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* AppserverIo\Psr\Auth\MappingWrapper |
5
|
|
|
* |
6
|
|
|
* NOTICE OF LICENSE |
7
|
|
|
* |
8
|
|
|
* This source file is subject to the Open Software License (OSL 3.0) |
9
|
|
|
* that is available through the world-wide-web at this URL: |
10
|
|
|
* http://opensource.org/licenses/osl-3.0.php |
11
|
|
|
* |
12
|
|
|
* PHP version 5 |
13
|
|
|
* |
14
|
|
|
* @author Tim Wagner <[email protected]> |
15
|
|
|
* @copyright 2016 TechDivision GmbH <[email protected]> |
16
|
|
|
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) |
17
|
|
|
* @link https://github.com/appserver-io-psr/auth |
18
|
|
|
* @link http://www.appserver.io |
19
|
|
|
*/ |
20
|
|
|
|
21
|
|
|
namespace AppserverIo\Psr\Auth; |
22
|
|
|
|
23
|
|
|
use AppserverIo\Psr\Servlet\Http\HttpServletRequestInterface; |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* A wrapper implementatio for a URL pattern to an authenticator mapping. |
27
|
|
|
* |
28
|
|
|
* @author Tim Wagner <[email protected]> |
29
|
|
|
* @copyright 2016 TechDivision GmbH <[email protected]> |
30
|
|
|
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) |
31
|
|
|
* @link https://github.com/appserver-io-psr/auth |
32
|
|
|
* @link http://www.appserver.io |
33
|
|
|
*/ |
34
|
|
|
class MappingWrapper implements MappingInterface |
35
|
|
|
{ |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* The mapping instance to be wrapped. |
39
|
|
|
* |
40
|
|
|
* @var \AppserverIo\Psr\Auth\MappingInterface |
41
|
|
|
*/ |
42
|
|
|
protected $mapping; |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* Injects the passed mapping instance into this wrapper. |
46
|
|
|
* |
47
|
|
|
* @param \AppserverIo\Psr\Auth\MappingInterface $mapping The mapping instance used for initialization |
48
|
|
|
* |
49
|
|
|
* @return void |
50
|
|
|
*/ |
51
|
|
|
public function injectMapping(MappingInterface $mapping) |
52
|
|
|
{ |
53
|
|
|
$this->mapping = $mapping; |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* Return's the mapping instance. |
58
|
|
|
* |
59
|
|
|
* @return \AppserverIo\Psr\Auth\MappingInterface The mapping instance |
60
|
|
|
*/ |
61
|
|
|
public function getMapping() |
62
|
|
|
{ |
63
|
|
|
return $this->mapping; |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
/** |
67
|
|
|
* Return's the URL pattern. |
68
|
|
|
* |
69
|
|
|
* @return string The URL pattern |
70
|
|
|
*/ |
71
|
|
|
public function getUrlPattern() |
72
|
|
|
{ |
73
|
|
|
return $this->getMapping()->getUrlPattern(); |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
/** |
77
|
|
|
* Return's the authenticator serial. |
78
|
|
|
* |
79
|
|
|
* @return string The authenticator serial |
80
|
|
|
*/ |
81
|
|
|
public function getAuthenticatorSerial() |
82
|
|
|
{ |
83
|
|
|
return $this->getMapping()->getAuthenticatorSerial(); |
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
/** |
87
|
|
|
* Return's the role names. |
88
|
|
|
* |
89
|
|
|
* @return array The role names |
90
|
|
|
*/ |
91
|
|
|
public function getRoleNames() |
92
|
|
|
{ |
93
|
|
|
return $this->getMapping()->getRoleNames(); |
94
|
|
|
} |
95
|
|
|
|
96
|
|
|
/** |
97
|
|
|
* Return's the HTTP methods that has to be authenticated. |
98
|
|
|
* |
99
|
|
|
* @return array The HTTP methods |
100
|
|
|
*/ |
101
|
|
|
public function getHttpMethods() |
102
|
|
|
{ |
103
|
|
|
return $this->getMapping()->getHttpMethods(); |
104
|
|
|
} |
105
|
|
|
|
106
|
|
|
/** |
107
|
|
|
* Return's the HTTP methods that has to b omissed from authentication |
108
|
|
|
* |
109
|
|
|
* @return array The HTTP methods |
110
|
|
|
*/ |
111
|
|
|
public function getHttpMethodOmissions() |
112
|
|
|
{ |
113
|
|
|
return $this->getMapping()->getHttpMethodOmissions(); |
114
|
|
|
} |
115
|
|
|
|
116
|
|
|
/** |
117
|
|
|
* Return's TRUE if the passed request matches the mappings URL patter. |
118
|
|
|
* |
119
|
|
|
* @param \AppserverIo\Psr\Servlet\Http\HttpServletRequestInterface $servletRequest The request to match |
120
|
|
|
* |
121
|
|
|
* @return boolean TRUE if the request matches, else FALSE |
122
|
|
|
*/ |
123
|
|
|
public function match(HttpServletRequestInterface $servletRequest) |
124
|
|
|
{ |
125
|
|
|
return $this->getMapping()->match($servletRequest); |
126
|
|
|
} |
127
|
|
|
} |
128
|
|
|
|