1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* BigBlueButton open source conferencing system - https://www.bigbluebutton.org/. |
5
|
|
|
* |
6
|
|
|
* Copyright (c) 2016-2024 BigBlueButton Inc. and by respective authors (see below). |
7
|
|
|
* |
8
|
|
|
* This program is free software; you can redistribute it and/or modify it under the |
9
|
|
|
* terms of the GNU Lesser General Public License as published by the Free Software |
10
|
|
|
* Foundation; either version 3.0 of the License, or (at your option) any later |
11
|
|
|
* version. |
12
|
|
|
* |
13
|
|
|
* BigBlueButton is distributed in the hope that it will be useful, but WITHOUT ANY |
14
|
|
|
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A |
15
|
|
|
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. |
16
|
|
|
* |
17
|
|
|
* You should have received a copy of the GNU Lesser General Public License along |
18
|
|
|
* with BigBlueButton; if not, see <https://www.gnu.org/licenses/>. |
19
|
|
|
*/ |
20
|
|
|
|
21
|
|
|
namespace BigBlueButton\Util; |
22
|
|
|
|
23
|
|
|
use BigBlueButton\Core\ApiMethod; |
24
|
|
|
use BigBlueButton\Parameters\CreateMeetingParameters; |
25
|
|
|
use BigBlueButton\Parameters\DeleteRecordingsParameters; |
26
|
|
|
use BigBlueButton\Parameters\EndMeetingParameters; |
27
|
|
|
use BigBlueButton\Parameters\GetMeetingInfoParameters; |
28
|
|
|
use BigBlueButton\Parameters\GetRecordingsParameters; |
29
|
|
|
use BigBlueButton\Parameters\GetRecordingTextTracksParameters; |
30
|
|
|
use BigBlueButton\Parameters\HooksCreateParameters; |
31
|
|
|
use BigBlueButton\Parameters\HooksDestroyParameters; |
32
|
|
|
use BigBlueButton\Parameters\InsertDocumentParameters; |
33
|
|
|
use BigBlueButton\Parameters\IsMeetingRunningParameters; |
34
|
|
|
use BigBlueButton\Parameters\JoinMeetingParameters; |
35
|
|
|
use BigBlueButton\Parameters\PublishRecordingsParameters; |
36
|
|
|
use BigBlueButton\Parameters\PutRecordingTextTrackParameters; |
37
|
|
|
use BigBlueButton\Parameters\UpdateRecordingsParameters; |
38
|
|
|
|
39
|
|
|
class UrlBuilder |
40
|
|
|
{ |
41
|
|
|
/** @deprecated Property will be private soon. Use setter/getter instead. */ |
42
|
|
|
protected string $hashingAlgorithm; |
43
|
|
|
|
44
|
|
|
private string $secret; |
45
|
|
|
|
46
|
|
|
private string $baseUrl; |
47
|
|
|
|
48
|
|
|
public function __construct(string $secret, string $baseUrl, string $hashingAlgorithm) |
49
|
|
|
{ |
50
|
|
|
$this->setSecret($secret); |
51
|
|
|
$this->setBaseUrl($baseUrl); |
52
|
|
|
$this->setHashingAlgorithm($hashingAlgorithm); |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
// Getters & Setters |
56
|
|
|
public function setSecret(string $secret): self |
57
|
|
|
{ |
58
|
|
|
$this->secret = $secret; |
59
|
|
|
|
60
|
|
|
return $this; |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
public function setBaseUrl(string $baseUrl): self |
64
|
|
|
{ |
65
|
|
|
// add tailing dir-separator if missing |
66
|
|
|
if ('/' != mb_substr($baseUrl, -1)) { |
67
|
|
|
$baseUrl .= '/'; |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
$this->baseUrl = $baseUrl; |
71
|
|
|
|
72
|
|
|
return $this; |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
public function setHashingAlgorithm(string $hashingAlgorithm): self |
76
|
|
|
{ |
77
|
|
|
$this->hashingAlgorithm = $hashingAlgorithm; |
|
|
|
|
78
|
|
|
|
79
|
|
|
return $this; |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
public function getHashingAlgorithm(): string |
83
|
|
|
{ |
84
|
|
|
return $this->hashingAlgorithm; |
|
|
|
|
85
|
|
|
} |
86
|
|
|
|
87
|
|
|
// Basic functions |
88
|
|
|
/** |
89
|
|
|
* Builds an API method URL that includes the url + params + its generated checksum. |
90
|
|
|
*/ |
91
|
|
|
public function buildUrl(string $method = '', string $params = '', bool $append = true): string |
92
|
|
|
{ |
93
|
|
|
return $this->baseUrl . 'api/' . $method . ($append ? '?' . $this->buildQs($method, $params) : ''); |
|
|
|
|
94
|
|
|
} |
95
|
|
|
|
96
|
|
|
/** |
97
|
|
|
* Builds a query string for an API method URL that includes the params + its generated checksum. |
98
|
|
|
* |
99
|
|
|
* @deprecated Function only used internal. Function will be private soon. No replacement. |
100
|
|
|
*/ |
101
|
|
|
public function buildQs(string $method = '', string $params = ''): string |
102
|
|
|
{ |
103
|
|
|
return $params . '&checksum=' . hash($this->hashingAlgorithm, $method . $params . $this->secret); |
|
|
|
|
104
|
|
|
} |
105
|
|
|
|
106
|
|
|
// URL-Generators |
107
|
|
|
public function getCreateMeetingUrl(CreateMeetingParameters $createMeetingParams): string |
108
|
|
|
{ |
109
|
|
|
return $this->buildUrl(ApiMethod::CREATE, $createMeetingParams->getHTTPQuery()); |
110
|
|
|
} |
111
|
|
|
|
112
|
|
|
public function getJoinMeetingURL(JoinMeetingParameters $joinMeetingParams): string |
113
|
|
|
{ |
114
|
|
|
return $this->buildUrl(ApiMethod::JOIN, $joinMeetingParams->getHTTPQuery()); |
115
|
|
|
} |
116
|
|
|
|
117
|
|
|
public function getEndMeetingURL(EndMeetingParameters $endParams): string |
118
|
|
|
{ |
119
|
|
|
return $this->buildUrl(ApiMethod::END, $endParams->getHTTPQuery()); |
120
|
|
|
} |
121
|
|
|
|
122
|
|
|
public function getInsertDocumentUrl(InsertDocumentParameters $insertDocumentParameters): string |
123
|
|
|
{ |
124
|
|
|
return $this->buildUrl(ApiMethod::INSERT_DOCUMENT, $insertDocumentParameters->getHTTPQuery()); |
125
|
|
|
} |
126
|
|
|
|
127
|
|
|
public function getIsMeetingRunningUrl(IsMeetingRunningParameters $meetingParams): string |
128
|
|
|
{ |
129
|
|
|
return $this->buildUrl(ApiMethod::IS_MEETING_RUNNING, $meetingParams->getHTTPQuery()); |
130
|
|
|
} |
131
|
|
|
|
132
|
|
|
public function getMeetingsUrl(): string |
133
|
|
|
{ |
134
|
|
|
return $this->buildUrl(ApiMethod::GET_MEETINGS); |
135
|
|
|
} |
136
|
|
|
|
137
|
|
|
public function getMeetingInfoUrl(GetMeetingInfoParameters $meetingParams): string |
138
|
|
|
{ |
139
|
|
|
return $this->buildUrl(ApiMethod::GET_MEETING_INFO, $meetingParams->getHTTPQuery()); |
140
|
|
|
} |
141
|
|
|
|
142
|
|
|
public function getRecordingsUrl(GetRecordingsParameters $recordingsParams): string |
143
|
|
|
{ |
144
|
|
|
return $this->buildUrl(ApiMethod::GET_RECORDINGS, $recordingsParams->getHTTPQuery()); |
145
|
|
|
} |
146
|
|
|
|
147
|
|
|
public function getPublishRecordingsUrl(PublishRecordingsParameters $recordingParams): string |
148
|
|
|
{ |
149
|
|
|
return $this->buildUrl(ApiMethod::PUBLISH_RECORDINGS, $recordingParams->getHTTPQuery()); |
150
|
|
|
} |
151
|
|
|
|
152
|
|
|
public function getDeleteRecordingsUrl(DeleteRecordingsParameters $recordingParams): string |
153
|
|
|
{ |
154
|
|
|
return $this->buildUrl(ApiMethod::DELETE_RECORDINGS, $recordingParams->getHTTPQuery()); |
155
|
|
|
} |
156
|
|
|
|
157
|
|
|
public function getUpdateRecordingsUrl(UpdateRecordingsParameters $recordingParams): string |
158
|
|
|
{ |
159
|
|
|
return $this->buildUrl(ApiMethod::UPDATE_RECORDINGS, $recordingParams->getHTTPQuery()); |
160
|
|
|
} |
161
|
|
|
|
162
|
|
|
public function getRecordingTextTracksUrl(GetRecordingTextTracksParameters $getRecordingTextTracksParameters): string |
163
|
|
|
{ |
164
|
|
|
return $this->buildUrl(ApiMethod::GET_RECORDING_TEXT_TRACKS, $getRecordingTextTracksParameters->getHTTPQuery()); |
165
|
|
|
} |
166
|
|
|
|
167
|
|
|
public function getPutRecordingTextTrackUrl(PutRecordingTextTrackParameters $putRecordingTextTrackParams): string |
168
|
|
|
{ |
169
|
|
|
return $this->buildUrl(ApiMethod::PUT_RECORDING_TEXT_TRACK, $putRecordingTextTrackParams->getHTTPQuery()); |
170
|
|
|
} |
171
|
|
|
|
172
|
|
|
public function getHooksCreateUrl(HooksCreateParameters $hookCreateParams): string |
173
|
|
|
{ |
174
|
|
|
return $this->buildUrl(ApiMethod::HOOKS_CREATE, $hookCreateParams->getHTTPQuery()); |
175
|
|
|
} |
176
|
|
|
|
177
|
|
|
public function getHooksListUrl(): string |
178
|
|
|
{ |
179
|
|
|
return $this->buildUrl(ApiMethod::HOOKS_LIST); |
180
|
|
|
} |
181
|
|
|
|
182
|
|
|
public function getHooksDestroyUrl(HooksDestroyParameters $hooksDestroyParams): string |
183
|
|
|
{ |
184
|
|
|
return $this->buildUrl(ApiMethod::HOOKS_DESTROY, $hooksDestroyParams->getHTTPQuery()); |
185
|
|
|
} |
186
|
|
|
} |
187
|
|
|
|
This property has been deprecated. The supplier of the class has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the property will be removed from the class and what other property to use instead.