29 $this->config = array_merge(array(
30 'www_realm' =>
'Service',
44 if (is_null($token)) {
53 if ($scope && (!isset($token[
"scope"]) || !$token[
"scope"] || !$this->scopeUtil->checkScope($scope, $token[
"scope"]))) {
54 $response->
setError(403,
'insufficient_scope',
'The request requires higher privileges than provided by the access token');
56 'WWW-Authenticate' => sprintf(
'%s realm="%s", scope="%s", error="%s", error_description="%s"',
57 $this->tokenType->getTokenType(),
58 $this->config[
'www_realm'],
69 $this->token = $token;
77 if ($token_param = $this->tokenType->getAccessTokenParameter($request, $response)) {
81 if (!$token = $this->tokenStorage->getAccessToken($token_param)) {
82 $response->
setError(401,
'invalid_token',
'The access token provided is invalid');
83 } elseif (!isset($token[
"expires"]) || !isset($token[
"client_id"])) {
84 $response->
setError(401,
'malformed_token',
'Malformed token (missing "expires")');
85 } elseif (
time() > $token[
"expires"]) {
86 $response->
setError(401,
'expired_token',
'The access token provided has expired');
92 $authHeader = sprintf(
'%s realm="%s"', $this->tokenType->getTokenType(), $this->config[
'www_realm']);
95 $authHeader = sprintf(
'%s, error="%s"', $authHeader, $error);
96 if ($error_description = $response->
getParameter(
'error_description')) {
97 $authHeader = sprintf(
'%s, error_description="%s"', $authHeader, $error_description);
101 $response->
addHttpHeaders(array(
'WWW-Authenticate' => $authHeader));