1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace SimpleSAML\SAML2\XML; |
6
|
|
|
|
7
|
|
|
use RuntimeException; |
8
|
|
|
use SimpleSAML\Assert\Assert; |
9
|
|
|
use SimpleSAML\XML\Exception\SchemaViolationException; |
10
|
|
|
|
11
|
|
|
/** |
12
|
|
|
* Trait for several extension points objects. |
13
|
|
|
* |
14
|
|
|
* @package simplesamlphp/saml2 |
15
|
|
|
*/ |
16
|
|
|
trait ExtensionPointTrait |
17
|
|
|
{ |
18
|
|
|
/** |
19
|
|
|
* Get the local name for the element's xsi:type. |
20
|
|
|
* |
21
|
|
|
* @return string |
22
|
|
|
*/ |
23
|
|
|
public static function getXsiTypeName(): string |
24
|
|
|
{ |
25
|
|
|
Assert::true( |
26
|
|
|
defined('static::XSI_TYPE_NAME'), |
27
|
|
|
self::getClassName(static::class) |
28
|
|
|
. '::XSI_TYPE_NAME constant must be defined and set to unprefixed type for the xsi:type it represents.', |
29
|
|
|
RuntimeException::class, |
30
|
|
|
); |
31
|
|
|
|
32
|
|
|
Assert::validNCName(static::XSI_TYPE_NAME, SchemaViolationException::class); |
|
|
|
|
33
|
|
|
return static::XSI_TYPE_NAME; |
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* Get the namespace for the element's xsi:type. |
39
|
|
|
* |
40
|
|
|
* @return string |
41
|
|
|
*/ |
42
|
|
|
public static function getXsiTypeNamespaceURI(): string |
43
|
|
|
{ |
44
|
|
|
Assert::true( |
45
|
|
|
defined('static::XSI_TYPE_NAMESPACE'), |
46
|
|
|
self::getClassName(static::class) |
47
|
|
|
. '::XSI_TYPE_NAMESPACE constant must be defined and set to the namespace for the xsi:type it represents.', |
48
|
|
|
RuntimeException::class, |
49
|
|
|
); |
50
|
|
|
|
51
|
|
|
Assert::validURI(static::XSI_TYPE_NAMESPACE, SchemaViolationException::class); |
|
|
|
|
52
|
|
|
return static::XSI_TYPE_NAMESPACE; |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* Get the namespace-prefix for the element's xsi:type. |
58
|
|
|
* |
59
|
|
|
* @return string |
60
|
|
|
*/ |
61
|
|
|
public static function getXsiTypePrefix(): string |
62
|
|
|
{ |
63
|
|
|
Assert::true( |
64
|
|
|
defined('static::XSI_TYPE_PREFIX'), |
65
|
|
|
self::getClassName(static::class) |
66
|
|
|
. '::XSI_TYPE_PREFIX constant must be defined and set to the namespace for the xsi:type it represents.', |
67
|
|
|
RuntimeException::class, |
68
|
|
|
); |
69
|
|
|
|
70
|
|
|
Assert::validNCName(static::XSI_TYPE_PREFIX, SchemaViolationException::class); |
|
|
|
|
71
|
|
|
return static::XSI_TYPE_PREFIX; |
72
|
|
|
} |
73
|
|
|
} |
74
|
|
|
|