1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace OpenConext\Value\Saml\Metadata\Common; |
4
|
|
|
|
5
|
|
|
use OpenConext\Value\Assert\Assertion; |
6
|
|
|
use OpenConext\Value\Serializable; |
7
|
|
|
|
8
|
|
|
final class Endpoint implements Serializable |
9
|
|
|
{ |
10
|
|
|
/** |
11
|
|
|
* @var Binding |
12
|
|
|
*/ |
13
|
|
|
private $binding; |
14
|
|
|
|
15
|
|
|
/** |
16
|
|
|
* @var string |
17
|
|
|
*/ |
18
|
|
|
private $location; |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* @var null|string |
22
|
|
|
*/ |
23
|
|
|
private $responseLocation; |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* @param Binding $binding |
27
|
|
|
* @param string $location |
28
|
|
|
* @param null|string $responseLocation |
29
|
|
|
*/ |
30
|
|
|
public function __construct(Binding $binding, $location, $responseLocation = null) |
31
|
|
|
{ |
32
|
|
|
Assertion::nonEmptyString($location, 'location'); |
33
|
|
|
Assertion::nullOrNonEmptyString($responseLocation, 'responseLocation'); |
34
|
|
|
|
35
|
|
|
$this->binding = $binding; |
36
|
|
|
$this->location = $location; |
37
|
|
|
$this->responseLocation = $responseLocation; |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* @return Binding |
42
|
|
|
*/ |
43
|
|
|
public function getBinding() |
44
|
|
|
{ |
45
|
|
|
return $this->binding; |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* @return string |
50
|
|
|
*/ |
51
|
|
|
public function getLocation() |
52
|
|
|
{ |
53
|
|
|
return $this->location; |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* @return null|string |
58
|
|
|
*/ |
59
|
|
|
public function getResponseLocation() |
60
|
|
|
{ |
61
|
|
|
return $this->responseLocation; |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
/** |
65
|
|
|
* @param Endpoint $other |
66
|
|
|
* @return bool |
67
|
|
|
*/ |
68
|
|
|
public function equals(Endpoint $other) |
69
|
|
|
{ |
70
|
|
|
return $this->binding->equals($other->binding) |
71
|
|
|
&& $this->location === $other->location |
72
|
|
|
&& $this->responseLocation === $other->responseLocation; |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
public static function deserialize($data) |
76
|
|
|
{ |
77
|
|
|
Assertion::isArray($data); |
78
|
|
|
Assertion::keysExist($data, array('binding', 'location', 'response_location')); |
79
|
|
|
|
80
|
|
|
return new self(Binding::deserialize($data['binding']), $data['location'], $data['response_location']); |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
public function serialize() |
84
|
|
|
{ |
85
|
|
|
return array( |
86
|
|
|
'binding' => $this->binding->serialize(), |
87
|
|
|
'location' => $this->location, |
88
|
|
|
'response_location' => $this->responseLocation |
89
|
|
|
); |
90
|
|
|
} |
91
|
|
|
|
92
|
|
|
public function __toString() |
93
|
|
|
{ |
94
|
|
|
return sprintf( |
95
|
|
|
'Endpoint(Binding=%s, Location=%s, ResponseLocation=%s', |
96
|
|
|
(string) $this->binding, |
97
|
|
|
$this->location, |
98
|
|
|
($this->responseLocation ?: 'null') |
99
|
|
|
); |
100
|
|
|
} |
101
|
|
|
} |
102
|
|
|
|