From be9bd76f3520ed0e29a3efaf4745a0222f503c54 Mon Sep 17 00:00:00 2001 From: Alex Bilbie Date: Sat, 9 Apr 2016 15:09:13 +0100 Subject: [PATCH] Added AccessTokenTrait --- src/Entities/Traits/AccessTokenTrait.php | 32 ++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 src/Entities/Traits/AccessTokenTrait.php diff --git a/src/Entities/Traits/AccessTokenTrait.php b/src/Entities/Traits/AccessTokenTrait.php new file mode 100644 index 00000000..17a8f7d4 --- /dev/null +++ b/src/Entities/Traits/AccessTokenTrait.php @@ -0,0 +1,32 @@ +setAudience($this->getClient()->getIdentifier()) + ->setId($this->getIdentifier(), true) + ->setIssuedAt(time()) + ->setNotBefore(time()) + ->setExpiration($this->getExpiryDateTime()->getTimestamp()) + ->setSubject($this->getUserIdentifier()) + ->set('scopes', $this->getScopes()) + ->sign(new Sha256(), new Key($privateKey->getKeyPath(), $privateKey->getPassPhrase())) + ->getToken(); + } +}