|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace WsdlToPhp\WsSecurity; |
|
6
|
|
|
|
|
7
|
|
|
use DOMElement; |
|
8
|
|
|
|
|
9
|
|
|
class UsernameToken extends Element |
|
10
|
|
|
{ |
|
11
|
|
|
public const NAME = 'UsernameToken'; |
|
12
|
|
|
|
|
13
|
|
|
public const ATTRIBUTE_ID = 'Id'; |
|
14
|
|
|
|
|
15
|
|
|
protected ?Username $username = null; |
|
16
|
|
|
|
|
17
|
|
|
protected ?Password $password = null; |
|
18
|
|
|
|
|
19
|
|
|
protected ?Created $created = null; |
|
20
|
|
|
|
|
21
|
|
|
protected ?Nonce $nonce = null; |
|
22
|
|
|
|
|
23
|
18 |
|
public function __construct(?string $id = null, string $namespace = self::NS_WSSE) |
|
24
|
|
|
{ |
|
25
|
18 |
|
parent::__construct(self::NAME, $namespace, null, empty($id) ? [] : [ |
|
26
|
18 |
|
sprintf('%s:%s', parent::NS_WSU_NAME, self::ATTRIBUTE_ID) => $id, |
|
27
|
|
|
]); |
|
28
|
|
|
} |
|
29
|
|
|
|
|
30
|
|
|
/** |
|
31
|
|
|
* Overrides method in order to add username, password and created values if they are set. |
|
32
|
|
|
* |
|
33
|
|
|
* @param bool $asDomElement returns elements as a DOMElement or as a string |
|
34
|
|
|
* |
|
35
|
|
|
* @return DOMElement|false|string |
|
36
|
|
|
*/ |
|
37
|
18 |
|
protected function __toSend(bool $asDomElement = false) |
|
38
|
|
|
{ |
|
39
|
18 |
|
$this->setValue([ |
|
40
|
18 |
|
$this->getUsername(), |
|
41
|
18 |
|
$this->getPassword(), |
|
42
|
18 |
|
$this->getCreated(), |
|
43
|
18 |
|
$this->getNonce(), |
|
44
|
|
|
]); |
|
45
|
|
|
|
|
46
|
18 |
|
return parent::__toSend($asDomElement); |
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
18 |
|
public function getUsername(): ?Username |
|
50
|
|
|
{ |
|
51
|
18 |
|
return $this->username; |
|
52
|
|
|
} |
|
53
|
|
|
|
|
54
|
18 |
|
public function setUsername(Username $username): self |
|
55
|
|
|
{ |
|
56
|
18 |
|
$this->username = $username; |
|
57
|
|
|
|
|
58
|
18 |
|
return $this; |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
18 |
|
public function getPassword(): ?Password |
|
62
|
|
|
{ |
|
63
|
18 |
|
return $this->password; |
|
64
|
|
|
} |
|
65
|
|
|
|
|
66
|
18 |
|
public function setPassword(Password $password): self |
|
67
|
|
|
{ |
|
68
|
18 |
|
$this->password = $password; |
|
69
|
|
|
|
|
70
|
18 |
|
return $this; |
|
71
|
|
|
} |
|
72
|
|
|
|
|
73
|
18 |
|
public function getCreated(): ?Created |
|
74
|
|
|
{ |
|
75
|
18 |
|
return $this->created; |
|
76
|
|
|
} |
|
77
|
|
|
|
|
78
|
18 |
|
public function setCreated(Created $created): self |
|
79
|
|
|
{ |
|
80
|
18 |
|
$this->created = $created; |
|
81
|
|
|
|
|
82
|
18 |
|
return $this; |
|
83
|
|
|
} |
|
84
|
|
|
|
|
85
|
18 |
|
public function getNonce(): ?Nonce |
|
86
|
|
|
{ |
|
87
|
18 |
|
return $this->nonce; |
|
88
|
|
|
} |
|
89
|
|
|
|
|
90
|
16 |
|
public function setNonce(Nonce $nonce): self |
|
91
|
|
|
{ |
|
92
|
16 |
|
$this->nonce = $nonce; |
|
93
|
|
|
|
|
94
|
16 |
|
return $this; |
|
95
|
|
|
} |
|
96
|
|
|
} |
|
97
|
|
|
|