mirror of
https://github.com/elyby/oauth2-server.git
synced 2025-05-31 14:12:07 +05:30
Merge branch 'v4.0.0-WIP' into develop
Conflicts: .gitignore .travis.yml README.md composer.json phpunit.xml sql/mysql.sql src/League/OAuth2/Server/Grant/RefreshToken.php src/League/OAuth2/Server/Resource.php src/League/OAuth2/Server/Storage/SessionInterface.php src/League/OAuth2/Server/Util/Request.php src/Util/KeyAlgorithm/DefaultAlgorithm.php tests/resource/ResourceServerTest.php tests/util/RedirectUriTest.php tests/util/RequestTest.php tests/util/SecureKeyTest.php
This commit is contained in:
46
src/Util/KeyAlgorithm/DefaultAlgorithm.php
Normal file
46
src/Util/KeyAlgorithm/DefaultAlgorithm.php
Normal file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
/**
|
||||
* OAuth 2.0 Secure key generator
|
||||
*
|
||||
* @package league/oauth2-server
|
||||
* @author Alex Bilbie <hello@alexbilbie.com>
|
||||
* @copyright Copyright (c) Alex Bilbie
|
||||
* @license http://mit-license.org/
|
||||
* @link https://github.com/thephpleague/oauth2-server
|
||||
*/
|
||||
|
||||
namespace League\OAuth2\Server\Util\KeyAlgorithm;
|
||||
|
||||
class DefaultAlgorithm implements KeyAlgorithmInterface
|
||||
{
|
||||
protected static $algorithm;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function generate($len = 40)
|
||||
{
|
||||
return self::getAlgorithm()->make($len);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param KeyAlgorithmInterface $algorithm
|
||||
*/
|
||||
public static function setAlgorithm(KeyAlgorithmInterface $algorithm)
|
||||
{
|
||||
self::$algorithm = $algorithm;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return KeyAlgorithmInterface
|
||||
*/
|
||||
public static function getAlgorithm()
|
||||
{
|
||||
if (!self::$algorithm) {
|
||||
|
||||
self::$algorithm = new DefaultAlgorithm();
|
||||
}
|
||||
|
||||
return self::$algorithm;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user