class AccessTokenEntity in Simple OAuth (OAuth2) & OpenID Connect 5.x
Same name and namespace in other branches
- 8.4 src/Entities/AccessTokenEntity.php \Drupal\simple_oauth\Entities\AccessTokenEntity
- 8.2 src/Entities/AccessTokenEntity.php \Drupal\simple_oauth\Entities\AccessTokenEntity
- 8.3 src/Entities/AccessTokenEntity.php \Drupal\simple_oauth\Entities\AccessTokenEntity
Hierarchy
- class \Drupal\simple_oauth\Entities\AccessTokenEntity implements \League\OAuth2\Server\Entities\AccessTokenEntityInterface uses \League\OAuth2\Server\Entities\Traits\AccessTokenTrait
Expanded class hierarchy of AccessTokenEntity
1 file declares its use of AccessTokenEntity
- AccessTokenRepository.php in src/
Repositories/ AccessTokenRepository.php
File
- src/
Entities/ AccessTokenEntity.php, line 14
Namespace
Drupal\simple_oauth\EntitiesView source
class AccessTokenEntity implements AccessTokenEntityInterface {
use AccessTokenTrait, TokenEntityTrait, EntityTrait;
/**
* {@inheritdoc}
*/
public function convertToJWT(CryptKey $privateKey) {
$private_claims = [];
\Drupal::moduleHandler()
->alter('simple_oauth_private_claims', $private_claims, $this);
if (!is_array($private_claims)) {
$message = 'An implementation of hook_simple_oauth_private_claims_alter ';
$message .= 'returns an invalid $private_claims value. $private_claims ';
$message .= 'must be an array.';
throw new \InvalidArgumentException($message);
}
$builder = (new Builder())
->setAudience($this
->getClient()
->getIdentifier())
->setId($this
->getIdentifier(), TRUE)
->setIssuedAt(time())
->setNotBefore(time())
->setExpiration($this
->getExpiryDateTime()
->getTimestamp())
->setSubject($this
->getUserIdentifier())
->set('scopes', $this
->getScopes());
foreach ($private_claims as $claim_name => $value) {
$builder
->set($claim_name, $value);
}
$key = new Key($privateKey
->getKeyPath(), $privateKey
->getPassPhrase());
$token = $builder
->sign(new Sha256(), $key)
->getToken();
return $token;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
AccessTokenEntity:: |
public | function |