Skip to content

Commit

Permalink
Added authInfo-1.1, domain-ext-2.1 and fee-0.9 extensions to EPP
Browse files Browse the repository at this point in the history
  • Loading branch information
metaregistrar committed Oct 27, 2017
1 parent 97b2f93 commit ce495d1
Show file tree
Hide file tree
Showing 11 changed files with 288 additions and 4 deletions.
9 changes: 8 additions & 1 deletion Examples/transferdomain.php
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php
namespace Metaregistrar\EPP;
/*
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
<command>
<info>
<domain:info xmlns:domain="urn:ietf:params:xml:ns:domain-1.0">
<domain:name>domain-0007.eu</domain:name>
</domain:info>
</info>
<extension>
<authInfo:info xmlns:authInfo="http://www.eurid.eu/xml/epp/authInfo-1.0">
<authInfo:request/>
</authInfo:info>
</extension>
</command>
</epp>
*/
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);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
<?php
namespace Metaregistrar\EPP;

class euridEppInfoDomainResponse extends eppInfoDomainResponse {
function __construct() {
parent::__construct();
}


/**
* Return EURid specific contact type 'onsite', which is not EPP standard
*
* @return array eppContactHandles
*/
public function getDomainContacts() {
$xpath = $this->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;
}
}
}

8 changes: 8 additions & 0 deletions Protocols/EPP/eppExtensions/authInfo-1.1/includes.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php
$this->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');
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<?php
namespace Metaregistrar\EPP;

/*
<?xml version='1.0' encoding='UTF-8'?>
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
<command>
<transfer op="request">
<domain:transfer xmlns:domain='urn:ietf:params:xml:ns:domain-1.0'>
<domain:name>some-domain-name</domain:name>
<domain:authInfo>
<domain:pw>XXXX-2N5J-L7AU-MV2L</domain:pw>
</domain:authInfo>
</domain:transfer>
</transfer>
<extension>
<domain-ext:transfer xmlns:domain='urn:ietf:params:xml:ns:domain-1.0' xmlns:domain-ext='http://www.eurid.eu/xml/epp/domain-ext-2.1'>
<domain-ext:request>
<domain-ext:contact type='billing'>c10</domain-ext:contact>
<domain-ext:contact type='tech'>c159</domain-ext:contact>
</domain-ext:request>
</domain-ext:transfer>
</extension>
</command>
</epp>
*/


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);
}


}
6 changes: 6 additions & 0 deletions Protocols/EPP/eppExtensions/domain-ext-2.1/includes.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?php
$this->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');
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php
namespace Metaregistrar\EPP;

class feeEppCheckDomainRequest extends eppCheckDomainRequest {
function __construct($checkrequest, $namespacesinroot) {
parent::__construct($checkrequest, $namespacesinroot);
$this->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;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php
namespace Metaregistrar\EPP;

class feeEppCheckdomainResponse extends eppCheckDomainResponse {
function __construct() {
parent::__construct();
}

public function getFees() {
$xpath = $this->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;
}
}

}
7 changes: 7 additions & 0 deletions Protocols/EPP/eppExtensions/fee-0.9/includes.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php
#
# Load the fee-0.9 specific additions
# SOURCE: https://tools.ietf.org/html/draft-brown-epp-fees-06
#
include_once(dirname(__FILE__) . '/eppRequests/feeEppCheckDomainRequest.php');
include_once(dirname(__FILE__) . '/eppResponses/feeEppCheckDomainResponse.php');
19 changes: 18 additions & 1 deletion Protocols/EPP/eppRequests/eppRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,24 @@ public function addExtension($name, $value) {
throw new eppException('Cannot set attribute on an empty epp element');
}
}


/**
* Adds the namespace to the EPP root element or to the applicable element, depending on the setting
* @param string $xmlns
* @param string $namespace
* @param \DOMElement $object
*/
protected function setNamespace($xmlns, $namespace, $object = null) {
$xmlns = str_replace('xmlns:','',$xmlns);
if ($this->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
Expand Down
6 changes: 4 additions & 2 deletions Registries/euridEppConnection/eppConnection.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down

0 comments on commit ce495d1

Please sign in to comment.