1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* Copyright 2014 SURFnet bv |
5
|
|
|
* |
6
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
7
|
|
|
* you may not use this file except in compliance with the License. |
8
|
|
|
* You may obtain a copy of the License at |
9
|
|
|
* |
10
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0 |
11
|
|
|
* |
12
|
|
|
* Unless required by applicable law or agreed to in writing, software |
13
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS, |
14
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
15
|
|
|
* See the License for the specific language governing permissions and |
16
|
|
|
* limitations under the License. |
17
|
|
|
*/ |
18
|
|
|
|
19
|
|
|
namespace Surfnet\StepupMiddlewareClient\Identity\Dto; |
20
|
|
|
|
21
|
|
|
use Assert; |
22
|
|
|
use Surfnet\StepupMiddlewareClient\Dto\HttpQuery; |
23
|
|
|
|
24
|
|
|
class VerifiedSecondFactorSearchQuery implements HttpQuery |
25
|
|
|
{ |
26
|
|
|
/** |
27
|
|
|
* @var string |
28
|
|
|
*/ |
29
|
|
|
private $identityId; |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* @var string |
33
|
|
|
*/ |
34
|
|
|
private $secondFactorId; |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* @var string |
38
|
|
|
*/ |
39
|
|
|
private $registrationCode; |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* @var string |
43
|
|
|
*/ |
44
|
|
|
private $institution; |
45
|
|
|
/** |
46
|
|
|
* @var string |
47
|
|
|
*/ |
48
|
|
|
private $actorId; |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* @param string $identityId |
52
|
|
|
* @return self |
53
|
|
|
*/ |
54
|
|
|
public function setIdentityId($identityId) |
55
|
|
|
{ |
56
|
|
|
$this->assertNonEmptyString($identityId, 'identityId'); |
57
|
|
|
|
58
|
|
|
$this->identityId = $identityId; |
59
|
|
|
|
60
|
|
|
return $this; |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
/** |
64
|
|
|
* @param string $secondFactorId |
65
|
|
|
* @return self |
66
|
|
|
*/ |
67
|
|
|
public function setSecondFactorId($secondFactorId) |
68
|
|
|
{ |
69
|
|
|
$this->assertNonEmptyString($secondFactorId, 'secondFactorId'); |
70
|
|
|
|
71
|
|
|
$this->secondFactorId = $secondFactorId; |
72
|
|
|
|
73
|
|
|
return $this; |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
/** |
77
|
|
|
* @param string $registrationCode |
78
|
|
|
* @return self |
79
|
|
|
*/ |
80
|
|
|
public function setRegistrationCode($registrationCode) |
81
|
|
|
{ |
82
|
|
|
$this->assertNonEmptyString($registrationCode, 'registrationCode'); |
83
|
|
|
|
84
|
|
|
$this->registrationCode = $registrationCode; |
85
|
|
|
|
86
|
|
|
return $this; |
87
|
|
|
} |
88
|
|
|
|
89
|
|
|
/** |
90
|
|
|
* @param string $institution |
91
|
|
|
* @return VerifiedSecondFactorSearchQuery |
92
|
|
|
*/ |
93
|
|
|
public function setInstitution($institution) |
94
|
|
|
{ |
95
|
|
|
$this->assertNonEmptyString($institution, 'institution'); |
96
|
|
|
|
97
|
|
|
$this->institution = $institution; |
98
|
|
|
|
99
|
|
|
return $this; |
100
|
|
|
} |
101
|
|
|
|
102
|
|
|
/** |
103
|
|
|
* @param string $actorId |
104
|
|
|
* @return VerifiedSecondFactorSearchQuery |
105
|
|
|
*/ |
106
|
|
|
public function setActorId($actorId) |
107
|
|
|
{ |
108
|
|
|
$this->assertNonEmptyString($actorId, 'actorId'); |
109
|
|
|
|
110
|
|
|
$this->actorId = $actorId; |
111
|
|
|
|
112
|
|
|
return $this; |
113
|
|
|
} |
114
|
|
|
|
115
|
|
|
private function assertNonEmptyString($value, $name) |
116
|
|
|
{ |
117
|
|
|
$message = sprintf( |
118
|
|
|
'"%s" must be a non-empty string, "%s" given', |
119
|
|
|
$name, |
120
|
|
|
(is_object($value) ? get_class($value) : gettype($value)) |
121
|
|
|
); |
122
|
|
|
|
123
|
|
|
Assert\that($value)->string($message)->notEmpty($message); |
124
|
|
|
} |
125
|
|
|
|
126
|
|
|
public function toHttpQuery() |
127
|
|
|
{ |
128
|
|
|
$fields = []; |
129
|
|
|
|
130
|
|
|
$fields['institution'] = $this->institution; |
131
|
|
|
|
132
|
|
|
if ($this->identityId) { |
133
|
|
|
$fields['identityId'] = $this->identityId; |
134
|
|
|
} |
135
|
|
|
|
136
|
|
|
if ($this->secondFactorId) { |
137
|
|
|
$fields['secondFactorId'] = $this->secondFactorId; |
138
|
|
|
} |
139
|
|
|
|
140
|
|
|
if ($this->registrationCode) { |
141
|
|
|
$fields['registrationCode'] = $this->registrationCode; |
142
|
|
|
} |
143
|
|
|
|
144
|
|
|
if ($this->actorId) { |
145
|
|
|
$fields['actorId'] = $this->actorId; |
146
|
|
|
} |
147
|
|
|
|
148
|
|
|
return '?' . http_build_query($fields); |
149
|
|
|
} |
150
|
|
|
} |
151
|
|
|
|