Skip to content

Commit

Permalink
Merge a773ec3 into f93b782
Browse files Browse the repository at this point in the history
  • Loading branch information
johnny-bit committed Oct 28, 2019
2 parents f93b782 + a773ec3 commit c288a66
Show file tree
Hide file tree
Showing 84 changed files with 494 additions and 2,354 deletions.
9 changes: 8 additions & 1 deletion CHANGELOG.md
Expand Up @@ -7,19 +7,26 @@
- Updated code documentation (more contributions welcome)
- Increased testing coverage
- More detailed examples of using this library
- All frame objects now accept ObjectSpec as dependency in order to fix static ObjectSpec problems (eg inability to have custom namespaces). This isn't breaking since without ObjectSpec being passed, default one is used
- `get/sendFrame` are now protected methods in `Client` classes (_breaking_)

### Added

- DNSSec dsData support in Domain classes ( @johnny-bit)
- Introduced `HTTPClient` allowing EPP communication over HTTP(S) (@johnny-bit)
- `AbstractClient` class and `ClientInterface` interface for ease of creating `Client` replacements(@johnny-bit)
- NASK Extension - a full Polish domain registry support
- NASK Extension - a full Polish domain registry support (@johnny-bit)
- Dependency injection for ObjectSpec (especially useful for registrars not following EPP namespaces, like NASK) (@johnny-bit)
- Nominet `release` extension for domains (@greenmato)
- nic.it extensions (@bessone)

### Fixed

- RFC5733 compatibility enhancements (added `extension` to voice and fax) for Contact calls(@johnny-bit)
- Removed coverage checks from non-testable classes
- Incorrect file permissions (execute bit) on source files
- `verify_peer_name` logic (@domainregistrar)
- Testing issues (@bessone)

## 1.0.0 - 2018-12-23

