1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace SimpleSAML\CAS\XML\cas; |
6
|
|
|
|
7
|
|
|
use DOMElement; |
8
|
|
|
use SimpleSAML\Assert\Assert; |
9
|
|
|
use SimpleSAML\XML\Exception\InvalidDOMElementException; |
10
|
|
|
use SimpleSAML\XML\Exception\MissingElementException; |
11
|
|
|
|
12
|
|
|
use function array_pop; |
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* Class for CAS proxySuccess |
16
|
|
|
* |
17
|
|
|
* @package simplesamlphp/cas |
18
|
|
|
*/ |
19
|
|
|
final class ProxySuccess extends AbstractResponse |
20
|
|
|
{ |
21
|
|
|
/** @var string */ |
22
|
|
|
final public const LOCALNAME = 'proxySuccess'; |
23
|
|
|
|
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* Initialize a cas:proxySuccess element |
27
|
|
|
* |
28
|
|
|
* @param \SimpleSAML\CAS\XML\cas\ProxyTicket $proxyTicket |
29
|
|
|
*/ |
30
|
|
|
final public function __construct( |
31
|
|
|
protected ProxyTicket $proxyTicket, |
32
|
|
|
) { |
33
|
|
|
} |
34
|
|
|
|
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* @return \SimpleSAML\CAS\XML\cas\ProxyTicket |
38
|
|
|
*/ |
39
|
|
|
public function getProxyTicket(): ProxyTicket |
40
|
|
|
{ |
41
|
|
|
return $this->proxyTicket; |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* Initialize an ProxySuccess element. |
47
|
|
|
* |
48
|
|
|
* @param \DOMElement $xml The XML element we should load. |
49
|
|
|
* @return static |
50
|
|
|
* |
51
|
|
|
* @throws \SimpleSAML\XML\Exception\InvalidDOMElementException |
52
|
|
|
* if the qualified name of the supplied element is wrong |
53
|
|
|
* @throws \SimpleSAML\XML\Exception\MissingAttributeException |
54
|
|
|
* if the supplied element is missing any of the mandatory attributes |
55
|
|
|
*/ |
56
|
|
|
public static function fromXML(DOMElement $xml): static |
57
|
|
|
{ |
58
|
|
|
Assert::same($xml->localName, static::getLocalName(), InvalidDOMElementException::class); |
59
|
|
|
Assert::same($xml->namespaceURI, static::getNamespaceURI(), InvalidDOMElementException::class); |
60
|
|
|
|
61
|
|
|
$proxyTicket = ProxyTicket::getChildrenOfClass($xml); |
62
|
|
|
Assert::count( |
63
|
|
|
$proxyTicket, |
64
|
|
|
1, |
65
|
|
|
'Exactly one <cas:proxyTicket> must be specified.', |
66
|
|
|
MissingElementException::class, |
67
|
|
|
); |
68
|
|
|
|
69
|
|
|
return new static(array_pop($proxyTicket)); |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
|
73
|
|
|
/** |
74
|
|
|
* Convert this ProxySuccess to XML. |
75
|
|
|
* |
76
|
|
|
* @param \DOMElement|null $parent The element we should append to. |
77
|
|
|
* @return \DOMElement This ProxySuccess-element. |
78
|
|
|
*/ |
79
|
|
|
public function toXML(?DOMElement $parent = null): DOMElement |
80
|
|
|
{ |
81
|
|
|
$e = $this->instantiateParentElement($parent); |
82
|
|
|
|
83
|
|
|
$this->getProxyTicket()->toXML($e); |
84
|
|
|
|
85
|
|
|
return $e; |
86
|
|
|
} |
87
|
|
|
} |
88
|
|
|
|