|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* simpleSAMLphp-casserver is a CAS 1.0 and 2.0 compliant CAS server in the form of a simpleSAMLphp module |
|
5
|
|
|
* |
|
6
|
|
|
* Copyright (C) 2013 Bjorn R. Jensen |
|
7
|
|
|
* |
|
8
|
|
|
* This library is free software; you can redistribute it and/or |
|
9
|
|
|
* modify it under the terms of the GNU Lesser General Public |
|
10
|
|
|
* License as published by the Free Software Foundation; either |
|
11
|
|
|
* version 2.1 of the License, or (at your option) any later version. |
|
12
|
|
|
* |
|
13
|
|
|
* This library is distributed in the hope that it will be useful, |
|
14
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
15
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
16
|
|
|
* Lesser General Public License for more details. |
|
17
|
|
|
* |
|
18
|
|
|
* You should have received a copy of the GNU Lesser General Public |
|
19
|
|
|
* License along with this library; if not, write to the Free Software |
|
20
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
|
21
|
|
|
* |
|
22
|
|
|
*/ |
|
23
|
|
|
|
|
24
|
|
|
declare(strict_types=1); |
|
25
|
|
|
|
|
26
|
|
|
namespace SimpleSAML\Module\casserver\Utils; |
|
27
|
|
|
|
|
28
|
|
|
use SimpleSAML\Configuration; |
|
29
|
|
|
use SimpleSAML\Module\casserver\Cas\ServiceValidator; |
|
30
|
|
|
use SimpleSAML\Module\casserver\Cas\TicketValidator; |
|
31
|
|
|
|
|
32
|
|
|
class Url |
|
33
|
|
|
{ |
|
34
|
|
|
/** |
|
35
|
|
|
* @deprecated |
|
36
|
|
|
* @see ServiceValidator |
|
37
|
|
|
* @param string $service |
|
38
|
|
|
* @param array $legal_service_urls |
|
39
|
|
|
* @return bool |
|
40
|
|
|
*/ |
|
41
|
|
|
function checkServiceURL(string $service, array $legal_service_urls): bool |
|
|
|
|
|
|
42
|
|
|
{ |
|
43
|
|
|
//delegate to ServiceValidator until all references to this can be cleaned up |
|
44
|
|
|
$config = Configuration::loadFromArray(['legal_service_urls' => $legal_service_urls]); |
|
45
|
|
|
$serviceValidator = new ServiceValidator($config); |
|
46
|
|
|
return $serviceValidator->checkServiceURL($service) !== null; |
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
|
|
|
|
50
|
|
|
/** |
|
51
|
|
|
* @param string $parameter |
|
52
|
|
|
* @return string |
|
53
|
|
|
*/ |
|
54
|
|
|
function sanitize(string $parameter): string |
|
|
|
|
|
|
55
|
|
|
{ |
|
56
|
|
|
return TicketValidator::sanitize($parameter); |
|
57
|
|
|
} |
|
58
|
|
|
} |
|
59
|
|
|
|
Adding explicit visibility (
private,protected, orpublic) is generally recommend to communicate to other developers how, and from where this method is intended to be used.