From ce495d15b0a6d8cea0604ae17daa301cb5f6d357 Mon Sep 17 00:00:00 2001 From: Ewout de Graaf Date: Fri, 27 Oct 2017 09:46:28 +0200 Subject: [PATCH] Added authInfo-1.1, domain-ext-2.1 and fee-0.9 extensions to EPP --- Examples/transferdomain.php | 9 +- .../eppRequests/euridEppInfoDomainRequest.php | 36 +++++++ .../euridEppInfoDomainResponse.php | 93 +++++++++++++++++++ .../eppExtensions/authInfo-1.1/includes.php | 8 ++ .../euridEppTransferDomainRequest.php | 53 +++++++++++ .../eppExtensions/domain-ext-2.1/includes.php | 6 ++ .../eppRequests/feeEppCheckDomainRequest.php | 32 +++++++ .../feeEppCheckDomainResponse.php | 23 +++++ .../EPP/eppExtensions/fee-0.9/includes.php | 7 ++ Protocols/EPP/eppRequests/eppRequest.php | 19 +++- .../euridEppConnection/eppConnection.php | 6 +- 11 files changed, 288 insertions(+), 4 deletions(-) create mode 100644 Protocols/EPP/eppExtensions/authInfo-1.1/eppRequests/euridEppInfoDomainRequest.php create mode 100644 Protocols/EPP/eppExtensions/authInfo-1.1/eppResponses/euridEppInfoDomainResponse.php create mode 100644 Protocols/EPP/eppExtensions/authInfo-1.1/includes.php create mode 100644 Protocols/EPP/eppExtensions/domain-ext-2.1/eppRequests/euridEppTransferDomainRequest.php create mode 100644 Protocols/EPP/eppExtensions/domain-ext-2.1/includes.php create mode 100644 Protocols/EPP/eppExtensions/fee-0.9/eppRequests/feeEppCheckDomainRequest.php create mode 100644 Protocols/EPP/eppExtensions/fee-0.9/eppResponses/feeEppCheckDomainResponse.php create mode 100644 Protocols/EPP/eppExtensions/fee-0.9/includes.php diff --git a/Examples/transferdomain.php b/Examples/transferdomain.php index c0982f6d..190c8104 100644 --- a/Examples/transferdomain.php +++ b/Examples/transferdomain.php @@ -41,7 +41,14 @@ function transferdomain($conn, $domainname, $authcode) { try { $domain = new eppDomain($domainname); $domain->setAuthorisationCode($authcode); - $transfer = new eppTransferRequest(eppTransferRequest::OPERATION_REQUEST,$domain); + $domain->setRegistrant(new \Metaregistrar\EPP\eppContactHandle('registrant handle')); + $domain->addContact(new \Metaregistrar\EPP\eppContactHandle('admin handle', \Metaregistrar\EPP\eppContactHandle::CONTACT_TYPE_ADMIN)); + $domain->addContact(new \Metaregistrar\EPP\eppContactHandle('tech handle', \Metaregistrar\EPP\eppContactHandle::CONTACT_TYPE_TECH)); + $domain->addContact(new \Metaregistrar\EPP\eppContactHandle('billing handle', \Metaregistrar\EPP\eppContactHandle::CONTACT_TYPE_BILLING)); + $domain->addHost(new \Metaregistrar\EPP\eppHost('ns1.yourdomainprovider.net')); + $domain->addHost(new \Metaregistrar\EPP\eppHost('ns2.yourdomainprovider.net')); + $domain->addHost(new \Metaregistrar\EPP\eppHost('ns3.yourdomainprovider.net')); + $transfer = new \Metaregistrar\EPP\metaregEppTransferExtendedRequest(eppTransferRequest::OPERATION_REQUEST,$domain); if ($response = $conn->request($transfer)) { /* @var $response Metaregistrar\EPP\eppTransferResponse */ echo $response->getDomainName()," transfer request was succesful\n"; diff --git a/Protocols/EPP/eppExtensions/authInfo-1.1/eppRequests/euridEppInfoDomainRequest.php b/Protocols/EPP/eppExtensions/authInfo-1.1/eppRequests/euridEppInfoDomainRequest.php new file mode 100644 index 00000000..b6db1c63 --- /dev/null +++ b/Protocols/EPP/eppExtensions/authInfo-1.1/eppRequests/euridEppInfoDomainRequest.php @@ -0,0 +1,36 @@ + + + + + domain-0007.eu + + + + + + + + + + + +*/ +class euridEppInfoDomainRequest extends eppInfoDomainRequest { + function __construct($infodomain, $hosts = null) { + parent::__construct($infodomain, $hosts); + $this->addEURIDExtension(); + $this->addSessionId(); + } + + + public function addEURIDExtension() { + $authext = $this->createElement('authInfo:info'); + $authext->setAttribute('xmlns:authInfo', 'http://www.eurid.eu/xml/epp/authInfo-1.1'); + $authext->appendChild($this->createElement('authInfo:request')); + $this->getExtension()->appendChild($authext); + } + +} \ No newline at end of file diff --git a/Protocols/EPP/eppExtensions/authInfo-1.1/eppResponses/euridEppInfoDomainResponse.php b/Protocols/EPP/eppExtensions/authInfo-1.1/eppResponses/euridEppInfoDomainResponse.php new file mode 100644 index 00000000..e75a5c8c --- /dev/null +++ b/Protocols/EPP/eppExtensions/authInfo-1.1/eppResponses/euridEppInfoDomainResponse.php @@ -0,0 +1,93 @@ +xPath(); + $cont = null; + $result = $xpath->query('/epp:epp/epp:response/epp:resData/domain:infData/domain:contact'); + foreach ($result as $contact) { + /* @var $contact \DOMElement */ + $contacttype = $contact->getAttribute('type'); + if ($contacttype) { + $cont[] = new eppContactHandle($contact->nodeValue, $contacttype); + } + } + $result = $xpath->query('/epp:epp/epp:response/epp:extension/domain-ext:infData/domain-ext:contact'); + foreach ($result as $contact) { + /* @var $contact \DOMElement */ + $contacttype = $contact->getAttribute('type'); + if ($contacttype) { + // EURID specific + if ($contacttype == 'onsite') { + $contacttype = 'admin'; + } + $cont[] = new eppContactHandle($contact->nodeValue, $contacttype); + } + } + return $cont; + } + + /** + * Get the date until the auth code is valie + * @return null|string + */ + public function getAuthorisationCodeValidDate() { + $xpath = $this->xPath(); + $result = $xpath->query('/epp:epp/epp:response/epp:extension/authInfo:infData/authInfo:validUntil'); + if ($result->length > 0) { + return $result->item(0)->nodeValue; + } else { + return null; + } + } + + + /** + * + * @return boolean + */ + public function getQuarantined() { + $xpath = $this->xPath(); + $result = $xpath->query('/epp:epp/epp:response/epp:extension/eurid:ext/eurid:infData/eurid:domain/eurid:quarantined'); + if ($result->length > 0) { + if ($result->item(0)->nodeValue == 'true') { + return true; + } else { + return false; + } + } else { + return null; + } + } + + + /** + * + * @return boolean + */ + public function getOnHold() { + $xpath = $this->xPath(); + $result = $xpath->query('/epp:epp/epp:response/epp:extension/eurid:ext/eurid:infData/eurid:domain/eurid:onhold'); + if ($result->length > 0) { + if ($result->item(0)->nodeValue == 'true') { + return true; + } else { + return false; + } + } else { + return null; + } + } +} + diff --git a/Protocols/EPP/eppExtensions/authInfo-1.1/includes.php b/Protocols/EPP/eppExtensions/authInfo-1.1/includes.php new file mode 100644 index 00000000..fccd64b3 --- /dev/null +++ b/Protocols/EPP/eppExtensions/authInfo-1.1/includes.php @@ -0,0 +1,8 @@ +addExtension('authInfo', 'http://www.eurid.eu/xml/epp/authInfo-1.1'); +# +# For use with the EURID connection +# +include_once(dirname(__FILE__) . '/eppRequests/euridEppInfoDomainRequest.php'); +include_once(dirname(__FILE__) . '/eppResponses/euridEppInfoDomainResponse.php'); +$this->addCommandResponse('Metaregistrar\EPP\euridEppInfoDomainRequest', 'Metaregistrar\EPP\euridEppInfoDomainResponse'); diff --git a/Protocols/EPP/eppExtensions/domain-ext-2.1/eppRequests/euridEppTransferDomainRequest.php b/Protocols/EPP/eppExtensions/domain-ext-2.1/eppRequests/euridEppTransferDomainRequest.php new file mode 100644 index 00000000..3ad57a3a --- /dev/null +++ b/Protocols/EPP/eppExtensions/domain-ext-2.1/eppRequests/euridEppTransferDomainRequest.php @@ -0,0 +1,53 @@ + + + + + + some-domain-name + + XXXX-2N5J-L7AU-MV2L + + + + + + + c10 + c159 + + + + + + */ + + +class euridEppTransferDomainRequest extends eppTransferRequest { + function __construct($operation, eppDomain $domain) { + parent::__construct($operation,$domain); + $this->addContacts($domain); + parent::addSessionId(); + + } + + private function addContacts(eppDomain $domain) { + $transfer = $this->createElement('domain-ext:transfer'); + $this->setNamespace('xmlns:domain','urn:ietf:params:xml:ns:domain-1.0',$transfer); + $this->setNamespace('xmlns:domain-ext','http://www.eurid.eu/xml/epp/domain-ext-2.1',$transfer); + $request = $this->createElement('domain-ext:request'); + foreach ($domain->getContacts() as $contact) { + /* @var $contact \Metaregistrar\EPP\eppContactHandle */ + $c = $this->createElement('domain-ext:contact',$contact->getContactHandle()); + $c->setAttribute('type',$contact->getContactType()); + $request->appendChild($c); + } + $transfer->appendChild($request); + $this->getExtension()->appendChild($transfer); + } + + +} \ No newline at end of file diff --git a/Protocols/EPP/eppExtensions/domain-ext-2.1/includes.php b/Protocols/EPP/eppExtensions/domain-ext-2.1/includes.php new file mode 100644 index 00000000..662574a1 --- /dev/null +++ b/Protocols/EPP/eppExtensions/domain-ext-2.1/includes.php @@ -0,0 +1,6 @@ +addExtension('domain-ext', 'http://www.eurid.eu/xml/epp/domain-ext-2.1'); + +include_once(dirname(__FILE__) . '/eppRequests/euridEppTransferDomainRequest.php'); + +$this->addCommandResponse('Metaregistrar\EPP\euridEppTransferDomainRequest', 'Metaregistrar\EPP\eppTransferResponse'); \ No newline at end of file diff --git a/Protocols/EPP/eppExtensions/fee-0.9/eppRequests/feeEppCheckDomainRequest.php b/Protocols/EPP/eppExtensions/fee-0.9/eppRequests/feeEppCheckDomainRequest.php new file mode 100644 index 00000000..1f38bccc --- /dev/null +++ b/Protocols/EPP/eppExtensions/fee-0.9/eppRequests/feeEppCheckDomainRequest.php @@ -0,0 +1,32 @@ +addFee(null,null); + $this->addSessionId(); + } + + private function addFee(eppDomain $domain, $command, $phase=null, $period = null) { + $extension = $this->getExtension(); + $check = $this->createElement('fee:check'); + $check->setAttribute('xmlns:fee','urn:ietf:params:xml:ns:fee-0.9'); + $fee = $this->createElement('fee:object'); + $fee->setAttribute('objURI','urn:ietf:params:xml:ns:domain-1.0'); + $objid = $this->createElement('fee:objID',$domain->getDomainname()); + $objid->setAttribute('element','name'); + $fee->appendChild($objid); + $command = $this->createElement('fee:command',$command); + if ($phase) { + $command->setAttribute('phase',$phase); + $fee->appendChild($phase); + } + if ($period) { + $per = $this->createElement('fee:period',$period); + $per->setAttribute('unit','y'); + } + $extension->appendChild($check); + return; + } +} \ No newline at end of file diff --git a/Protocols/EPP/eppExtensions/fee-0.9/eppResponses/feeEppCheckDomainResponse.php b/Protocols/EPP/eppExtensions/fee-0.9/eppResponses/feeEppCheckDomainResponse.php new file mode 100644 index 00000000..f8de1508 --- /dev/null +++ b/Protocols/EPP/eppExtensions/fee-0.9/eppResponses/feeEppCheckDomainResponse.php @@ -0,0 +1,23 @@ +xPath(); + $result = $xpath->query('/epp:epp/epp:response/epp:extension/fee:chkData/fee:cd/*'); + if ($result->length > 0) { + if ($result->item(0)->nodeValue == 'true') { + return true; + } else { + return false; + } + } else { + return null; + } + } + +} \ No newline at end of file diff --git a/Protocols/EPP/eppExtensions/fee-0.9/includes.php b/Protocols/EPP/eppExtensions/fee-0.9/includes.php new file mode 100644 index 00000000..afeb9af9 --- /dev/null +++ b/Protocols/EPP/eppExtensions/fee-0.9/includes.php @@ -0,0 +1,7 @@ +rootNamespaces()) { + $this->getEpp()->setAttribute('xmlns:'.$xmlns,$namespace); + } else { + if ($object) { + $object->setAttribute('xmlns:'.$xmlns,$namespace); + } + } + } + public function addSessionId() { # # Remove earlier session id's to make sure session id is at the end diff --git a/Registries/euridEppConnection/eppConnection.php b/Registries/euridEppConnection/eppConnection.php index 22a8500b..aee2c3cf 100644 --- a/Registries/euridEppConnection/eppConnection.php +++ b/Registries/euridEppConnection/eppConnection.php @@ -8,8 +8,10 @@ public function __construct($logging = false, $settingsfile = null) { //parent::enableDnssec(); parent::setServices(array('urn:ietf:params:xml:ns:domain-1.0' => 'domain', 'urn:ietf:params:xml:ns:contact-1.0' => 'contact')); //parent::addExtension('nsgroup','http://www.eurid.eu/xml/epp/nsgroup-1.1'); - parent::addService('http://www.eurid.eu/xml/epp/registrar-1.0', 'registrar'); - //parent::addExtension('authInfo','http://www.eurid.eu/xml/epp/authInfo-1.0'); + //parent::addService('http://www.eurid.eu/xml/epp/registrar-1.0', 'registrar'); + parent::addExtension('authInfo','http://www.eurid.eu/xml/epp/authInfo-1.1'); + parent::addExtension('domain-ext','http://www.eurid.eu/xml/epp/domain-ext-2.1'); + #parent::addCommandResponse('euridEppCreateNsgroupRequest', 'euridEppCreateNsgroupResponse'); #parent::addCommandResponse('euridEppCreateRequest', 'euridEppCreateResponse'); #parent::addCommandResponse('euridEppAuthcodeRequest', 'eppResponse');