1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace SimpleSAML\WSSecurity\XML\wsdl; |
6
|
|
|
|
7
|
|
|
use DOMElement; |
8
|
|
|
use SimpleSAML\Assert\Assert; |
9
|
|
|
use SimpleSAML\XML\Exception\SchemaViolationException; |
10
|
|
|
|
11
|
|
|
/** |
12
|
|
|
* Abstract class representing the tBindingOperation type. |
13
|
|
|
* |
14
|
|
|
* @package simplesamlphp/ws-security |
15
|
|
|
*/ |
16
|
|
|
abstract class AbstractBindingOperation extends AbstractExtensibleDocumented |
17
|
|
|
{ |
18
|
|
|
/** |
19
|
|
|
* Initialize a wsdl:tBindingOperation |
20
|
|
|
* |
21
|
|
|
* @param string $name |
22
|
|
|
* @param \SimpleSAML\WSSecurity\XML\wsdl\BindingOperationInput|null $input |
23
|
|
|
* @param \SimpleSAML\WSSecurity\XML\wsdl\BindingOperationOutput|null $output |
24
|
|
|
* @param \SimpleSAML\WSSecurity\XML\wsdl\BindingOperationFault[] $fault |
25
|
|
|
* @param \SimpleSAML\XML\Chunk[] $elements |
26
|
|
|
*/ |
27
|
|
|
public function __construct( |
28
|
|
|
protected string $name, |
29
|
|
|
protected ?BindingOperationInput $input = null, |
30
|
|
|
protected ?BindingOperationOutput $output = null, |
31
|
|
|
protected array $fault = [], |
32
|
|
|
array $elements = [], |
33
|
|
|
) { |
34
|
|
|
Assert::validNCName($name, SchemaViolationException::class); |
35
|
|
|
Assert::allIsInstanceOf($fault, BindingOperationFault::class, SchemaViolationException::class); |
36
|
|
|
|
37
|
|
|
parent::__construct($elements); |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* Collect the value of the name-property. |
43
|
|
|
* |
44
|
|
|
* @return string |
45
|
|
|
*/ |
46
|
|
|
public function getName(): string |
47
|
|
|
{ |
48
|
|
|
return $this->name; |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* Collect the value of the input-property. |
54
|
|
|
* |
55
|
|
|
* @return \SimpleSAML\WSSecurity\XML\wsdl\BindingOperationInput|null |
56
|
|
|
*/ |
57
|
|
|
public function getInput(): ?BindingOperationInput |
58
|
|
|
{ |
59
|
|
|
return $this->input; |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
|
63
|
|
|
/** |
64
|
|
|
* Collect the value of the output-property. |
65
|
|
|
* |
66
|
|
|
* @return \SimpleSAML\WSSecurity\XML\wsdl\BindingOperationOutput|null |
67
|
|
|
*/ |
68
|
|
|
public function getOutput(): ?BindingOperationOutput |
69
|
|
|
{ |
70
|
|
|
return $this->output; |
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
|
74
|
|
|
/** |
75
|
|
|
* Collect the value of the fault-property. |
76
|
|
|
* |
77
|
|
|
* @return \SimpleSAML\WSSecurity\XML\wsdl\BindingOperationFault[] |
78
|
|
|
*/ |
79
|
|
|
public function getFault(): array |
80
|
|
|
{ |
81
|
|
|
return $this->fault; |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
|
85
|
|
|
/** |
86
|
|
|
* Test if an object, at the state it's in, would produce an empty XML-element |
87
|
|
|
* |
88
|
|
|
* @return bool |
89
|
|
|
*/ |
90
|
|
|
public function isEmptyElement(): bool |
91
|
|
|
{ |
92
|
|
|
// Upstream abstract elements can be empty, but this one cannot |
93
|
|
|
return false; |
94
|
|
|
} |
95
|
|
|
|
96
|
|
|
|
97
|
|
|
/** |
98
|
|
|
* Convert this tBindingOperation to XML. |
99
|
|
|
* |
100
|
|
|
* @param \DOMElement|null $parent The element we are converting to XML. |
101
|
|
|
* @return \DOMElement The XML element after adding the data corresponding to this tBindingOperation. |
102
|
|
|
*/ |
103
|
|
|
public function toXML(DOMElement $parent = null): DOMElement |
104
|
|
|
{ |
105
|
|
|
$e = parent::toXML($parent); |
106
|
|
|
|
107
|
|
|
$e->setAttribute('name', $this->getName()); |
108
|
|
|
|
109
|
|
|
$this->getInput()?->toXML($e); |
110
|
|
|
$this->getOutput()?->toXML($e); |
111
|
|
|
|
112
|
|
|
foreach ($this->getFault() as $fault) { |
113
|
|
|
$fault->toXML($e); |
114
|
|
|
} |
115
|
|
|
|
116
|
|
|
return $e; |
117
|
|
|
} |
118
|
|
|
} |
119
|
|
|
|