/**
  * @param $redirect_uri
  * An absolute URI to which the authorization server will redirect the
  * user-agent to when the end-user authorization step is completed.
  * @param $error
  * A single error code as described in Section 4.1.2.1
  * @param $error_description
  * (optional) A human-readable text providing additional information,
  * used to assist in the understanding and resolution of the error
  * occurred.
  * @param $state
  * (optional) REQUIRED if the "state" parameter was present in the client
  * authorization request. Set to the exact value received from the client.
  *
  * @see http://tools.ietf.org/html/draft-ietf-oauth-v2-20#section-4.1.2.1
  *
  * @ingroup oauth2_error
  */
 public function __construct($redirect_uri, $error, $error_description = null, $state = null)
 {
     parent::__construct(OAuth2::HTTP_FOUND, $error, $error_description);
     $this->redirectUri = $redirect_uri;
     if ($state) {
         $this->errorData['state'] = $state;
     }
 }
 /**
  * @param string $redirectUri      An absolute URI to which the authorization server will redirect the user-agent to when the end-user authorization step is completed.
  * @param string $error            A single error code as described in Section 4.1.2.1
  * @param string $errorDescription (optional) A human-readable text providing additional information, used to assist in the understanding and resolution of the error occurred.
  * @param string $state            (optional) REQUIRED if the "state" parameter was present in the client authorization request. Set to the exact value received from the client.
  *
  * @see     http://tools.ietf.org/html/draft-ietf-oauth-v2-20#section-4.1.2.1
  *
  * @ingroup oauth2_error
  */
 public function __construct($redirectUri, $error, $errorDescription = null, $state = null, $method = OAuth2::TRANSPORT_QUERY)
 {
     parent::__construct(OAuth2::HTTP_FOUND, $error, $errorDescription);
     $this->method = $method;
     $this->redirectUri = $redirectUri;
     if ($state) {
         $this->errorData['state'] = $state;
     }
 }
 /**
  *
  * @param $http_status_code
  * HTTP status code message as predefined.
  * @param $error
  * The "error" attribute is used to provide the client with the reason
  * why the access request was declined.
  * @param $error_description
  * (optional) The "error_description" attribute provides a human-readable text
  * containing additional information, used to assist in the understanding
  * and resolution of the error occurred.
  * @param $scope
  * A space-delimited list of scope values indicating the required scope
  * of the access token for accessing the requested resource.
  */
 public function __construct($httpCode, $tokenType, $realm, $error, $error_description = null, $scope = null)
 {
     parent::__construct($httpCode, $error, $error_description);
     if ($scope) {
         $this->errorData['scope'] = $scope;
     }
     // Build header
     $this->header = sprintf('WWW-Authenticate: %s realm="%s"', ucwords($tokenType), $realm);
     foreach ($this->errorData as $key => $value) {
         $this->header .= ", {$key}=\"{$value}\"";
     }
 }
 /**
  * Blackhold callback
  *
  * OAuth requests will fail postValidation, so rather than disabling it completely
  * if the request does fail this check we store it in $this->blackHoled and then
  * when handling our forms we can use $this->validateRequest() to check if there
  * were any errors and handle them with an exception.
  * Requests that fail for reasons other than postValidation are handled here immediately
  * using the best guess for if it was a form or OAuth
  *
  * @param string $type
  */
 public function blackHole($type)
 {
     $this->blackHoled = $type;
     if ($type != 'auth') {
         if (isset($this->request->data['_Token'])) {
             //Probably our form
             $this->validateRequest();
         } else {
             //Probably OAuth
             $e = new OAuth2ServerException(OAuth2::HTTP_BAD_REQUEST, OAuth2::ERROR_INVALID_REQUEST, 'Request Invalid.');
             $e->sendHttpResponse();
         }
     }
 }
 /**
  * @return array
  */
 public function getResponseHeaders()
 {
     return $this->header + parent::getResponseHeaders();
 }