mirror of
https://github.com/elyby/oauth2-server.git
synced 2025-02-12 05:25:47 +05:30
63 lines
1.2 KiB
PHP
63 lines
1.2 KiB
PHP
|
<?php
|
||
|
/**
|
||
|
* Cryptography key holder.
|
||
|
*
|
||
|
* @author Julián Gutiérrez <juliangut@gmail.com>
|
||
|
* @copyright Copyright (c) Alex Bilbie
|
||
|
* @license http://mit-license.org/
|
||
|
*
|
||
|
* @link https://github.com/thephpleague/oauth2-server
|
||
|
*/
|
||
|
namespace League\OAuth2\Server;
|
||
|
|
||
|
class CryptKey
|
||
|
{
|
||
|
/**
|
||
|
* @var string
|
||
|
*/
|
||
|
protected $keyPath;
|
||
|
|
||
|
/**
|
||
|
* @var string
|
||
|
*/
|
||
|
protected $passPhrase;
|
||
|
|
||
|
/**
|
||
|
* @param string $keyPath
|
||
|
* @param null|string $passPhrase
|
||
|
*/
|
||
|
public function __construct($keyPath, $passPhrase = null)
|
||
|
{
|
||
|
if (strpos($keyPath, 'file://') !== 0) {
|
||
|
$keyPath = 'file://' . $keyPath;
|
||
|
}
|
||
|
|
||
|
if (!file_exists($keyPath) || !is_readable($keyPath)) {
|
||
|
throw new \LogicException(sprintf('Key path "%s" does not exist or is not readable', $keyPath));
|
||
|
}
|
||
|
|
||
|
$this->keyPath = $keyPath;
|
||
|
$this->passPhrase = $passPhrase;
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Retrieve key path.
|
||
|
*
|
||
|
* @return string
|
||
|
*/
|
||
|
public function getKeyPath()
|
||
|
{
|
||
|
return $this->keyPath;
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Retrieve key pass phrase.
|
||
|
*
|
||
|
* @return null|string
|
||
|
*/
|
||
|
public function getPassPhrase()
|
||
|
{
|
||
|
return $this->passPhrase;
|
||
|
}
|
||
|
}
|