Exponential Basic 2.4.0.1 Exponential Basic CMS — PHP Class Reference

oauth_required.php
Go to the documentation of this file.
1 <?php
15 class ezpOauthRequired implements ezcMvcResultStatusObject
16 {
17 const DEFAULT_REALM = 'Exponential REST';
18
24 public $realm;
25
31 public $errorType;
32
38 public $errorMessage;
39
40 public function __construct( $realm, $errorType = null, $errorMessage = null )
41 {
42 $this->realm = $realm;
43 $this->errorType = $errorType;
44 $this->errorMessage = $errorMessage;
45 }
46
52 public function process( ezcMvcResponseWriter $writer )
53 {
54 if ( $writer instanceof ezcMvcHttpResponseWriter )
55 {
56 $writer->headers['HTTP/1.1 ' . ezpOauthErrorType::httpCodeforError( $this->errorType )] = "";
57 $writer->headers['WWW-Authenticate'] = "OAuth realm='{$this->realm}'{$this->createErrorString()}";
58 }
59
60 if ( isset( $this->errorType) )
61 {
62 $writer->headers['Content-Type'] = 'application/json; charset=UTF-8';
63 $body = array( 'error' => $this->errorType );
64
65 if ( isset( $this->errorMessage ) )
66 $body['error_description'] = $this->errorMessage;
67
68 $writer->response->body = json_encode( $body );
69 }
70 }
71
77 protected function createErrorString()
78 {
79 $str = '';
80 if ( $this->errorType !== null )
81 {
82 $str .= ", error='{$this->errorType}'";
83 }
84
85 if ( $this->errorMessage !== null )
86 {
87 $str .= ", error_description='{$this->errorMessage}'";
88 }
89 return $str;
90 }
91 }
92 ?>
ezpOauthErrorType\httpCodeforError
static httpCodeforError( $error)
Definition: outh_error_type.php:19
ezpOauthRequired
Definition: oauth_required.php:16
ezpOauthRequired\$errorMessage
$errorMessage
Definition: oauth_required.php:38
ezpOauthRequired\DEFAULT_REALM
const DEFAULT_REALM
Definition: oauth_required.php:17
ezpOauthRequired\createErrorString
createErrorString()
Definition: oauth_required.php:77
ezpOauthRequired\$errorType
$errorType
Definition: oauth_required.php:31
ezpOauthRequired\__construct
__construct( $realm, $errorType=null, $errorMessage=null)
Definition: oauth_required.php:40
ezpOauthRequired\process
process(ezcMvcResponseWriter $writer)
Definition: oauth_required.php:52
ezpOauthRequired\$realm
$realm
Definition: oauth_required.php:24
$str
$str
Definition: ezarticle/modules/content.php:30
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.