source: sandbox/2.4.1-3/prototype/library/oauth2/lib/OAuth2AuthenticateException.php @ 6351

Revision 6351, 1.6 KB checked in by gustavo, 12 years ago (diff)

Ticket #2768 - Melhorias na inserção de destinatários na criacao de mensagem

  • Property svn:executable set to *
Line 
1<?php
2
3/**
4 * Send an error header with the given realm and an error, if provided.
5 * Suitable for the bearer token type.
6 *
7 * @see http://tools.ietf.org/html/draft-ietf-oauth-v2-bearer-04#section-2.4
8 *
9 * @ingroup oauth2_error
10 */
11class OAuth2AuthenticateException extends OAuth2ServerException {
12       
13        protected $header;
14
15        /**
16         *
17         * @param $http_status_code
18         * HTTP status code message as predefined.
19         * @param $error
20         * The "error" attribute is used to provide the client with the reason
21         * why the access request was declined.
22         * @param $error_description
23         * (optional) The "error_description" attribute provides a human-readable text
24         * containing additional information, used to assist in the understanding
25         * and resolution of the error occurred.
26         * @param $scope
27         * A space-delimited list of scope values indicating the required scope
28         * of the access token for accessing the requested resource.
29         */
30        public function __construct($httpCode, $tokenType, $realm, $error, $error_description = NULL, $scope = NULL) {
31                parent::__construct($httpCode, $error, $error_description);
32               
33                if ($scope) {
34                        $this->errorData['scope'] = $scope;
35                }
36               
37                // Build header
38                $this->header = sprintf('WWW-Authenticate: %s realm="%s"', ucwords($tokenType), $realm);
39                foreach ( $this->errorData as $key => $value ) {
40                        $this->header .= ", $key=\"$value\"";
41                }
42        }
43
44        /**
45         * Send out HTTP headers for JSON.
46         *
47         * @see http://tools.ietf.org/html/draft-ietf-oauth-v2-20#section-5.1
48         * @see http://tools.ietf.org/html/draft-ietf-oauth-v2-20#section-5.2
49         *
50         * @ingroup oauth2_section_5
51         */
52        protected function sendHeaders() {
53                header($this->header);
54        }
55}
Note: See TracBrowser for help on using the repository browser.