diff --git a/src/Entities/AccessTokenEntity.php b/src/Entities/AccessTokenEntity.php new file mode 100644 index 00000000..830c13e1 --- /dev/null +++ b/src/Entities/AccessTokenEntity.php @@ -0,0 +1,11 @@ +secret; + } + + /** + * Set the client's secret + * @param string $secret + * @return string + */ + public function setSecret($secret) + { + $this->secret = $secret; + } + + /** + * Get the client's name + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * Set the client's name + * @param string $name + */ + public function setName($name) + { + $this->name = $name; + } +} \ No newline at end of file diff --git a/src/Entities/Traits/EntityTrait.php b/src/Entities/Traits/EntityTrait.php new file mode 100644 index 00000000..527506ac --- /dev/null +++ b/src/Entities/Traits/EntityTrait.php @@ -0,0 +1,26 @@ +identifier; + } + + /** + * @param mixed $identifier + */ + public function setIdentifier($identifier) + { + $this->identifier = $identifier; + } +} diff --git a/src/Entities/Traits/RefreshTokenTrait.php b/src/Entities/Traits/RefreshTokenTrait.php new file mode 100644 index 00000000..06f81808 --- /dev/null +++ b/src/Entities/Traits/RefreshTokenTrait.php @@ -0,0 +1,30 @@ +originalAccessToken = $accessToken; + } + + /** + * Get the access token that the refresh token was originally associated with + * @return \League\OAuth2\Server\Entities\Interfaces\AccessTokenEntityInterface + */ + public function getOriginalAccessToken() + { + return $this->originalAccessToken; + } +} \ No newline at end of file diff --git a/src/Entities/Traits/TokenEntityTrait.php b/src/Entities/Traits/TokenEntityTrait.php new file mode 100644 index 00000000..bcd756bf --- /dev/null +++ b/src/Entities/Traits/TokenEntityTrait.php @@ -0,0 +1,126 @@ +scopes[$scope->getIdentifier()] = $scope; + } + + /** + * Get an associated scope by the scope's identifier + * @param string $identifier + * @return ScopeEntityInterface|null The scope or null if not found + */ + public function getScopeWithIdentifier($identifier) + { + return (isset($this->scopes[$identifier])) ? $this->scopes[$identifier] : null; + } + + /** + * Return an array of scopes associated with the token + * @return ScopeEntityInterface[] + */ + public function getScopes() + { + return $this->scopes; + } + + /** + * Get the token's expiry date time + * @return \DateTime + */ + public function getExpiryDateTime() + { + return $this->expiryDateTime; + } + + /** + * Set the date time when the token expires + * @param \DateTime $dateTime + */ + public function setExpiryDateTime(\DateTime $dateTime) + { + $this->expiryDateTime = $dateTime; + } + + /** + * Set the token's owner + * @param string $type The type of the owner (e.g. "user", "client" or something more specific) + * @param string|int $identifier The identifier of the owner + */ + public function setOwner($type, $identifier) + { + $this->ownerType = $type; + $this->ownerIdentifier = $identifier; + } + + /** + * Get the token owner's type + * @return string The type of owner (e.g. "user", "client" or something more specific) + */ + public function getOwnerType() + { + return $this->ownerType; + } + + /** + * Get the token owner's identifier + * @return string|int + */ + public function getOwnerIdentifier() + { + return $this->ownerIdentifier; + } + + /** + * Get the client that the token was issued to + * @return ClientEntityInterface + */ + public function getClient() + { + return $this->client; + } + + /** + * Set the client that the token was issued to + * @param \League\OAuth2\Server\Entities\Interfaces\ClientEntityInterface $client + */ + public function setClient(ClientEntityInterface $client) + { + $this->client = $client; + } +} \ No newline at end of file