mirror of
https://github.com/elyby/oauth2-server.git
synced 2024-11-01 16:33:07 +05:30
Removed unused SecureKey class
This commit is contained in:
parent
937d425e4c
commit
97c138bb0b
@ -1,48 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* OAuth 2.0 Secure key generator.
|
||||
*
|
||||
* @author Alex Bilbie <hello@alexbilbie.com>
|
||||
* @copyright Copyright (c) 2013 PHP League of Extraordinary Packages
|
||||
* @license http://mit-license.org/
|
||||
*
|
||||
* @link http://github.com/php-loep/oauth2-server
|
||||
*/
|
||||
namespace League\OAuth2\Server\Utils;
|
||||
|
||||
use League\OAuth2\Server\Exception\OAuthServerException;
|
||||
|
||||
/**
|
||||
* SecureKey class.
|
||||
*/
|
||||
class SecureKey
|
||||
{
|
||||
/**
|
||||
* Generate a new unique code.
|
||||
*
|
||||
* @param int $len Length of the generated code
|
||||
*
|
||||
* @throws \League\OAuth2\Server\Exception\OAuthServerException
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function generate($len = 40)
|
||||
{
|
||||
try {
|
||||
$string = random_bytes($len);
|
||||
// @codeCoverageIgnoreStart
|
||||
} catch (\TypeError $e) {
|
||||
// Well, it's an integer, so this IS unexpected.
|
||||
throw OAuthServerException::serverError('An unexpected error has occurred');
|
||||
} catch (\Error $e) {
|
||||
// This is also unexpected because 32 is a reasonable integer.
|
||||
throw OAuthServerException::serverError('An unexpected error has occurred');
|
||||
} catch (\Exception $e) {
|
||||
// If you get this message, the CSPRNG failed hard.
|
||||
throw OAuthServerException::serverError('Could not generate a random string. Is our OS secure?');
|
||||
}
|
||||
// @codeCoverageIgnoreEnd
|
||||
|
||||
return bin2hex($string);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user