1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace SimpleSAML\CAS\XML; |
6
|
|
|
|
7
|
|
|
use DOMElement; |
8
|
|
|
use SimpleSAML\CAS\Assert\Assert; |
9
|
|
|
use SimpleSAML\CAS\Type\CodeValue; |
10
|
|
|
use SimpleSAML\XML\TypedTextContentTrait; |
11
|
|
|
use SimpleSAML\XMLSchema\Exception\InvalidDOMElementException; |
12
|
|
|
use SimpleSAML\XMLSchema\Type\StringValue; |
13
|
|
|
|
14
|
|
|
use function strval; |
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* Class for CAS proxyFailure |
18
|
|
|
* |
19
|
|
|
* @package simplesamlphp/cas |
20
|
|
|
*/ |
21
|
|
|
final class ProxyFailure extends AbstractResponse |
22
|
|
|
{ |
23
|
|
|
use TypedTextContentTrait; |
24
|
|
|
|
25
|
|
|
/** @var string */ |
26
|
|
|
public const TEXTCONTENT_TYPE = StringValue::class; |
27
|
|
|
|
28
|
|
|
/** @var string */ |
29
|
|
|
final public const LOCALNAME = 'proxyFailure'; |
30
|
|
|
|
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* Create a new instance of ProxyFailure |
34
|
|
|
* |
35
|
|
|
* @param \SimpleSAML\XMLSchema\Type\StringValue $content |
36
|
|
|
* @param \SimpleSAML\CAS\Type\CodeValue $code |
37
|
|
|
*/ |
38
|
|
|
final public function __construct( |
39
|
|
|
StringValue $content, |
40
|
|
|
protected CodeValue $code, |
41
|
|
|
) { |
42
|
|
|
$this->setContent($content); |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* Collect the value of the code-property |
48
|
|
|
* |
49
|
|
|
* @return \SimpleSAML\CAS\Type\CodeValue |
50
|
|
|
*/ |
51
|
|
|
public function getCode(): CodeValue |
52
|
|
|
{ |
53
|
|
|
return $this->code; |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* Initialize an ProxyFailure element. |
59
|
|
|
* |
60
|
|
|
* @param \DOMElement $xml The XML element we should load. |
61
|
|
|
* @return static |
62
|
|
|
* |
63
|
|
|
* @throws \SimpleSAML\XMLSchema\Exception\InvalidDOMElementException |
64
|
|
|
* if the qualified name of the supplied element is wrong |
65
|
|
|
* @throws \SimpleSAML\XMLSchema\Exception\MissingAttributeException |
66
|
|
|
* if the supplied element is missing any of the mandatory attributes |
67
|
|
|
*/ |
68
|
|
|
public static function fromXML(DOMElement $xml): static |
69
|
|
|
{ |
70
|
|
|
Assert::same($xml->localName, static::getLocalName(), InvalidDOMElementException::class); |
71
|
|
|
Assert::same($xml->namespaceURI, static::getNamespaceURI(), InvalidDOMElementException::class); |
72
|
|
|
|
73
|
|
|
return new static( |
74
|
|
|
StringValue::fromString($xml->textContent), |
75
|
|
|
self::getAttribute($xml, 'code', CodeValue::class), |
76
|
|
|
); |
77
|
|
|
} |
78
|
|
|
|
79
|
|
|
|
80
|
|
|
/** |
81
|
|
|
* Convert this ProxyFailure to XML. |
82
|
|
|
* |
83
|
|
|
* @param \DOMElement|null $parent The element we should append to. |
84
|
|
|
* @return \DOMElement This ProxyFailure-element. |
85
|
|
|
*/ |
86
|
|
|
public function toXML(?DOMElement $parent = null): DOMElement |
87
|
|
|
{ |
88
|
|
|
$e = $this->instantiateParentElement($parent); |
89
|
|
|
|
90
|
|
|
$e->textContent = strval($this->getContent()); |
91
|
|
|
$e->setAttribute('code', strval($this->getCode())); |
92
|
|
|
|
93
|
|
|
return $e; |
94
|
|
|
} |
95
|
|
|
} |
96
|
|
|
|