PHP Classes

File: src/Chronicle/Middleware/CheckAdminSignature.php

Recommend this page to a friend!
  Classes of Scott Arciszewski  >  Chronicle  >  src/Chronicle/Middleware/CheckAdminSignature.php  >  Download  
File: src/Chronicle/Middleware/CheckAdminSignature.php
Role: Class source
Content type: text/plain
Description: Class source
Class: Chronicle
Append arbitrary data to a storage container
Author: By
Last change:
Date: 3 years ago
Size: 1,135 bytes
 

Contents

Class file image Download
<?php
declare(strict_types=1);
namespace
ParagonIE\Chronicle\Middleware;

use
ParagonIE\Chronicle\Chronicle;
use
ParagonIE\Chronicle\Exception\ClientNotFound;
use
ParagonIE\ConstantTime\Base64UrlSafe;
use
ParagonIE\Sapient\CryptographyKeys\SigningPublicKey;

/**
 * Class CheckAdminSignature
 * @package ParagonIE\Chronicle\Middleware
 */
class CheckAdminSignature extends CheckClientSignature
{
    const
PROPERTIES_TO_SET = ['authenticated', 'administrator'];

   
/**
     * Only selects a valid result if the client has isAdmin set to TRUE.
     *
     * @param string $clientId
     * @return SigningPublicKey
     * @throws ClientNotFound
     */
   
public function getPublicKey(string $clientId): SigningPublicKey
   
{
       
$sqlResult = Chronicle::getDatabase()->row(
           
"SELECT * FROM chronicle_clients WHERE publicid = ? AND isAdmin",
           
$clientId
       
);
        if (empty(
$sqlResult)) {
            throw new
ClientNotFound('Client not found or is not an administrator.');
        }
        return new
SigningPublicKey(
           
Base64UrlSafe::decode($sqlResult['publickey'])
        );
    }
}

For more information send a message to info at phpclasses dot org.