|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace GoetasWebservices\SoapServices\SoapClient\WssWsSecurity; |
|
4
|
|
|
|
|
5
|
|
|
use ass\XmlSecurity\Key as XmlSecurityKey; |
|
6
|
|
|
|
|
7
|
|
|
class SecurityKeyPair |
|
8
|
|
|
{ |
|
9
|
|
|
/** |
|
10
|
|
|
* Private key. |
|
11
|
|
|
* |
|
12
|
|
|
* @var \ass\XmlSecurity\Key |
|
13
|
|
|
*/ |
|
14
|
|
|
private $privateKey = null; |
|
15
|
|
|
|
|
16
|
|
|
/** |
|
17
|
|
|
* Public key. |
|
18
|
|
|
* |
|
19
|
|
|
* @var \ass\XmlSecurity\Key |
|
20
|
|
|
*/ |
|
21
|
|
|
private $publicKey = null; |
|
22
|
|
|
|
|
23
|
|
|
/** |
|
24
|
|
|
* Add private key. |
|
25
|
|
|
* |
|
26
|
|
|
* @param string $encryptionType Encryption type |
|
27
|
|
|
* @param string $key Private key |
|
28
|
|
|
* @param boolean $keyIsFile Given key parameter is path to key file |
|
29
|
|
|
* @param string $passphrase Passphrase for key |
|
30
|
|
|
* |
|
31
|
|
|
* @return void |
|
32
|
|
|
*/ |
|
33
|
|
|
public function setPrivateKey($encryptionType, $key = null, $keyIsFile = true, $passphrase = null) |
|
34
|
|
|
{ |
|
35
|
|
|
$this->privateKey = XmlSecurityKey::factory($encryptionType, $key, $keyIsFile, XmlSecurityKey::TYPE_PRIVATE, $passphrase); |
|
36
|
|
|
} |
|
37
|
|
|
|
|
38
|
|
|
/** |
|
39
|
|
|
* Add public key. |
|
40
|
|
|
* |
|
41
|
|
|
* @param string $encryptionType Encryption type |
|
42
|
|
|
* @param string $key Public key |
|
43
|
|
|
* @param boolean $keyIsFile Given key parameter is path to key file |
|
44
|
|
|
* |
|
45
|
|
|
* @return void |
|
46
|
|
|
*/ |
|
47
|
|
|
public function setPublicKey($encryptionType, $key = null, $keyIsFile = true) |
|
48
|
|
|
{ |
|
49
|
|
|
$this->publicKey = XmlSecurityKey::factory($encryptionType, $key, $keyIsFile, XmlSecurityKey::TYPE_PUBLIC); |
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
|
|
/** |
|
53
|
|
|
* Get private key. |
|
54
|
|
|
* |
|
55
|
|
|
* @return \ass\XmlSecurity\Key |
|
56
|
|
|
*/ |
|
57
|
|
|
public function getPrivateKey() |
|
58
|
|
|
{ |
|
59
|
|
|
return $this->privateKey; |
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
|
|
/** |
|
63
|
|
|
* Get public key. |
|
64
|
|
|
* |
|
65
|
|
|
* @return \ass\XmlSecurity\Key |
|
66
|
|
|
*/ |
|
67
|
|
|
public function getPublicKey() |
|
68
|
|
|
{ |
|
69
|
|
|
return $this->publicKey; |
|
70
|
|
|
} |
|
71
|
|
|
|
|
72
|
|
|
/** |
|
73
|
|
|
* Has private and public key? |
|
74
|
|
|
* |
|
75
|
|
|
* @return boolean |
|
76
|
|
|
*/ |
|
77
|
|
|
public function hasKeys() |
|
78
|
|
|
{ |
|
79
|
|
|
return null !== $this->privateKey && null !== $this->publicKey; |
|
80
|
|
|
} |
|
81
|
|
|
|
|
82
|
|
|
/** |
|
83
|
|
|
* Has private key? |
|
84
|
|
|
* |
|
85
|
|
|
* @return boolean |
|
86
|
|
|
*/ |
|
87
|
|
|
public function hasPrivateKey() |
|
88
|
|
|
{ |
|
89
|
|
|
return null !== $this->privateKey; |
|
90
|
|
|
} |
|
91
|
|
|
|
|
92
|
|
|
/** |
|
93
|
|
|
* Has public key? |
|
94
|
|
|
* |
|
95
|
|
|
* @return boolean |
|
96
|
|
|
*/ |
|
97
|
|
|
public function hasPublicKey() |
|
98
|
|
|
{ |
|
99
|
|
|
return null !== $this->publicKey; |
|
100
|
|
|
} |
|
101
|
|
|
} |
|
102
|
|
|
|