Skip to content

Commit 676c7db

Browse files
Merge pull request #412 from hamrak/master
Add SK-NIC Support (.sk, .org.sk).
2 parents ca29622 + 6215d35 commit 676c7db

File tree

15 files changed

+1304
-17
lines changed

15 files changed

+1304
-17
lines changed

Protocols/EPP/eppConnection.php

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,12 @@ class eppConnection {
130130
*/
131131
protected $local_cert_path = null;
132132

133+
/**
134+
* Path to private key file
135+
* @var string
136+
*/
137+
protected $local_pk_path = null;
138+
133139
/**
134140
* Password of certificate file
135141
* @var string
@@ -301,18 +307,21 @@ public function disableDnssec() {
301307
* @param string $certificatepath
302308
* @param string | null $certificatepassword
303309
* @param bool $selfsigned
310+
* @param string | null $certificatekeypath
304311
*
305312
*/
306-
public function enableCertification($certificatepath, $certificatepassword, $selfsigned = false) {
313+
public function enableCertification($certificatepath, $certificatepassword, $selfsigned = false, $certificatekeypath = null) {
307314
$this->local_cert_path = $certificatepath;
308315
$this->local_cert_pwd = $certificatepassword;
309316
$this->allow_self_signed = $selfsigned;
317+
$this->local_pk_path = $certificatekeypath;
310318
}
311319

312320
public function disableCertification() {
313321
$this->local_cert_path = null;
314322
$this->local_cert_pwd = null;
315323
$this->allow_self_signed = null;
324+
$this->local_pk_path = null;
316325
}
317326

318327

@@ -352,6 +361,9 @@ public function connect($hostname = null, $port = null) {
352361
stream_context_set_option($context, 'ssl', 'verify_peer_name', $this->verify_peer_name);
353362
if ($this->local_cert_path) {
354363
stream_context_set_option($context, 'ssl', 'local_cert', $this->local_cert_path);
364+
if (isset($this->local_pk_path) && (strlen($this->local_pk_path)>0)) {
365+
stream_context_set_option($context, 'ssl', 'local_pk', $this->local_pk_path);
366+
}
355367
if (isset($this->local_cert_pwd) && (strlen($this->local_cert_pwd)>0)) {
356368
stream_context_set_option($context, 'ssl', 'passphrase', $this->local_cert_pwd);
357369
}
@@ -379,11 +391,11 @@ public function connect($hostname = null, $port = null) {
379391
$this->read();
380392
}
381393
return $this->connected;
382-
} else {
383-
$this->writeLog("Connection could not be opened: $errno $errstr","ERROR");
384-
return false;
385394
}
386395

396+
$this->writeLog("Connection could not be opened: $errno $errstr","ERROR");
397+
return false;
398+
387399
}
388400

389401
/**
@@ -1148,14 +1160,6 @@ public function setConnectionDetails($result) {
11481160
$this->enableLogging();
11491161
}
11501162
}
1151-
1152-
if (array_key_exists('certificatefile',$result) && array_key_exists('certificatepassword',$result)) {
1153-
// Enter the path to your certificate and the password here
1154-
$this->enableCertification($result['certificatefile'], $result['certificatepassword']);
1155-
} elseif (array_key_exists('certificatefile',$result)) {
1156-
// Enter the path to your certificate without password
1157-
$this->enableCertification($result['certificatefile'], null);
1158-
}
11591163
if (array_key_exists('verifypeer',$result)) {
11601164
if (($result['verifypeer']=='true') || ($result['verifypeer']=='yes') || ($result['verifypeer']=='1')) {
11611165
$this->verify_peer = true;
@@ -1177,6 +1181,14 @@ public function setConnectionDetails($result) {
11771181
$this->allow_self_signed = false;
11781182
}
11791183
}
1184+
if (array_key_exists('certificatefile',$result)) {
1185+
$this->enableCertification(
1186+
$result['certificatefile'],
1187+
array_key_exists('certificatepassword',$result) ? $result['certificatepassword'] : null,
1188+
$this->allow_self_signed,
1189+
array_key_exists('certificatekey',$result) ? $result['certificatekey'] : null
1190+
);
1191+
}
11801192

11811193
$this->settingsloaded = true;
11821194
return true;

Protocols/EPP/eppException.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class eppException extends \Exception {
2929
* @param string $command
3030
* @param \Metaregistrar\EPP\eppResponse|null $response
3131
*/
32-
public function __construct($message = "", $code = 0, \Exception $previous = null, $reason = null, $command = null, $response = null) {
32+
public function __construct($message = "", $code = 0, $previous = null, $reason = null, $command = null, $response = null) {
3333
$this->reason = $reason;
3434
$trace = $this->getTrace();
3535
$this->class = null;
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
<?php
2+
namespace Metaregistrar\EPP;
3+
4+
/**
5+
* Class AuxContactCreateDomainRequest
6+
* @package Metaregistrar\EPP
7+
*
8+
* <extension>
9+
* <auxcontact:create xmlns:auxcontact="urn:ietf:params:xml:ns:auxcontact-0.1">
10+
* <auxcontact:contact type="abuse">sh8013</auxcontact:contact>
11+
* <auxcontact:contact type="dns-operator">ClientZ</auxcontact:contact>
12+
* </auxcontact:create>
13+
* </extension>
14+
*/
15+
class AuxContactCreateDomainRequest extends eppCreateDomainRequest
16+
{
17+
/**
18+
* @var array Auxiliary contacts to include in domain creation
19+
*/
20+
private $auxContacts = [];
21+
22+
/**
23+
* AuxContactCreateDomainRequest constructor
24+
*
25+
* @param eppDomain $createinfo Domain object to create
26+
* @param boolean $forcehostattr Force host attributes
27+
* @param boolean $namespacesinroot Namespaces in root
28+
* @param boolean $usecdata Use CDATA
29+
* @param array $auxContacts Auxiliary contacts to add [['type' => 'type', 'id' => 'id'], ...]
30+
*/
31+
function __construct($createinfo, $forcehostattr = false, $namespacesinroot = true, $usecdata = true, $auxContacts = [])
32+
{
33+
parent::__construct($createinfo, $forcehostattr, $namespacesinroot, $usecdata);
34+
35+
// Store contacts
36+
$this->auxContacts = $auxContacts;
37+
38+
// Add the extension to the request
39+
$this->addAuxContactExtension();
40+
41+
// Add session ID
42+
$this->addSessionId();
43+
}
44+
45+
/**
46+
* Add auxiliary contact to the request
47+
*
48+
* @param string $type Contact type (e.g., 'abuse', 'dns-operator')
49+
* @param string $contactId Contact ID
50+
* @return $this
51+
*/
52+
public function addAuxContact($type, $contactId)
53+
{
54+
$this->auxContacts[] = [
55+
'type' => $type,
56+
'id' => $contactId
57+
];
58+
59+
// Refresh extension
60+
$this->addAuxContactExtension();
61+
62+
return $this;
63+
}
64+
65+
/**
66+
* Add the auxiliary contact extension to the request
67+
*/
68+
private function addAuxContactExtension()
69+
{
70+
// Skip if no contacts to add
71+
if (empty($this->auxContacts)) {
72+
return;
73+
}
74+
75+
// Create the auxcontact:create an element
76+
$createElement = $this->createElement('auxcontact:create');
77+
$this->setNamespace('auxcontact', 'urn:ietf:params:xml:ns:auxcontact-0.1', $createElement);
78+
79+
// Add contacts
80+
foreach ($this->auxContacts as $contact) {
81+
$contactElement = $this->createElement('auxcontact:contact', htmlspecialchars($contact['id']));
82+
$contactElement->setAttribute('type', htmlspecialchars($contact['type']));
83+
$createElement->appendChild($contactElement);
84+
}
85+
86+
// Add to the extension element
87+
$this->getExtension()->appendChild($createElement);
88+
}
89+
}
Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
<?php
2+
namespace Metaregistrar\EPP;
3+
4+
/**
5+
* Class AuxContactUpdateDomainRequest
6+
* @package Metaregistrar\EPP
7+
*
8+
* <extension>
9+
* <auxcontact:update xmlns:auxcontact="urn:ietf:params:xml:ns:auxcontact-0.1">
10+
* <auxcontact:rem>
11+
* <auxcontact:contact type="dns-operator">ClientZ</auxcontact:contact>
12+
* </auxcontact:rem>
13+
* <auxcontact:add>
14+
* <auxcontact:contact type="dns-operator">ClientXYZ</auxcontact:contact>
15+
* </auxcontact:add>
16+
* </auxcontact:update>
17+
* </extension>
18+
*/
19+
class AuxContactUpdateDomainRequest extends eppUpdateDomainRequest
20+
{
21+
/**
22+
* @var array Auxiliary contacts to add
23+
*/
24+
private $addAuxContacts = [];
25+
26+
/**
27+
* @var array Auxiliary contacts to remove
28+
*/
29+
private $removeAuxContacts = [];
30+
31+
/**
32+
* AuxContactUpdateDomainRequest constructor
33+
*
34+
* @param eppDomain $objectname Domain object to update
35+
* @param eppDomain $addinfo Elements to add
36+
* @param eppDomain $removeinfo Elements to remove
37+
* @param eppDomain $updateinfo Elements to update
38+
* @param boolean $forcehostattr Force host attributes
39+
* @param boolean $namespacesinroot Namespaces in root
40+
* @param boolean $usecdata Use CDATA
41+
* @param array $addAuxContacts Auxiliary contacts to add [['type' => 'type', 'id' => 'id'], ...]
42+
* @param array $removeAuxContacts Auxiliary contacts to remove [['type' => 'type', 'id' => 'id'], ...]
43+
*/
44+
function __construct($objectname, $addinfo = null, $removeinfo = null, $updateinfo = null, $forcehostattr = false, $namespacesinroot = true, $usecdata = true, $addAuxContacts = [], $removeAuxContacts = [])
45+
{
46+
parent::__construct($objectname, $addinfo, $removeinfo, $updateinfo, $forcehostattr, $namespacesinroot, $usecdata);
47+
48+
// Store contacts to add and remove
49+
$this->addAuxContacts = $addAuxContacts;
50+
$this->removeAuxContacts = $removeAuxContacts;
51+
52+
// Add the extension to the request
53+
$this->addAuxContactExtension();
54+
55+
// Add session ID
56+
$this->addSessionId();
57+
}
58+
59+
/**
60+
* Add auxiliary contact to add list
61+
*
62+
* @param string $type Contact type (e.g., 'abuse', 'dns-operator')
63+
* @param string $contactId Contact ID
64+
* @return $this
65+
*/
66+
public function addAuxContact($type, $contactId)
67+
{
68+
$this->addAuxContacts[] = [
69+
'type' => $type,
70+
'id' => $contactId
71+
];
72+
73+
// Refresh extension
74+
$this->addAuxContactExtension();
75+
76+
return $this;
77+
}
78+
79+
/**
80+
* Add auxiliary contact to remove list
81+
*
82+
* @param string $type Contact type (e.g., 'abuse', 'dns-operator')
83+
* @param string $contactId Contact ID
84+
* @return $this
85+
*/
86+
public function removeAuxContact($type, $contactId)
87+
{
88+
$this->removeAuxContacts[] = [
89+
'type' => $type,
90+
'id' => $contactId
91+
];
92+
93+
// Refresh extension
94+
$this->addAuxContactExtension();
95+
96+
return $this;
97+
}
98+
99+
/**
100+
* Add the auxiliary contact extension to the request
101+
*/
102+
private function addAuxContactExtension()
103+
{
104+
// Skip if no contacts to add or remove
105+
if (empty($this->addAuxContacts) && empty($this->removeAuxContacts)) {
106+
return;
107+
}
108+
109+
// Create the auxcontact:update element
110+
$updateElement = $this->createElement('auxcontact:update');
111+
$this->setNamespace('auxcontact', 'urn:ietf:params:xml:ns:auxcontact-0.1', $updateElement);
112+
113+
// Add contacts to remove
114+
if (!empty($this->removeAuxContacts)) {
115+
$remElement = $this->createElement('auxcontact:rem');
116+
117+
foreach ($this->removeAuxContacts as $contact) {
118+
$contactElement = $this->createElement('auxcontact:contact', htmlspecialchars($contact['id']));
119+
$contactElement->setAttribute('type', htmlspecialchars($contact['type']));
120+
$remElement->appendChild($contactElement);
121+
}
122+
123+
$updateElement->appendChild($remElement);
124+
}
125+
126+
// Add contacts to add
127+
if (!empty($this->addAuxContacts)) {
128+
$addElement = $this->createElement('auxcontact:add');
129+
130+
foreach ($this->addAuxContacts as $contact) {
131+
$contactElement = $this->createElement('auxcontact:contact', htmlspecialchars($contact['id']));
132+
$contactElement->setAttribute('type', htmlspecialchars($contact['type']));
133+
$addElement->appendChild($contactElement);
134+
}
135+
136+
$updateElement->appendChild($addElement);
137+
}
138+
139+
// Add to the extension element
140+
$this->getExtension()->appendChild($updateElement);
141+
}
142+
}

0 commit comments

Comments
 (0)