This commit is contained in:
2024-08-05 22:57:28 +08:00
commit 0efda6c02a
1779 changed files with 171774 additions and 0 deletions
@@ -0,0 +1,25 @@
<?php
/*
* This file is part of the Acme PHP project.
*
* (c) Titouan Galopin <galopintitouan@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace AcmePhp\Core\Exception;
/**
* Error reported by the client.
*
* @author Titouan Galopin <galopintitouan@gmail.com>
*/
class AcmeCoreClientException extends AcmeCoreException
{
public function __construct($message, \Exception $previous = null)
{
parent::__construct($message, 0, $previous);
}
}
@@ -0,0 +1,19 @@
<?php
/*
* This file is part of the Acme PHP project.
*
* (c) Titouan Galopin <galopintitouan@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace AcmePhp\Core\Exception;
/**
* @author Titouan Galopin <galopintitouan@gmail.com>
*/
class AcmeCoreException extends \RuntimeException
{
}
@@ -0,0 +1,27 @@
<?php
/*
* This file is part of the Acme PHP project.
*
* (c) Titouan Galopin <galopintitouan@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace AcmePhp\Core\Exception;
use Psr\Http\Message\RequestInterface;
/**
* Error reported by the server.
*
* @author Titouan Galopin <galopintitouan@gmail.com>
*/
class AcmeCoreServerException extends AcmeCoreException
{
public function __construct(RequestInterface $request, $message, \Exception $previous = null)
{
parent::__construct($message, $previous ? $previous->getCode() : 0, $previous);
}
}
@@ -0,0 +1,23 @@
<?php
/*
* This file is part of the Acme PHP project.
*
* (c) Titouan Galopin <galopintitouan@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace AcmePhp\Core\Exception;
/**
* @author Jérémy Derussé <jeremy@derusse.com>
*/
class AcmeDnsResolutionException extends AcmeCoreException
{
public function __construct($message, \Exception $previous = null)
{
parent::__construct(null === $message ? 'An exception was thrown during resolution of DNS' : $message, 0, $previous);
}
}
@@ -0,0 +1,23 @@
<?php
/*
* This file is part of the Acme PHP project.
*
* (c) Titouan Galopin <galopintitouan@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace AcmePhp\Core\Exception\Protocol;
/**
* @author Titouan Galopin <galopintitouan@gmail.com>
*/
class CertificateRequestFailedException extends ProtocolException
{
public function __construct(string $response)
{
parent::__construct(sprintf('Certificate request failed (response: %s)', $response));
}
}
@@ -0,0 +1,23 @@
<?php
/*
* This file is part of the Acme PHP project.
*
* (c) Titouan Galopin <galopintitouan@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace AcmePhp\Core\Exception\Protocol;
/**
* @author Titouan Galopin <galopintitouan@gmail.com>
*/
class CertificateRequestTimedOutException extends ProtocolException
{
public function __construct(string $response)
{
parent::__construct(sprintf('Certificate request timed out (response: %s)', $response));
}
}
@@ -0,0 +1,18 @@
<?php
/*
* This file is part of the Acme PHP project.
*
* (c) Titouan Galopin <galopintitouan@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace AcmePhp\Core\Exception\Protocol;
use AcmePhp\Core\Exception\AcmeCoreClientException;
class CertificateRevocationException extends AcmeCoreClientException
{
}
@@ -0,0 +1,38 @@
<?php
/*
* This file is part of the Acme PHP project.
*
* (c) Titouan Galopin <galopintitouan@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace AcmePhp\Core\Exception\Protocol;
/**
* @author Titouan Galopin <galopintitouan@gmail.com>
*/
class ChallengeFailedException extends ProtocolException
{
private $response;
public function __construct($response, \Exception $previous = null)
{
parent::__construct(
sprintf('Challenge failed (response: %s).', json_encode($response)),
$previous
);
$this->response = $response;
}
/**
* @return array
*/
public function getResponse()
{
return $this->response;
}
}
@@ -0,0 +1,23 @@
<?php
/*
* This file is part of the Acme PHP project.
*
* (c) Titouan Galopin <galopintitouan@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace AcmePhp\Core\Exception\Protocol;
/**
* @author Titouan Galopin <galopintitouan@gmail.com>
*/
class ChallengeNotSupportedException extends ProtocolException
{
public function __construct(\Exception $previous = null)
{
parent::__construct('This ACME server does not expose supported challenge.', $previous);
}
}
@@ -0,0 +1,38 @@
<?php
/*
* This file is part of the Acme PHP project.
*
* (c) Titouan Galopin <galopintitouan@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace AcmePhp\Core\Exception\Protocol;
/**
* @author Titouan Galopin <galopintitouan@gmail.com>
*/
class ChallengeTimedOutException extends ProtocolException
{
private $response;
public function __construct($response, \Exception $previous = null)
{
parent::__construct(
sprintf('Challenge timed out (response: %s).', json_encode($response)),
$previous
);
$this->response = $response;
}
/**
* @return array
*/
public function getResponse()
{
return $this->response;
}
}
@@ -0,0 +1,19 @@
<?php
/*
* This file is part of the Acme PHP project.
*
* (c) Titouan Galopin <galopintitouan@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace AcmePhp\Core\Exception\Protocol;
/**
* @author Titouan Galopin <galopintitouan@gmail.com>
*/
class ExpectedJsonException extends ProtocolException
{
}
@@ -0,0 +1,23 @@
<?php
/*
* This file is part of the Acme PHP project.
*
* (c) Titouan Galopin <galopintitouan@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace AcmePhp\Core\Exception\Protocol;
use AcmePhp\Core\Exception\AcmeCoreClientException;
/**
* Error because the protocol was not respected.
*
* @author Titouan Galopin <galopintitouan@gmail.com>
*/
class ProtocolException extends AcmeCoreClientException
{
}
@@ -0,0 +1,30 @@
<?php
/*
* This file is part of the Acme PHP project.
*
* (c) Titouan Galopin <galopintitouan@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace AcmePhp\Core\Exception\Server;
use AcmePhp\Core\Exception\AcmeCoreServerException;
use Psr\Http\Message\RequestInterface;
/**
* @author Titouan Galopin <galopintitouan@gmail.com>
*/
class BadCsrServerException extends AcmeCoreServerException
{
public function __construct(RequestInterface $request, string $detail, \Exception $previous = null)
{
parent::__construct(
$request,
'[badCSR] The CSR is unacceptable (e.g., due to a short key): '.$detail,
$previous
);
}
}
@@ -0,0 +1,30 @@
<?php
/*
* This file is part of the Acme PHP project.
*
* (c) Titouan Galopin <galopintitouan@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace AcmePhp\Core\Exception\Server;
use AcmePhp\Core\Exception\AcmeCoreServerException;
use Psr\Http\Message\RequestInterface;
/**
* @author Titouan Galopin <galopintitouan@gmail.com>
*/
class BadNonceServerException extends AcmeCoreServerException
{
public function __construct(RequestInterface $request, string $detail, \Exception $previous = null)
{
parent::__construct(
$request,
'[badNonce] The client sent an unacceptable anti-replay nonce: '.$detail,
$previous
);
}
}
@@ -0,0 +1,30 @@
<?php
/*
* This file is part of the Acme PHP project.
*
* (c) Titouan Galopin <galopintitouan@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace AcmePhp\Core\Exception\Server;
use AcmePhp\Core\Exception\AcmeCoreServerException;
use Psr\Http\Message\RequestInterface;
/**
* @author Alex Plekhanov <alex@plekhanov.dev>
*/
class CaaServerException extends AcmeCoreServerException
{
public function __construct(RequestInterface $request, string $detail, \Exception $previous = null)
{
parent::__construct(
$request,
'[caa] Certification Authority Authorization (CAA) records forbid the CA from issuing a certificate: '.$detail,
$previous
);
}
}
@@ -0,0 +1,30 @@
<?php
/*
* This file is part of the Acme PHP project.
*
* (c) Titouan Galopin <galopintitouan@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace AcmePhp\Core\Exception\Server;
use AcmePhp\Core\Exception\AcmeCoreServerException;
use Psr\Http\Message\RequestInterface;
/**
* @author Titouan Galopin <galopintitouan@gmail.com>
*/
class ConnectionServerException extends AcmeCoreServerException
{
public function __construct(RequestInterface $request, string $detail, \Exception $previous = null)
{
parent::__construct(
$request,
'[connection] The server could not connect to the client for DV: '.$detail,
$previous
);
}
}
@@ -0,0 +1,30 @@
<?php
/*
* This file is part of the Acme PHP project.
*
* (c) Titouan Galopin <galopintitouan@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace AcmePhp\Core\Exception\Server;
use AcmePhp\Core\Exception\AcmeCoreServerException;
use Psr\Http\Message\RequestInterface;
/**
* @author Alex Plekhanov <alex@plekhanov.dev>
*/
class DnsServerException extends AcmeCoreServerException
{
public function __construct(RequestInterface $request, string $detail, \Exception $previous = null)
{
parent::__construct(
$request,
'[dns] There was a problem with a DNS query during identifier validation: '.$detail,
$previous
);
}
}
@@ -0,0 +1,30 @@
<?php
/*
* This file is part of the Acme PHP project.
*
* (c) Titouan Galopin <galopintitouan@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace AcmePhp\Core\Exception\Server;
use AcmePhp\Core\Exception\AcmeCoreServerException;
use Psr\Http\Message\RequestInterface;
/**
* @author Alex Plekhanov <alex@plekhanov.dev>
*/
class IncorrectResponseServerException extends AcmeCoreServerException
{
public function __construct(RequestInterface $request, string $detail, \Exception $previous = null)
{
parent::__construct(
$request,
"[incorrectResponse] Response received didnt match the challenge's requirements: ".$detail,
$previous
);
}
}
@@ -0,0 +1,30 @@
<?php
/*
* This file is part of the Acme PHP project.
*
* (c) Titouan Galopin <galopintitouan@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace AcmePhp\Core\Exception\Server;
use AcmePhp\Core\Exception\AcmeCoreServerException;
use Psr\Http\Message\RequestInterface;
/**
* @author Titouan Galopin <galopintitouan@gmail.com>
*/
class InternalServerException extends AcmeCoreServerException
{
public function __construct(RequestInterface $request, string $detail, \Exception $previous = null)
{
parent::__construct(
$request,
'[serverInternal] The server experienced an internal error: '.$detail,
$previous
);
}
}
@@ -0,0 +1,30 @@
<?php
/*
* This file is part of the Acme PHP project.
*
* (c) Titouan Galopin <galopintitouan@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace AcmePhp\Core\Exception\Server;
use AcmePhp\Core\Exception\AcmeCoreServerException;
use Psr\Http\Message\RequestInterface;
/**
* @author Alex Plekhanov <alex@plekhanov.dev>
*/
class InvalidContactServerException extends AcmeCoreServerException
{
public function __construct(RequestInterface $request, string $detail, \Exception $previous = null)
{
parent::__construct(
$request,
'[invalidContact] A contact URL for an account was invalid: '.$detail,
$previous
);
}
}
@@ -0,0 +1,30 @@
<?php
/*
* This file is part of the Acme PHP project.
*
* (c) Titouan Galopin <galopintitouan@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace AcmePhp\Core\Exception\Server;
use AcmePhp\Core\Exception\AcmeCoreServerException;
use Psr\Http\Message\RequestInterface;
/**
* @author Titouan Galopin <galopintitouan@gmail.com>
*/
class InvalidEmailServerException extends AcmeCoreServerException
{
public function __construct(RequestInterface $request, string $detail, \Exception $previous = null)
{
parent::__construct(
$request,
'[invalidEmail] This email is unacceptable (e.g., it is invalid): '.$detail,
$previous
);
}
}
@@ -0,0 +1,30 @@
<?php
/*
* This file is part of the Acme PHP project.
*
* (c) Titouan Galopin <galopintitouan@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace AcmePhp\Core\Exception\Server;
use AcmePhp\Core\Exception\AcmeCoreServerException;
use Psr\Http\Message\RequestInterface;
/**
* @author Titouan Galopin <galopintitouan@gmail.com>
*/
class MalformedServerException extends AcmeCoreServerException
{
public function __construct(RequestInterface $request, string $detail, \Exception $previous = null)
{
parent::__construct(
$request,
'[malformed] The request message was malformed: '.$detail,
$previous
);
}
}
@@ -0,0 +1,27 @@
<?php
/*
* This file is part of the Acme PHP project.
*
* (c) Titouan Galopin <galopintitouan@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace AcmePhp\Core\Exception\Server;
use AcmePhp\Core\Exception\AcmeCoreServerException;
use Psr\Http\Message\RequestInterface;
class OrderNotReadyServerException extends AcmeCoreServerException
{
public function __construct(RequestInterface $request, string $detail, \Exception $previous = null)
{
parent::__construct(
$request,
'[orderNotReady] Order could not be finalized: '.$detail,
$previous
);
}
}
@@ -0,0 +1,30 @@
<?php
/*
* This file is part of the Acme PHP project.
*
* (c) Titouan Galopin <galopintitouan@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace AcmePhp\Core\Exception\Server;
use AcmePhp\Core\Exception\AcmeCoreServerException;
use Psr\Http\Message\RequestInterface;
/**
* @author Titouan Galopin <galopintitouan@gmail.com>
*/
class RateLimitedServerException extends AcmeCoreServerException
{
public function __construct(RequestInterface $request, string $detail, \Exception $previous = null)
{
parent::__construct(
$request,
'[rateLimited] This client reached the rate limit of the server: '.$detail,
$previous
);
}
}
@@ -0,0 +1,30 @@
<?php
/*
* This file is part of the Acme PHP project.
*
* (c) Titouan Galopin <galopintitouan@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace AcmePhp\Core\Exception\Server;
use AcmePhp\Core\Exception\AcmeCoreServerException;
use Psr\Http\Message\RequestInterface;
/**
* @author Alex Plekhanov <alex@plekhanov.dev>
*/
class RejectedIdentifierServerException extends AcmeCoreServerException
{
public function __construct(RequestInterface $request, string $detail, \Exception $previous = null)
{
parent::__construct(
$request,
'[rejectedIdentifier] The server will not issue certificates for the identifier: '.$detail,
$previous
);
}
}
@@ -0,0 +1,30 @@
<?php
/*
* This file is part of the Acme PHP project.
*
* (c) Titouan Galopin <galopintitouan@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace AcmePhp\Core\Exception\Server;
use AcmePhp\Core\Exception\AcmeCoreServerException;
use Psr\Http\Message\RequestInterface;
/**
* @author Titouan Galopin <galopintitouan@gmail.com>
*/
class TlsServerException extends AcmeCoreServerException
{
public function __construct(RequestInterface $request, string $detail, \Exception $previous = null)
{
parent::__construct(
$request,
'[tls] The server experienced a TLS error during DV: '.$detail,
$previous
);
}
}
@@ -0,0 +1,30 @@
<?php
/*
* This file is part of the Acme PHP project.
*
* (c) Titouan Galopin <galopintitouan@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace AcmePhp\Core\Exception\Server;
use AcmePhp\Core\Exception\AcmeCoreServerException;
use Psr\Http\Message\RequestInterface;
/**
* @author Titouan Galopin <galopintitouan@gmail.com>
*/
class UnauthorizedServerException extends AcmeCoreServerException
{
public function __construct(RequestInterface $request, string $detail, \Exception $previous = null)
{
parent::__construct(
$request,
'[unauthorized] The client lacks sufficient authorization: '.$detail,
$previous
);
}
}
@@ -0,0 +1,30 @@
<?php
/*
* This file is part of the Acme PHP project.
*
* (c) Titouan Galopin <galopintitouan@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace AcmePhp\Core\Exception\Server;
use AcmePhp\Core\Exception\AcmeCoreServerException;
use Psr\Http\Message\RequestInterface;
/**
* @author Titouan Galopin <galopintitouan@gmail.com>
*/
class UnknownHostServerException extends AcmeCoreServerException
{
public function __construct(RequestInterface $request, string $detail, \Exception $previous = null)
{
parent::__construct(
$request,
'[unknownHost] The server could not resolve a domain name: '.$detail,
$previous
);
}
}
@@ -0,0 +1,30 @@
<?php
/*
* This file is part of the Acme PHP project.
*
* (c) Titouan Galopin <galopintitouan@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace AcmePhp\Core\Exception\Server;
use AcmePhp\Core\Exception\AcmeCoreServerException;
use Psr\Http\Message\RequestInterface;
/**
* @author Alex Plekhanov <alex@plekhanov.dev>
*/
class UnsupportedContactServerException extends AcmeCoreServerException
{
public function __construct(RequestInterface $request, string $detail, \Exception $previous = null)
{
parent::__construct(
$request,
'[unsupportedContact] A contact URL for an account used an unsupported protocol scheme: '.$detail,
$previous
);
}
}
@@ -0,0 +1,30 @@
<?php
/*
* This file is part of the Acme PHP project.
*
* (c) Titouan Galopin <galopintitouan@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace AcmePhp\Core\Exception\Server;
use AcmePhp\Core\Exception\AcmeCoreServerException;
use Psr\Http\Message\RequestInterface;
/**
* @author Alex Plekhanov <alex@plekhanov.dev>
*/
class UnsupportedIdentifierServerException extends AcmeCoreServerException
{
public function __construct(RequestInterface $request, string $detail, \Exception $previous = null)
{
parent::__construct(
$request,
'[unsupportedIdentifier] An identifier is of an unsupported type: '.$detail,
$previous
);
}
}
@@ -0,0 +1,30 @@
<?php
/*
* This file is part of the Acme PHP project.
*
* (c) Titouan Galopin <galopintitouan@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace AcmePhp\Core\Exception\Server;
use AcmePhp\Core\Exception\AcmeCoreServerException;
use Psr\Http\Message\RequestInterface;
/**
* @author Alex Plekhanov <alex@plekhanov.dev>
*/
class UserActionRequiredServerException extends AcmeCoreServerException
{
public function __construct(RequestInterface $request, string $detail, \Exception $previous = null)
{
parent::__construct(
$request,
'[userActionRequired] Visit the “instance” URL and take actions specified there: '.$detail,
$previous
);
}
}