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