Rolling back the patch from SHINDIG-966, was breaking makeRequest
[shindig.git] / php / src / gadgets / oauth / OAuthRequestParams.php
blobc83eea967d6b826e8ad4712fae170413aaa49968
1 <?php
2 /**
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
21 /**
22 * Bundles information about a proxy request that requires OAuth
24 class OAuthRequestParams {
25 public static $SERVICE_PARAM = "OAUTH_SERVICE_NAME";
26 public static $TOKEN_PARAM = "OAUTH_TOKEN_NAME";
27 public static $REQUEST_TOKEN_PARAM = "OAUTH_REQUEST_TOKEN";
28 public static $REQUEST_TOKEN_SECRET_PARAM = "OAUTH_REQUEST_TOKEN_SECRET";
29 public static $CLIENT_STATE_PARAM = "oauthState";
30 public static $BYPASS_SPEC_CACHE_PARAM = "bypassSpecCache";
31 protected $serviceName;
32 protected $tokenName;
33 protected $requestToken;
34 protected $requestTokenSecret;
35 protected $origClientState;
36 protected $bypassSpecCache;
38 public function __construct() {
39 $this->serviceName = $this->getParam(self::$SERVICE_PARAM, "");
40 $this->tokenName = $this->getParam(self::$TOKEN_PARAM, "");
41 $this->requestToken = $this->getParam(self::$REQUEST_TOKEN_PARAM, null);
42 $this->requestTokenSecret = $this->getParam(self::$REQUEST_TOKEN_SECRET_PARAM, null);
43 $this->origClientState = $this->getParam(self::$CLIENT_STATE_PARAM, null);
44 $this->bypassSpecCache = $this->parseBypassSpecCacheParam();
47 private function getParam($name, $def) {
48 $val = null;
49 if (isset($_REQUEST[$name])) {
50 $val = $_REQUEST[$name];
52 if ($val == null) {
53 $val = $def;
55 return $val;
58 public function getBypassSpecCache() {
59 return $this->bypassSpecCache;
62 public function getRequestToken() {
63 return $this->requestToken;
66 public function getRequestTokenSecret() {
67 return $this->requestTokenSecret;
70 public static function parseBypassSpecCacheParam() {
71 if (isset($_REQUEST[self::$BYPASS_SPEC_CACHE_PARAM])) {
72 return "1" == $_REQUEST[self::$BYPASS_SPEC_CACHE_PARAM];
74 return false;
77 public function getServiceName() {
78 return $this->serviceName;
81 public function getTokenName() {
82 return $this->tokenName;
85 public function getOrigClientState() {
86 return $this->origClientState;