2015-11-09 20:35:30 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Pony.fm - A community for pony fan music.
|
|
|
|
* Copyright (C) 2015 Peter Deltchev
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Affero General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Affero General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Affero General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace Poniverse;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Class AccessTokenInfo
|
|
|
|
*
|
|
|
|
* A container for the fields in the draft OAuth Token Introspection proposal.
|
|
|
|
*
|
|
|
|
* @link https://tools.ietf.org/html/draft-richer-oauth-introspection-06
|
|
|
|
* @package Poniverse
|
|
|
|
*/
|
2016-09-30 00:26:31 +02:00
|
|
|
class AccessTokenInfo
|
|
|
|
{
|
2015-11-09 20:35:30 +01:00
|
|
|
protected $token;
|
|
|
|
|
|
|
|
protected $isActive;
|
|
|
|
protected $expiresAt;
|
|
|
|
protected $issuedAt;
|
|
|
|
protected $scopes;
|
|
|
|
protected $clientId;
|
|
|
|
protected $sub;
|
|
|
|
protected $userId;
|
|
|
|
protected $intendedAudience;
|
|
|
|
protected $issuer;
|
|
|
|
protected $tokenType;
|
|
|
|
|
2016-09-30 00:26:31 +02:00
|
|
|
public function __construct($accessToken)
|
|
|
|
{
|
2015-11-09 20:35:30 +01:00
|
|
|
$this->token = $accessToken;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return mixed
|
|
|
|
*/
|
2016-09-30 00:26:31 +02:00
|
|
|
public function getToken()
|
|
|
|
{
|
2015-11-09 20:35:30 +01:00
|
|
|
return $this->token;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return bool
|
|
|
|
*/
|
2016-09-30 00:26:31 +02:00
|
|
|
public function getIsActive()
|
|
|
|
{
|
2015-11-09 20:35:30 +01:00
|
|
|
return $this->isActive;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param bool $isActive
|
|
|
|
* @return AccessTokenInfo
|
|
|
|
*/
|
2016-09-30 00:26:31 +02:00
|
|
|
public function setIsActive($isActive)
|
|
|
|
{
|
2015-11-09 20:35:30 +01:00
|
|
|
$this->isActive = $isActive;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return mixed
|
|
|
|
*/
|
2016-09-30 00:26:31 +02:00
|
|
|
public function getExpiresAt()
|
|
|
|
{
|
2015-11-09 20:35:30 +01:00
|
|
|
return $this->expiresAt;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param mixed $expiresAt
|
|
|
|
* @return AccessTokenInfo
|
|
|
|
*/
|
2016-09-30 00:26:31 +02:00
|
|
|
public function setExpiresAt($expiresAt)
|
|
|
|
{
|
2015-11-09 20:35:30 +01:00
|
|
|
$this->expiresAt = $expiresAt;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return mixed
|
|
|
|
*/
|
2016-09-30 00:26:31 +02:00
|
|
|
public function getIssuedAt()
|
|
|
|
{
|
2015-11-09 20:35:30 +01:00
|
|
|
return $this->issuedAt;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param mixed $issuedAt
|
|
|
|
* @return AccessTokenInfo
|
|
|
|
*/
|
2016-09-30 00:26:31 +02:00
|
|
|
public function setIssuedAt($issuedAt)
|
|
|
|
{
|
2015-11-09 20:35:30 +01:00
|
|
|
$this->issuedAt = $issuedAt;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return array
|
|
|
|
*/
|
2016-09-30 00:26:31 +02:00
|
|
|
public function getScopes()
|
|
|
|
{
|
2015-11-09 20:35:30 +01:00
|
|
|
return $this->scopes;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param array|string $scopes
|
|
|
|
* @return AccessTokenInfo
|
|
|
|
*/
|
2016-09-30 00:26:31 +02:00
|
|
|
public function setScopes($scopes)
|
|
|
|
{
|
2015-11-09 20:35:30 +01:00
|
|
|
if (is_array($scopes)) {
|
|
|
|
$this->scopes = $scopes;
|
|
|
|
} else {
|
|
|
|
$this->scopes = mb_split(' ', $scopes);
|
|
|
|
}
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return mixed
|
|
|
|
*/
|
2016-09-30 00:26:31 +02:00
|
|
|
public function getClientId()
|
|
|
|
{
|
2015-11-09 20:35:30 +01:00
|
|
|
return $this->clientId;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param mixed $clientId
|
|
|
|
* @return AccessTokenInfo
|
|
|
|
*/
|
2016-09-30 00:26:31 +02:00
|
|
|
public function setClientId($clientId)
|
|
|
|
{
|
2015-11-09 20:35:30 +01:00
|
|
|
$this->clientId = $clientId;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return mixed
|
|
|
|
*/
|
2016-09-30 00:26:31 +02:00
|
|
|
public function getSub()
|
|
|
|
{
|
2015-11-09 20:35:30 +01:00
|
|
|
return $this->sub;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param mixed $sub
|
|
|
|
* @return AccessTokenInfo
|
|
|
|
*/
|
2016-09-30 00:26:31 +02:00
|
|
|
public function setSub($sub)
|
|
|
|
{
|
2015-11-09 20:35:30 +01:00
|
|
|
$this->sub = $sub;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return mixed
|
|
|
|
*/
|
2016-09-30 00:26:31 +02:00
|
|
|
public function getUserId()
|
|
|
|
{
|
2015-11-09 20:35:30 +01:00
|
|
|
return $this->userId;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param mixed $userId
|
|
|
|
* @return AccessTokenInfo
|
|
|
|
*/
|
2016-09-30 00:26:31 +02:00
|
|
|
public function setUserId($userId)
|
|
|
|
{
|
2015-11-09 20:35:30 +01:00
|
|
|
$this->userId = $userId;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return mixed
|
|
|
|
*/
|
2016-09-30 00:26:31 +02:00
|
|
|
public function getIntendedAudience()
|
|
|
|
{
|
2015-11-09 20:35:30 +01:00
|
|
|
return $this->intendedAudience;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param mixed $intendedAudience
|
|
|
|
* @return AccessTokenInfo
|
|
|
|
*/
|
2016-09-30 00:26:31 +02:00
|
|
|
public function setIntendedAudience($intendedAudience)
|
|
|
|
{
|
2015-11-09 20:35:30 +01:00
|
|
|
$this->intendedAudience = $intendedAudience;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return mixed
|
|
|
|
*/
|
2016-09-30 00:26:31 +02:00
|
|
|
public function getIssuer()
|
|
|
|
{
|
2015-11-09 20:35:30 +01:00
|
|
|
return $this->issuer;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param mixed $issuer
|
|
|
|
* @return AccessTokenInfo
|
|
|
|
*/
|
2016-09-30 00:26:31 +02:00
|
|
|
public function setIssuer($issuer)
|
|
|
|
{
|
2015-11-09 20:35:30 +01:00
|
|
|
$this->issuer = $issuer;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return mixed
|
|
|
|
*/
|
2016-09-30 00:26:31 +02:00
|
|
|
public function getTokenType()
|
|
|
|
{
|
2015-11-09 20:35:30 +01:00
|
|
|
return $this->tokenType;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param mixed $tokenType
|
|
|
|
* @return AccessTokenInfo
|
|
|
|
*/
|
2016-09-30 00:26:31 +02:00
|
|
|
public function setTokenType($tokenType)
|
|
|
|
{
|
2015-11-09 20:35:30 +01:00
|
|
|
$this->tokenType = $tokenType;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
}
|