mirror of
https://github.com/anikeen-com/yaac.git
synced 2026-03-14 14:16:24 +00:00
Initial commit
This commit is contained in:
87
src/Data/Account.php
Normal file
87
src/Data/Account.php
Normal file
@@ -0,0 +1,87 @@
|
||||
<?php
|
||||
|
||||
namespace Afosto\LetsEncrypt\Data;
|
||||
|
||||
class Account
|
||||
{
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $contact;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $createdAt;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
protected $isValid;
|
||||
|
||||
/**
|
||||
* @var
|
||||
*/
|
||||
protected $initialIp;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $accountURL;
|
||||
|
||||
|
||||
public function __construct(
|
||||
array $contact,
|
||||
\DateTime $createdAt,
|
||||
bool $isValid,
|
||||
string $initialIp,
|
||||
string $accountURL
|
||||
) {
|
||||
$this->initialIp = $initialIp;
|
||||
$this->contact = $contact;
|
||||
$this->createdAt = $createdAt;
|
||||
$this->isValid = $isValid;
|
||||
$this->accountURL = $accountURL;
|
||||
}
|
||||
|
||||
public function getId(): string
|
||||
{
|
||||
return substr($this->accountURL, strrpos($this->accountURL, '/') + 1);
|
||||
}
|
||||
|
||||
public function getCreatedAt(): \DateTime
|
||||
{
|
||||
return $this->createdAt;
|
||||
}
|
||||
|
||||
|
||||
public function getAccountURL(): string
|
||||
{
|
||||
return $this->accountURL;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getContact(): array
|
||||
{
|
||||
return $this->contact;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getInitialIp(): string
|
||||
{
|
||||
return $this->initialIp;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isValid(): bool
|
||||
{
|
||||
return $this->isValid;
|
||||
}
|
||||
}
|
||||
93
src/Data/Authorization.php
Normal file
93
src/Data/Authorization.php
Normal file
@@ -0,0 +1,93 @@
|
||||
<?php
|
||||
|
||||
namespace Afosto\LetsEncrypt\Data;
|
||||
|
||||
use Afosto\LetsEncrypt\Client;
|
||||
|
||||
class Authorization
|
||||
{
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $domain;
|
||||
|
||||
/**
|
||||
* @var \DateTime
|
||||
*/
|
||||
protected $expires;
|
||||
|
||||
/**
|
||||
* @var Challenge[]
|
||||
*/
|
||||
protected $challenges = [];
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $digest;
|
||||
|
||||
public function __construct(string $domain, string $expires, string $digest)
|
||||
{
|
||||
$this->domain = $domain;
|
||||
$this->expires = (new \DateTime())->setTimestamp(strtotime($expires));
|
||||
$this->digest = $digest;
|
||||
}
|
||||
|
||||
public function addChallenge(Challenge $challenge)
|
||||
{
|
||||
$this->challenges[] = $challenge;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getDomain(): string
|
||||
{
|
||||
return $this->domain;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return \DateTime
|
||||
*/
|
||||
public function getExpires(): \DateTime
|
||||
{
|
||||
return $this->expires;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Challenge[]
|
||||
*/
|
||||
public function getChallenges(): array
|
||||
{
|
||||
return $this->challenges;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Challenge|bool
|
||||
*/
|
||||
public function getHttpChallenge()
|
||||
{
|
||||
foreach ($this->getChallenges() as $challenge) {
|
||||
if ($challenge->getType() == Client::VALIDATION_HTTP) {
|
||||
return $challenge;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Challenge $challenge
|
||||
* @return File|bool
|
||||
*/
|
||||
public function getFile(Challenge $challenge)
|
||||
{
|
||||
if ($challenge->getType() == Client::VALIDATION_HTTP) {
|
||||
$file = new File($challenge->getToken(), $challenge->getToken() . '.' . $this->digest);
|
||||
return $file;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
76
src/Data/Certificate.php
Normal file
76
src/Data/Certificate.php
Normal file
@@ -0,0 +1,76 @@
|
||||
<?php
|
||||
|
||||
namespace Afosto\LetsEncrypt\Data;
|
||||
|
||||
use Afosto\LetsEncrypt\Helper;
|
||||
|
||||
class Certificate
|
||||
{
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $privateKey;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $certificate;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $csr;
|
||||
|
||||
/**
|
||||
* @var \DateTime
|
||||
*/
|
||||
protected $expiryDate;
|
||||
|
||||
/**
|
||||
* Certificate constructor.
|
||||
* @param $privateKey
|
||||
* @param $csr
|
||||
* @param $certificate
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function __construct($privateKey, $csr, $certificate)
|
||||
{
|
||||
$this->privateKey = $privateKey;
|
||||
$this->csr = $csr;
|
||||
$this->certificate = $certificate;
|
||||
$this->expiryDate = Helper::getCertExpiryDate($certificate);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getCsr(): string
|
||||
{
|
||||
return $this->csr;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \DateTime
|
||||
*/
|
||||
public function getExpiryDate(): \DateTime
|
||||
{
|
||||
return $this->expiryDate;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getCertificate(): string
|
||||
{
|
||||
return $this->certificate;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getPrivateKey(): string
|
||||
{
|
||||
return $this->privateKey;
|
||||
}
|
||||
}
|
||||
83
src/Data/Challenge.php
Normal file
83
src/Data/Challenge.php
Normal file
@@ -0,0 +1,83 @@
|
||||
<?php
|
||||
|
||||
namespace Afosto\LetsEncrypt\Data;
|
||||
|
||||
class Challenge
|
||||
{
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $authorizationURL;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $type;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $status;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $url;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $token;
|
||||
|
||||
/**
|
||||
* Challenge constructor.
|
||||
* @param string $authorizationURL
|
||||
* @param string $type
|
||||
* @param string $status
|
||||
* @param string $url
|
||||
* @param string $token
|
||||
*/
|
||||
public function __construct(string $authorizationURL, string $type, string $status, string $url, string $token)
|
||||
{
|
||||
$this->authorizationURL = $authorizationURL;
|
||||
$this->type = $type;
|
||||
$this->status = $status;
|
||||
$this->url = $url;
|
||||
$this->token = $token;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getUrl(): string
|
||||
{
|
||||
return $this->url;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getType(): string
|
||||
{
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getToken(): string
|
||||
{
|
||||
return $this->token;
|
||||
}
|
||||
|
||||
public function getStatus(): string
|
||||
{
|
||||
return $this->status;
|
||||
}
|
||||
|
||||
public function getAuthorizationURL(): string
|
||||
{
|
||||
return $this->authorizationURL;
|
||||
}
|
||||
}
|
||||
40
src/Data/File.php
Normal file
40
src/Data/File.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace Afosto\LetsEncrypt\Data;
|
||||
|
||||
class File
|
||||
{
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $filename;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $contents;
|
||||
|
||||
|
||||
public function __construct(string $filename, string $contents)
|
||||
{
|
||||
$this->contents = $contents;
|
||||
$this->filename = $filename;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getFilename(): string
|
||||
{
|
||||
return $this->filename;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getContents(): string
|
||||
{
|
||||
return $this->contents;
|
||||
}
|
||||
}
|
||||
102
src/Data/Order.php
Normal file
102
src/Data/Order.php
Normal file
@@ -0,0 +1,102 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Afosto\LetsEncrypt\Data;
|
||||
|
||||
class Order
|
||||
{
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $url;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $status;
|
||||
|
||||
/**
|
||||
* @var \DateTime
|
||||
*/
|
||||
protected $expiresAt;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $identifiers;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $authorizations;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $finalizeURL;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $domains;
|
||||
|
||||
|
||||
public function __construct(
|
||||
array $domains,
|
||||
string $url,
|
||||
string $status,
|
||||
string $expiresAt,
|
||||
array $identifiers,
|
||||
array $authorizations,
|
||||
string $finalizeURL
|
||||
) {
|
||||
$this->domains = $domains;
|
||||
$this->url = $url;
|
||||
$this->status = $status;
|
||||
$this->expiresAt = (new \DateTime())->setTimestamp(strtotime($expiresAt));
|
||||
$this->identifiers = $identifiers;
|
||||
$this->authorizations = $authorizations;
|
||||
$this->finalizeURL = $finalizeURL;
|
||||
}
|
||||
|
||||
public function getId(): string
|
||||
{
|
||||
return substr($this->url, strrpos($this->url, '/') + 1);
|
||||
}
|
||||
|
||||
public function getURL(): string
|
||||
{
|
||||
return $this->url;
|
||||
}
|
||||
|
||||
public function getAuthorizationURLs(): array
|
||||
{
|
||||
return $this->authorizations;
|
||||
}
|
||||
|
||||
public function getStatus(): string
|
||||
{
|
||||
return $this->status;
|
||||
}
|
||||
|
||||
public function getExpiresAt(): \DateTime
|
||||
{
|
||||
return $this->expiresAt;
|
||||
}
|
||||
|
||||
public function getIdentifiers(): array
|
||||
{
|
||||
return $this->identifiers;
|
||||
}
|
||||
|
||||
public function getFinalizeURL(): string
|
||||
{
|
||||
return $this->finalizeURL;
|
||||
}
|
||||
|
||||
public function getDomains(): array
|
||||
{
|
||||
return $this->domains;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user