Skip to content
Open
81 changes: 81 additions & 0 deletions Protocols/EPP/eppExtensions/it-extcon-1.0/eppData/itEppContact.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
<?php
namespace Metaregistrar\EPP;
/**
* The Contact Info Object
*
* This will hold the complete contact info a registry can receive and give you
*
*/

class itEppContact extends eppContact {

private $entityTypes = [
1, // Italian and foreign natural persons
2, // Companies/one man companie
3, // Freelance workers/professionals
4, // Non-profit organizations
5, // Public organizations
6, // Other subjects
7, // Foreigners who match 2-6
];

private $consentForPublishing;
private $registrantEntityType;
private $registrantNationalityCode;
private $registrantRegCode;

public function __construct($postalInfo = null, $email = null, $voice = null, $fax = null, $password = null, $status = null, $consentForPublishing = null, $entityType = null, $nationalityCode = null, $regCode = null) {
parent::__construct($postalInfo, $email, $voice, $fax, $password, $status);

$this->setConsentForPublishing($consentForPublishing);
$this->setRegistrant($entityType, $nationalityCode, $regCode);
}

public function setConsentForPublishing($consent = false)
{
$this->consentForPublishing = $consent ? 1 : 0;
}

public function getConsentForPublishing()
{
return $this->consentForPublishing;
}

public function setRegistrantEntityType($entityType)
{
if (!in_array($entityType, $this->entityTypes)) {
throw new eppException(sprintf('The entity type: \'%s\' is invalid', $entityType));
}
$this->registrantEntityType = $entityType;
}

public function setRegistrantNationalityCode($nationalityCode)
{
if (!empty($nationalityCode)) {
$this->registrantNationalityCode = $nationalityCode;
}
}

public function setRegistrantRegCode($regCode)
{
if (!empty($regCode)) {
$this->registrantRegCode = $regCode;
}
}

public function setRegistrant($entityType, $nationalityCode, $regCode)
{
$this->setRegistrantEntityType($entityType);
$this->setRegistrantNationalityCode($nationalityCode);
$this->setRegistrantRegCode($regCode);
}

public function getRegistrant()
{
return [
'entityType' => $this->registrantEntityType,
'nationalityCode' => $this->registrantNationalityCode,
'regCode' => $this->registrantRegCode
];
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<?php
namespace Metaregistrar\EPP;
/*
<extension>
<extcon:create xmlns:extcon="http://www.nic.it/ITNIC-EPP/extcon-1.0" xsi:schemaLocation="http://www.nic.it/ITNIC-EPP/extcon-1.0 extcon-1.0.xsd">
<extcon:consentForPublishing>true</extcon:consentForPublishing>
<extcon:registrant>
<extcon:nationalityCode>IT</extcon:nationalityCode>
<extcon:entityType>1</extcon:entityType>
<extcon:regCode>BSSRCR78D03G674P</extcon:regCode>
</extcon:registrant>
</extcon:create>
</extension>
*/

class itEppCreateContactRequest extends eppCreateContactRequest {

/**
* itEppCreateContactRequest constructor.
* @param eppContact|null $createInfo
* @param string $contacttype
* @param string $language
* @throws eppException
*/
function __construct(itEppContact $createInfo) {
parent::__construct($createInfo);
$this->addContactExtension($createInfo);
$this->addSessionId();
}

/**
* @param object eppContact
*/
public function addContactExtension(itEppContact $createInfo) {
$this->addExtension('xmlns:xsi', 'http://www.w3.org/2001/XMLSchema-instance');
$this->addExtension('xsi:schemaLocation', 'urn:ietf:params:xml:ns:epp-1.0 epp-1.0.xsd');

$this->contactobject->setAttribute('xmlns:contact', 'urn:ietf:params:xml:ns:contact-1.0');
$this->contactobject->setAttribute('xsi:schemaLocation', 'urn:ietf:params:xml:ns:contact-1.0 contact-1.0.xsd');

$create = $this->createElement('extcon:create');
$create->setAttribute('xmlns:extcon', 'http://www.nic.it/ITNIC-EPP/extcon-1.0');
$create->setAttribute('xsi:schemaLocation', 'http://www.nic.it/ITNIC-EPP/extcon-1.0 extcon-1.0.xsd');

$create->appendChild($this->createElement('extcon:consentForPublishing', $createInfo->getConsentForPublishing()));

$registrant = $createInfo->getRegistrant();
$registrantElement = $this->createElement('extcon:registrant');
$registrantElement->appendChild($this->createElement('extcon:nationalityCode', $registrant['nationalityCode']));
$registrantElement->appendChild($this->createElement('extcon:entityType', $registrant['entityType']));
$registrantElement->appendChild($this->createElement('extcon:regCode', $registrant['regCode']));
$create->appendChild($registrantElement);

$this->getExtension()->appendChild($create);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?php
namespace Metaregistrar\EPP;

class itEppInfoContactResponse extends eppInfoContactResponse {

/**
*
* @return eppContact
*/
public function getContact()
{
$postalinfo = $this->getContactPostalInfo();

$contact = new itEppContact($postalinfo, $this->getContactEmail(), $this->getContactVoice(), $this->getContactFax(), null, null, $this->getConsentForPublishing(), $this->getRegistrantEntityType(), $this->getRegistrantNationalityCode(), $this->getRegistrantRegCode());
return $contact;
}

public function isRegistrant()
{
return $this->queryPath('/epp:epp/epp:response/epp:extension/extcon:infData/extcon:registrant') ? true : false;
}

public function getConsentForPublishing()
{
return (bool) $this->queryPath('/epp:epp/epp:response/epp:extension/extcon:infData/extcon:consentForPublishing');
}

public function getRegistrantEntityType()
{
return (int) $this->queryPath('/epp:epp/epp:response/epp:extension/extcon:infData/extcon:registrant/extcon:entityType');
}

public function getRegistrantNationalityCode()
{
return $this->queryPath('/epp:epp/epp:response/epp:extension/extcon:infData/extcon:registrant/extcon:nationalityCode');
}

public function getRegistrantRegCode()
{
return $this->queryPath('/epp:epp/epp:response/epp:extension/extcon:infData/extcon:registrant/extcon:regCode');
}

public function getRegistrant()
{
$registrant['nationalityCode'] = $this->getRegistrantNationalityCode();
$registrant['entityType'] = $this->getRegistrantEntityType();
$registrant['regCode'] = $this->getRegistrantRegCode();

return $registrant;
}
}
9 changes: 9 additions & 0 deletions Protocols/EPP/eppExtensions/it-extcon-1.0/includes.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php
$this->addExtension('extcon-1.0', 'http://www.nic.it/ITNIC-EPP/extcon-1.0');

include_once(dirname(__FILE__) . '/eppData/itEppContact.php');
include_once(dirname(__FILE__) . '/eppRequests/itEppCreateContactRequest.php');
include_once(dirname(__FILE__) . '/eppResponses/itEppInfoContactResponse.php');

$this->addCommandResponse('Metaregistrar\EPP\itEppCreateContactRequest', 'Metaregistrar\EPP\eppCreateContactResponse');
$this->addCommandResponse('Metaregistrar\EPP\eppInfoContactRequest', 'Metaregistrar\EPP\itEppInfoContactResponse');
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

namespace Metaregistrar\EPP;

class itEppCreateDomainResponse extends eppCreateDomainResponse
{
public function getIdnRequested()
{
return $this->queryPath('/epp:epp/epp:response/epp:extension/extdom:remappedIdnData/extdom:idnRequested');
}

public function getIdnCreated()
{
return $this->queryPath('/epp:epp/epp:response/epp:extension/extdom:remappedIdnData/extdom:idnCreated');
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php
namespace Metaregistrar\EPP;

class itEppInfoDomainResponse extends eppInfoDomainResponse
{
public function getDomainStatuses()
{
$statuses = parent::getDomainStatuses();

$xpath = $this->xPath();
$result = $xpath->query('/epp:epp/epp:response/epp:extension/extdom:infData/extdom:ownStatus');

foreach ($result as $status) {
/** @var \DOMElement $status */
$statuses[] = new eppStatus(
$status->getAttribute('s'),
$status->getAttribute('lang'),
$status->nodeValue
);
}

return $statuses;
}
}
8 changes: 8 additions & 0 deletions Protocols/EPP/eppExtensions/it-extdom-2.0/includes.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php
$this->addExtension('extdom-2.0', 'http://www.nic.it/ITNIC-EPP/extdom-2.0');

include_once(dirname(__FILE__) . '/eppResponses/itEppCreateDomainResponse.php');
include_once(dirname(__FILE__) . '/eppResponses/itEppInfoDomainResponse.php');

$this->addCommandResponse('Metaregistrar\EPP\eppCreateDomainRequest', 'Metaregistrar\EPP\itEppCreateDomainResponse');
$this->addCommandResponse('Metaregistrar\EPP\eppInfoDomainRequest', 'Metaregistrar\EPP\itEppInfoDomainResponse');
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php
namespace Metaregistrar\EPP;

class itEppLoginResponse extends eppResponse {
function __construct() {
parent::__construct();
}

function __destruct() {
parent::__destruct();
}

/**
* Return the available credit in euros
* @return float
*/
public function getCredit()
{
return (float) $this->queryPath('/epp:epp/epp:response/epp:extension/extepp:creditMsgData/extepp:credit');
}
}
6 changes: 6 additions & 0 deletions Protocols/EPP/eppExtensions/it-extepp-2.0/includes.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?php
$this->addExtension('extepp-2.0', 'http://www.nic.it/ITNIC-EPP/extepp-2.0');

include_once(dirname(__FILE__) . '/eppResponses/itEppLoginResponse.php');

$this->addCommandResponse('Metaregistrar\EPP\eppLoginRequest', 'Metaregistrar\EPP\itEppLoginResponse');
2 changes: 2 additions & 0 deletions Protocols/EPP/eppExtensions/it-extsecdns-1.0/includes.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?php
$this->addExtension('extsecDNS-1.0', 'http://www.nic.it/ITNIC-EPP/extsecDNS-1.0');
74 changes: 74 additions & 0 deletions Registries/itEppConnection/eppConnection.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
<?php
namespace Metaregistrar\EPP;

class itEppConnection extends eppHttpsConnection {

/*
* Available credit in euros
* @var float
*/
protected float $credit = 0;

public function __construct($logging = false, $settingsfile = null) {
parent::__construct($logging, $settingsfile);

parent::enableRgp();

parent::setServices(
array(
'urn:ietf:params:xml:ns:domain-1.0' => 'domain',
'urn:ietf:params:xml:ns:contact-1.0' => 'contact'
)
);

// Add registry-specific EPP extensions
parent::useExtension('it-extcon-1.0');
parent::useExtension('it-extdom-2.0');
parent::useExtension('it-extepp-2.0');
}

public function enableDnssec() {
parent::enableDnssec();
$this->useExtension('it-extsecdns-1.0');
}

public function disableDnssec() {
parent::disableDnssec();
$this->removeExtension('it-extsecdns-1.0');
}

/**
* Performs an EPP login request and checks the result
* @param bool $usecdata Enclose the password field with [[CDATA]]
* @return bool
*/
public function login($usecdata = false)
{
if (!$this->connected) {
if (!$this->connect()) {
return false;
}
}
$login = new eppLoginRequest(null, $usecdata);

if ($response = $this->request($login)) {
// Get available credit
/** @var itEppLoginResponse $response */
$this->credit = $response->getCredit();

$this->writeLog("Logged in", "LOGIN");
$this->loggedin = true;
return true;
}
return false;
}

/**
* Get the available credit in euros
* @return float
*/
public function getCredit(): float
{
return $this->credit;
}
}