diff --git a/src/League/OAuth2/Server/AccessToken.php b/src/League/OAuth2/Server/AccessToken.php deleted file mode 100644 index 692636a2..00000000 --- a/src/League/OAuth2/Server/AccessToken.php +++ /dev/null @@ -1,118 +0,0 @@ -storage = $storage; - $this->scopes = new ParameterBag(); - } - - public function setSession(Session $session) - { - $this->session = $session; - } - - public function getSession() - { - return $this->session; - } - - public function setSessionStorage(SessionStorageInterface $sessionStorage) - { - $this->sessionStorage = $sessionStorage; - } - - public function getSessionStorage() - { - return $this->sessionStorage; - } - - public function setTTL($ttl = 0) - { - $this->ttl = $ttl; - } - - public function getTTL() - { - return $this->ttl; - } - - public function setTimestamp($timestamp = 0) - { - $this->timestamp = $timestamp; - } - - public function getTimestamp() - { - return $this->timestamp; - } - - public function setId($id = null) - { - $this->id = ($id !== null) ? $id : SecureKey::make(); - } - - public function getId() - { - return $this->id; - } - - public function associateScope($scope, $details = []) - { - if (!$this->scopes->has($scope)) { - $this->scopes->set($scope, []); - } - - return $this; - } - - public function hasScope($scope) - { - return $this->scopes->has($scope); - } - - public function getScopes() - { - return $this->scopes->all(); - } -} diff --git a/src/League/OAuth2/Server/Session.php b/src/League/OAuth2/Server/Session.php deleted file mode 100644 index bf7b0063..00000000 --- a/src/League/OAuth2/Server/Session.php +++ /dev/null @@ -1,134 +0,0 @@ -storage = $storage; - $this->scopes = new ParameterBag(); - } - - public function associateScope($scope) - { - if (!$this->scopes->has($scope)) { - $this->scopes->set($scope, 1); - } - - return $this; - } - - public function hasScope($scope) - { - return $this->scopes->has($scope); - } - - public function associateAccessToken(AccessToken $accessToken) - { - $this->accessToken = $accessToken; - } - - public function associateRefreshToken(RefreshToken $refreshToken) - { - $this->refreshToken = $refreshToken; - } - - public function associateAuthCode(AuthCode $authCode) - { - $this->authCode = $authCode; - } - - /** - * Associate a client - * @param League\OAuth2\Server\Client $client The client - * @return self - */ - public function associateClient(Client $client) - { - $this->client = $client; - - return $this; - } - - /** - * Set client - * @param League\OAuth2\Server\Client - */ - public function setClient(Client $client) - { - $this->client = $client; - } - - /** - * Return client - * @return League\OAuth2\Server\Client - */ - public function getClient() - { - return $this->client; - } - - /** - * Set the session owner - * @param string $type The type of the owner (e.g. user, app) - * @param string $id The ID of the owner - * @return self - */ - public function setOwner($type, $id) - { - $this->ownerType = $type; - $this->ownerId = $id; - - return $this; - } - - public function getOwnerId() - { - return $this->ownerId; - } - - public function getOwnerType() - { - return $this->ownerType; - } - - public function getById($id) - { - $params = $this->storage->getSession($id); - - if ($params === null) { - throw new OAuth2Exception('Unrecognised session ID - ' . $id); - } - - $this->id = $params['session_id']; - $this->setOwner($params['owner_type'], $params['owner_id']); - } -} diff --git a/src/League/OAuth2/Server/Util/Request.php b/src/League/OAuth2/Server/Util/Request.php deleted file mode 100644 index b2f5752c..00000000 --- a/src/League/OAuth2/Server/Util/Request.php +++ /dev/null @@ -1,146 +0,0 @@ - - * @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\Util; - -use OutOfBoundsException; -use InvalidMethodCallException; -use InvalidArgumentException; - -class Request implements RequestInterface -{ - protected $get = array(); - protected $post = array(); - protected $cookies = array(); - protected $files = array(); - protected $server = array(); - protected $headers = array(); - - public static function buildFromGlobals() - { - return new static($_GET, $_POST, $_COOKIE, $_FILES, $_SERVER); - } - - public function __construct(array $get = array(), array $post = array(), array $cookies = array(), array $files = array(), array $server = array(), $headers = array()) - { - $this->get = $get; - $this->post = $post; - $this->cookies = $cookies; - $this->files = $files; - $this->server = $server; - - if (empty($headers)) { - $this->headers = $this->readHeaders(); - } else { - $this->headers = $this->normalizeHeaders($headers); - } - } - - public function get($index = null, $default = null) - { - return $this->getPropertyValue('get', $index, $default); - } - - public function post($index = null, $default = null) - { - return $this->getPropertyValue('post', $index, $default); - } - - public function file($index = null, $default = null) - { - return $this->getPropertyValue('files', $index, $default); - } - - public function cookie($index = null, $default = null) - { - return $this->getPropertyValue('cookies', $index, $default); - } - - public function server($index = null, $default = null) - { - return $this->getPropertyValue('server', $index, $default); - } - - public function header($index = null, $default = null) - { - return $this->getPropertyValue('headers', $index, $default); - } - - protected function readHeaders() - { - if (function_exists('getallheaders')) { - // @codeCoverageIgnoreStart - $headers = getallheaders(); - } else { - // @codeCoverageIgnoreEnd - $headers = array(); - foreach ($this->server() as $name => $value) { - if (substr($name, 0, 5) == 'HTTP_') { - $name = str_replace(' ', '-', ucwords(strtolower(str_replace('_', ' ', substr($name, 5))))); - $headers[$name] = $value; - } - } - } - - return $this->normalizeHeaders($headers); - } - - protected function getPropertyValue($property, $index = null, $default = null) - { - if ( ! isset($this->{$property})) { - throw new InvalidArgumentException("Property '$property' does not exist."); - } - if (is_null($index)) { - return $this->{$property}; - } - - if ( ! array_key_exists($index, $this->{$property})) { - return $default; - } - - return $this->{$property}[$index]; - } - - /** - * Takes all of the headers and normalizes them in a canonical form. - * - * @param array $headers The request headers. - * @return array An arry of headers with the header name normalized - */ - protected function normalizeHeaders(array $headers) - { - $normalized = array(); - foreach ($headers as $key => $value) { - $normalized[ucfirst($this->normalizeKey($key))] = $value; - } - - return $normalized; - } - - /** - * Transform header name into canonical form - * - * Taken from the Slim codebase... - * - * @param string $key - * @return string - */ - protected function normalizeKey($key) - { - $key = strtolower($key); - $key = str_replace(array('-', '_'), ' ', $key); - $key = preg_replace('#^http #', '', $key); - $key = ucwords($key); - $key = str_replace(' ', '-', $key); - - return $key; - } -} \ No newline at end of file