1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of the LightSAML-Core package. |
5
|
|
|
* |
6
|
|
|
* (c) Milos Tomic <[email protected]> |
7
|
|
|
* |
8
|
|
|
* This source file is subject to the MIT license that is bundled |
9
|
|
|
* with this source code in the file LICENSE. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
namespace LightSaml\Model\Assertion; |
13
|
|
|
|
14
|
|
|
use LightSaml\Model\Context\DeserializationContext; |
15
|
|
|
use LightSaml\Model\Context\SerializationContext; |
16
|
|
|
use LightSaml\SamlConstants; |
17
|
|
|
|
18
|
|
|
class ProxyRestriction extends AbstractCondition |
19
|
|
|
{ |
20
|
|
|
/** |
21
|
|
|
* @var int|null |
22
|
|
|
*/ |
23
|
|
|
protected $count; |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* @var string[]|null |
27
|
|
|
*/ |
28
|
|
|
protected $audience; |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* @param int $count |
32
|
|
|
* @param string[] $audience |
33
|
|
|
*/ |
34
|
9 |
|
public function __construct($count = null, array $audience = null) |
35
|
|
|
{ |
36
|
9 |
|
$this->count = $count; |
37
|
9 |
|
$this->audience = $audience; |
38
|
9 |
|
} |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* @param string $audience |
42
|
|
|
* |
43
|
|
|
* @return ProxyRestriction |
44
|
|
|
*/ |
45
|
|
|
public function addAudience($audience) |
46
|
|
|
{ |
47
|
|
|
if (false == is_array($this->audience)) { |
|
|
|
|
48
|
|
|
$this->audience = array(); |
49
|
|
|
} |
50
|
|
|
$this->audience[] = (string) $audience; |
51
|
|
|
|
52
|
|
|
return $this; |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* @return null|\string[] |
57
|
|
|
*/ |
58
|
2 |
|
public function getAllAudience() |
59
|
|
|
{ |
60
|
2 |
|
return $this->audience; |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
/** |
64
|
|
|
* @param int|null $count |
65
|
|
|
* |
66
|
|
|
* @return ProxyRestriction |
67
|
|
|
*/ |
68
|
|
|
public function setCount($count) |
69
|
|
|
{ |
70
|
|
|
$this->count = null !== $count ? intval($count) : null; |
71
|
|
|
|
72
|
|
|
return $this; |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
/** |
76
|
|
|
* @return int|null |
77
|
|
|
*/ |
78
|
3 |
|
public function getCount() |
79
|
|
|
{ |
80
|
3 |
|
return $this->count; |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
/** |
84
|
|
|
* @param \DOMNode $parent |
85
|
|
|
* @param SerializationContext $context |
86
|
|
|
* |
87
|
|
|
* @return void |
88
|
|
|
*/ |
89
|
|
View Code Duplication |
public function serialize(\DOMNode $parent, SerializationContext $context) |
|
|
|
|
90
|
|
|
{ |
91
|
|
|
$result = $this->createElement('ProxyRestriction', SamlConstants::NS_ASSERTION, $parent, $context); |
92
|
|
|
|
93
|
|
|
$this->attributesToXml(array('count'), $result); |
94
|
|
|
|
95
|
|
|
$this->manyElementsToXml($this->getAllAudience(), $result, $context, 'Audience'); |
96
|
|
|
} |
97
|
|
|
|
98
|
|
|
/** |
99
|
|
|
* @param \DOMNode $node |
100
|
|
|
* @param DeserializationContext $context |
101
|
|
|
*/ |
102
|
|
View Code Duplication |
public function deserialize(\DOMNode $node, DeserializationContext $context) |
|
|
|
|
103
|
|
|
{ |
104
|
|
|
$this->checkXmlNodeName($node, 'ProxyRestriction', SamlConstants::NS_ASSERTION); |
105
|
|
|
|
106
|
|
|
$this->attributesFromXml($node, array('count')); |
|
|
|
|
107
|
|
|
|
108
|
|
|
$this->manyElementsFromXml($node, $context, 'Audience', 'saml', null, 'addAudience'); |
|
|
|
|
109
|
|
|
} |
110
|
|
|
} |
111
|
|
|
|
When comparing two booleans, it is generally considered safer to use the strict comparison operator.