Expand Down
93 changes: 88 additions & 5 deletions README.md
Expand Up @@ -45,11 +45,12 @@ Features
* [PSR-1](http://www.php-fig.org/psr/psr-1/), [PSR-2](http://www.php-fig.org/psr/psr-2/) & [PSR-4](http://www.php-fig.org/psr/psr-4/)
* notice and warning free (find them, and I'll fix it!)
* high-level usage (Plug & Play)
* simplified client (auto login/logout, auto inject clTRID)
* simplified client for socket and http(s) connections (auto login/logout, auto inject clTRID)
* SSL (+local-cert)
* XPath like setter to simplify the creation of complex XML structures
* XML based responses for direct traversal via XPath
* [RFC 5730](http://tools.ietf.org/html/rfc5730), [RFC 5731](http://tools.ietf.org/html/rfc5731), [RFC 5732](http://tools.ietf.org/html/rfc5732), [RFC 5733](http://tools.ietf.org/html/rfc5733), [RFC 5734](http://tools.ietf.org/html/rfc5734) & [RFC 3915](http://tools.ietf.org/html/rfc3915)
* DNSSEC support [RFC 5910](http://tools.ietf.org/html/rfc5910)


Install
Expand Down Expand Up @@ -119,7 +120,7 @@ require 'vendor/autoload.php';

use AfriCC\EPP\Frame\Command\Create\Host as CreateHost;

$frame = new CreateHost;
$frame = new CreateHost();
$frame->setHost('ns1.example.com');
$frame->setHost('ns2.example.com');
$frame->addAddr('8.8.8.8');
Expand All @@ -141,7 +142,7 @@ Method which will return an assoc array.
use AfriCC\EPP\Frame\Command\Check\Domain as DomainCheck;
use AfriCC\EPP\Frame\Response;

$frame = new DomainCheck;
$frame = new DomainCheck();
$frame->addDomain('example.org');
$frame->addDomain('example.net');
$frame->addDomain('example.com');
Expand Down Expand Up @@ -170,12 +171,95 @@ foreach ($data['chkData']['cd'] as $cd) {
printf('Domain: %s, available: %d' . PHP_EOL, $cd['name'], $cd['@name']['avail']);
}
```
### Custom ObjectSpec

If registrar you're working with uses custom namespace names (eg NASK) you can
use custom ObjectSpec. Clients always use specified ObjectSpec when decoding
responses from EPP server.

You can use this feature as follows:

```php
use AfriCC\EPP\HTTPClient as EPPClient;
use \AfriCC\EPP\Extension\NASK\ObjectSpec as NASKObjectSpec;
use AfriCC\EPP\Frame\Command\Poll;

$objectSpec = new NASKObjectSpec();
$config = [
'host' => 'https://app.registrar.tld',
'username' => 'user',
'password' => 'pass',
'services' => $objectSpec->services,
'serviceExtensions' => $objectSpec->serviceExtensions,
];

$epp_client = new EPPClient($config, $objectSpec);

$frame = new Poll($epp_client->getObjectSpec());
```

or you can create frames with custom ObjectSpec:

```php
use AfriCC\EPP\Extension\NASK\Update\Future as UpdateFuture;
use AfriCC\EPP\Extension\NASK\ObjectSpec as NASKObjectSpec;

$frame = new UpdateFuture(new NASKObjectSpec());
$frame->setFuture('example7.pl');
$frame->changeRegistrant('mak21');
$frame->changeAuthInfo('2fooBAR');
echo $frame;
```

You can also create different clients with different ObjectSpec and then you can
use `getObjectSpec` method when creating any request frame:

```php
use AfriCC\EPP\ObjectSpec as DefaultObjectSpec;
use AfriCC\EPP\Extension\NASK\ObjectSpec as NASKObjectSpec;
use AfriCC\EPP\Client as EPPClient;
use AfriCC\EPP\HTTPClient as HTTPEPPClient;
use AfriCC\EPP\Frame\Command\Poll;

//...
$nask_objectspec = new NASKObjectSpec();
$default_objectspec = new DefaultObjectSpec();

$nask_client = new HTTPEPPClient($nask_config, $nask_objectspec);
$http_client = new HTTPEPPClient($http_config, $default_objectspec);
$socket_client = new EPPClient($socket_config, $default_objectspec);
$nask_socket_client = new EPPClient($nask_socket_config, $nask_objectspec);

$nask_poll = new Poll($nask_client->getObjectSpec());
$default_poll = new Poll($socket_client->getObjectSpec());
```

You can also change Client's objectSpec on the fly via `setObjectSpec` method:

```php
use AfriCC\EPP\ObjectSpec as DefaultObjectSpec;
use AfriCC\EPP\Extension\NASK\ObjectSpec as NASKObjectSpec;
use AfriCC\EPP\Client as EPPClient;

//...
$nask_objectspec = new NASKObjectSpec();
$default_objectspec = new DefaultObjectSpec();

$variable_client = new EPPClient($socket_config, $default_objectspec);

//calls to getObjectSpec will return default objectSpec and responses
//will be parsed using default ObjectSpec

$variable_client->setObjectSpec($nask_objectspec);

//calls to getObjectSpec will return NASK objectSpec and responses
//will be parsed using NASK ObjectSpec

```

Future
------

* objectspec on login needs to be smarter (no global/static object, auto-injecter)
* stricter response parsing
* stricter request validation
* make it server capable (in conjunction with apache mod_epp)
Expand All @@ -201,4 +285,3 @@ License
php-epp2 is released under the GPLv3 License. See the bundled
[LICENSE](https://github.com/AfriCC/php-epp2/blob/master/LICENSE) file for
details.

64 changes: 64 additions & 0 deletions examples/Connection/http_connect.php
@@ -0,0 +1,64 @@
<?php

// debug
error_reporting(E_ALL);
ini_set('display_errors', true);

chdir(__DIR__);

require '../../vendor/autoload.php';

use AfriCC\EPP\Extension\NASK\ObjectSpec as NASKObjectSpec;
use AfriCC\EPP\Frame\Command\Poll;
use AfriCC\EPP\HTTPClient as EPPClient;

$objectSpec = new NASKObjectSpec();
$config = [
'debug' => true,
'host' => 'https://app.registrar.tld',
'username' => 'user',
'password' => 'pass',
'services' => $objectSpec->services,
'serviceExtensions' => $objectSpec->serviceExtensions,
//'ssl' => true, //ssl forced to true by using "https" protocol
'ca_cert' => 'ca.crt',
'local_cert' => 'client.crt',
'pk_cert' => 'client.key',
];

$epp_client = new EPPClient($config, $objectSpec);

try {
$greeting = $epp_client->connect();

echo $greeting;

$frame = new Poll($epp_client->getObjectSpec()); //use epp client default objectspec
$frame->request();

$response = $epp_client->request($frame);

while ($response->success() && $response->code() !== 1300) { // 1300 = result successful, no more mesages

echo 'Epp Poll message ID: ';
echo $response->queueId();
echo "\n";
echo 'Epp Poll Message: ';
echo $response->queueMessage();

$ackFrame = new Poll($epp_client->getObjectSpec());
$ackFrame->ack($response->queueId());
$ackResponse = $epp_client->request($ackFrame);
if (!$ackResponse->success()) {
echo "Couldn't ACK poll message\n";
break; // no ack!
}
$response = $client->request($frame); //reuse already existing poll request frame
}
} catch (Exception $e) {
echo $e->getMessage() . PHP_EOL;
unset($epp_client);
exit(1);
}

$epp_client->close();
Expand Up @@ -6,7 +6,7 @@

chdir(__DIR__);

require '../vendor/autoload.php';
require '../../vendor/autoload.php';

use AfriCC\EPP\Client as EPPClient;

Expand Down
Expand Up @@ -6,10 +6,9 @@

chdir(__DIR__);

require '../vendor/autoload.php';
require '../../../vendor/autoload.php';

use AfriCC\EPP\Extension\COZA\Info\CozaContact as CozaContactInfoExtension;
use AfriCC\EPP\Extension\COZA\Update\CozaContact as CozaContactUpdateExtension;

$frame = new CozaContactInfoExtension();
$frame->setId('MyContact');
Expand All @@ -24,10 +23,3 @@
$frame->setAuthInfo('password');
$frame->requestDomainListing();
echo $frame;

echo PHP_EOL;

$frame = new CozaContactUpdateExtension();
$frame->setId('MyContact');
$frame->cancelPendingAction();
echo $frame;
16 changes: 16 additions & 0 deletions examples/Extension/COZA/contact_update.php
@@ -0,0 +1,16 @@
<?php

// debug
error_reporting(E_ALL);
ini_set('display_errors', true);

chdir(__DIR__);

require '../../../vendor/autoload.php';

use AfriCC\EPP\Extension\COZA\Update\CozaContact as CozaContactUpdateExtension;

$frame = new CozaContactUpdateExtension();
$frame->setId('MyContact');
$frame->cancelPendingAction();
echo $frame;
6 changes: 2 additions & 4 deletions examples/Extension/NASK/check_future.php
Expand Up @@ -8,11 +8,9 @@

require './_autoload.php';
use AfriCC\EPP\Extension\NASK\Check\Future as CheckFuture;
use AfriCC\EPP\Extension\NASK\ObjectSpec;
use AfriCC\EPP\Extension\NASK\ObjectSpec as NASKObjectSpec;

ObjectSpec::overwriteParent();

$frame = new CheckFuture();
$frame = new CheckFuture(new NASKObjectSpec());
$frame->addFuture('ala.pl');
$frame->addFuture('ela.com.pl');
$frame->addFuture('ola.org');
Expand Down
6 changes: 2 additions & 4 deletions examples/Extension/NASK/create_future.php
Expand Up @@ -8,11 +8,9 @@

require './_autoload.php';
use AfriCC\EPP\Extension\NASK\Create\Future as CreateFuture;
use AfriCC\EPP\Extension\NASK\ObjectSpec;
use AfriCC\EPP\Extension\NASK\ObjectSpec as NASKObjectSpec;

ObjectSpec::overwriteParent();

$frame = new CreateFuture();
$frame = new CreateFuture(new NASKObjectSpec());
$frame->setFuture('example.pl');
$frame->setPeriod('3y');
$frame->setRegistrant('jd1234');
Expand Down
6 changes: 2 additions & 4 deletions examples/Extension/NASK/delete_future.php
Expand Up @@ -8,10 +8,8 @@

require './_autoload.php';
use AfriCC\EPP\Extension\NASK\Delete\Future as DeleteFuture;
use AfriCC\EPP\Extension\NASK\ObjectSpec;
use AfriCC\EPP\Extension\NASK\ObjectSpec as NASKObjectSpec;

ObjectSpec::overwriteParent();

$frame = new DeleteFuture();
$frame = new DeleteFuture(new NASKObjectSpec());
$frame->setFuture('futuretest.pl');
echo $frame;
6 changes: 2 additions & 4 deletions examples/Extension/NASK/info_future.php
Expand Up @@ -8,11 +8,9 @@

require './_autoload.php';
use AfriCC\EPP\Extension\NASK\Info\Future as InfoFuture;
use AfriCC\EPP\Extension\NASK\ObjectSpec;
use AfriCC\EPP\Extension\NASK\ObjectSpec as NASKObjectSpec;

ObjectSpec::overwriteParent();

$frame = new InfoFuture();
$frame = new InfoFuture(new NASKObjectSpec());
$frame->setFuture('example.pl');
$frame->setAuthInfo('2fooBAR');
echo $frame;
6 changes: 2 additions & 4 deletions examples/Extension/NASK/renew_future.php
Expand Up @@ -7,12 +7,10 @@
chdir(__DIR__);

require './_autoload.php';
use AfriCC\EPP\Extension\NASK\ObjectSpec;
use AfriCC\EPP\Extension\NASK\ObjectSpec as NASKObjectSpec;
use AfriCC\EPP\Extension\NASK\Renew\Future as RenewFuture;

ObjectSpec::overwriteParent();

$frame = new RenewFuture();
$frame = new RenewFuture(new NASKObjectSpec());
$frame->setFuture('example.pl');
$frame->setCurrentExpirationDate('2010-10-30');
$frame->setPeriod('3y');
Expand Down
6 changes: 2 additions & 4 deletions examples/Extension/NASK/report_basic.php
Expand Up @@ -7,12 +7,10 @@
chdir(__DIR__);

require './_autoload.php';
use AfriCC\EPP\Extension\NASK\ObjectSpec;
use AfriCC\EPP\Extension\NASK\ObjectSpec as NASKObjectSpec;
use AfriCC\EPP\Extension\NASK\Report;

ObjectSpec::overwriteParent();

$frame = new Report();
$frame = new Report(new NASKObjectSpec());
$frame->setOffset(0);
$frame->setLimit(50);
echo $frame;
6 changes: 2 additions & 4 deletions examples/Extension/NASK/report_cancel.php
Expand Up @@ -7,12 +7,10 @@
chdir(__DIR__);

require './_autoload.php';
use AfriCC\EPP\Extension\NASK\ObjectSpec;
use AfriCC\EPP\Extension\NASK\ObjectSpec as NASKObjectSpec;
use AfriCC\EPP\Extension\NASK\Report\Cancel as ReportCancel;

ObjectSpec::overwriteParent();

$frame = new ReportCancel();
$frame = new ReportCancel(new NASKObjectSpec());
$frame->setReportId('e264a95d-0ba0-40f1-a0e0-97407fd5cdbe');
$frame->setOffset(0);
$frame->setLimit(50);
Expand Down
6 changes: 2 additions & 4 deletions examples/Extension/NASK/report_contact.php
Expand Up @@ -7,12 +7,10 @@
chdir(__DIR__);

require './_autoload.php';
use AfriCC\EPP\Extension\NASK\ObjectSpec;
use AfriCC\EPP\Extension\NASK\ObjectSpec as NASKObjectSpec;
use AfriCC\EPP\Extension\NASK\Report\Contact as ReportContact;

ObjectSpec::overwriteParent();

$frame = new ReportContact();
$frame = new ReportContact(new NASKObjectSpec());
$frame->setContactId('k13');
$frame->setOffset(0);
$frame->setLimit(50);
Expand Down

0 comments on commit c288a66

Please sign in to comment.