2013-12-24 22:31:11 +05:30
|
|
|
<?php
|
2014-01-08 21:45:29 +05:30
|
|
|
/**
|
|
|
|
* OAuth 2.0 Refresh token entity
|
|
|
|
*
|
|
|
|
* @package league/oauth2-server
|
|
|
|
* @author Alex Bilbie <hello@alexbilbie.com>
|
|
|
|
* @copyright Copyright (c) PHP League of Extraordinary Packages
|
|
|
|
* @license http://mit-license.org/
|
|
|
|
* @link http://github.com/php-loep/oauth2-server
|
|
|
|
*/
|
2013-12-24 22:31:11 +05:30
|
|
|
|
|
|
|
namespace League\OAuth2\Server\Entities;
|
|
|
|
|
|
|
|
use League\OAuth2\Server\Storage\SessionStorageInterface;
|
|
|
|
use League\OAuth2\Server\Storage\RefreshTokenInterface;
|
|
|
|
use League\OAuth2\Server\Util\SecureKey;
|
|
|
|
use League\OAuth2\Server\Exception\InvalidAccessTokenException;
|
2014-01-08 21:45:29 +05:30
|
|
|
use Symfony\Component\HttpFoundation\ParameterBag;
|
2013-12-24 22:31:11 +05:30
|
|
|
|
2014-01-08 21:45:29 +05:30
|
|
|
/**
|
|
|
|
* Refresh token entity class
|
|
|
|
*/
|
2013-12-24 22:31:11 +05:30
|
|
|
class RefreshToken extends AbstractToken
|
|
|
|
{
|
|
|
|
/**
|
2014-01-08 21:45:29 +05:30
|
|
|
* Access token associated to refresh token
|
|
|
|
* @var \League\OAuth2\Server\Entities\AccessToken
|
2013-12-24 22:31:11 +05:30
|
|
|
*/
|
2014-01-08 21:45:29 +05:30
|
|
|
protected $accessToken;
|
2013-12-24 22:31:11 +05:30
|
|
|
|
|
|
|
/**
|
|
|
|
* Associate an access token
|
2014-01-08 21:45:29 +05:30
|
|
|
* @param \League\OAuth2\Server\Entities\AccessToken $accessToken
|
2013-12-24 22:31:11 +05:30
|
|
|
* @return self
|
|
|
|
*/
|
|
|
|
public function setAccessToken(AccessToken $accessToken)
|
|
|
|
{
|
|
|
|
$this->accessToken = $accessToken;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return access token
|
|
|
|
* @return AccessToken
|
|
|
|
*/
|
|
|
|
public function getAccessToken()
|
|
|
|
{
|
|
|
|
return $this->accessToken;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2014-01-08 21:45:29 +05:30
|
|
|
* {@inheritdoc}
|
2013-12-24 22:31:11 +05:30
|
|
|
*/
|
|
|
|
public function save()
|
|
|
|
{
|
2014-01-08 21:45:29 +05:30
|
|
|
$this->server->getStorage('refresh_token')->createAccessToken(
|
2013-12-31 21:05:51 +05:30
|
|
|
$this->getToken(),
|
2013-12-24 22:31:11 +05:30
|
|
|
$this->getExpireTime(),
|
2013-12-31 21:05:51 +05:30
|
|
|
$this->getAccessToken()->getToken()
|
2013-12-24 22:31:11 +05:30
|
|
|
);
|
|
|
|
|
|
|
|
// Associate the scope with the token
|
|
|
|
foreach ($this->getScopes() as $scope) {
|
2014-01-08 21:45:29 +05:30
|
|
|
$this->server->getStorage('refresh_token')->associateScope($this->getToken(), $scope->getId());
|
2013-12-31 21:05:51 +05:30
|
|
|
}
|
2013-12-24 22:31:11 +05:30
|
|
|
}
|
|
|
|
}
|