|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* Copyright 2015 SURFnet B.V. |
|
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 OpenConext\Profile\Value; |
|
20
|
|
|
|
|
21
|
|
|
use OpenConext\Profile\Assert; |
|
22
|
|
|
|
|
23
|
|
|
final class EntityType |
|
24
|
|
|
{ |
|
25
|
|
|
const TYPE_SP = 'saml20-sp'; |
|
26
|
|
|
const TYPE_IDP = 'saml20-idp'; |
|
27
|
|
|
|
|
28
|
|
|
/** |
|
29
|
|
|
* @var string |
|
30
|
|
|
*/ |
|
31
|
|
|
private $type; |
|
32
|
|
|
|
|
33
|
|
|
/** |
|
34
|
|
|
* @param string $type |
|
35
|
|
|
*/ |
|
36
|
|
|
public function __construct($type) |
|
37
|
|
|
{ |
|
38
|
|
|
Assert::inArray($type, [self::TYPE_SP, self::TYPE_IDP]); |
|
39
|
|
|
|
|
40
|
|
|
$this->type = $type; |
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
|
|
/** |
|
44
|
|
|
* Creates a new ServiceProvider Type |
|
45
|
|
|
* @return EntityType |
|
46
|
|
|
* |
|
47
|
|
|
* @SuppressWarnings(PHPMD.CamelCaseMethodName) |
|
48
|
|
|
* @SuppressWarnings(PHPMD.ShortMethodName) |
|
49
|
|
|
*/ |
|
50
|
|
|
public static function SP() |
|
51
|
|
|
{ |
|
52
|
|
|
return new EntityType(self::TYPE_SP); |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
// @codingStandardsIgnoreStart |
|
56
|
|
|
/** |
|
57
|
|
|
* Creates a new IdentityProvider Type |
|
58
|
|
|
* @return EntityType |
|
59
|
|
|
* |
|
60
|
|
|
* @SuppressWarnings(PHPMD.CamelCaseMethodName) |
|
61
|
|
|
*/ |
|
62
|
|
|
public static function IdP() |
|
63
|
|
|
{ |
|
64
|
|
|
return new EntityType(self::TYPE_IDP); |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
/** |
|
68
|
|
|
* @return bool |
|
69
|
|
|
*/ |
|
70
|
|
|
public function isSP() |
|
71
|
|
|
{ |
|
72
|
|
|
return $this->type === self::TYPE_SP; |
|
73
|
|
|
} |
|
74
|
|
|
|
|
75
|
|
|
/** |
|
76
|
|
|
* @return bool |
|
77
|
|
|
*/ |
|
78
|
|
|
public function isIdP() |
|
79
|
|
|
{ |
|
80
|
|
|
return $this->type === self::TYPE_IDP; |
|
81
|
|
|
} |
|
82
|
|
|
// @codingStandardsIgnoreEnd |
|
83
|
|
|
|
|
84
|
|
|
/** |
|
85
|
|
|
* @param EntityType $other |
|
86
|
|
|
* @return bool |
|
87
|
|
|
*/ |
|
88
|
|
|
public function equals(EntityType $other) |
|
89
|
|
|
{ |
|
90
|
|
|
return $this->type === $other->type; |
|
91
|
|
|
} |
|
92
|
|
|
|
|
93
|
|
|
public function __toString() |
|
94
|
|
|
{ |
|
95
|
|
|
return $this->type; |
|
96
|
|
|
} |
|
97
|
|
|
} |
|
98
|
|
|
|