SHINDIG-1041 by Pan Jie - Adds support for OAuth params to the OAuthFetcher
[shindig.git] / php / src / gadgets / oauth / OAuthRequestParams.php
blob6f5b5b2e1a47f4035010229c78a0936af9bbc11f
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(array $arguments) {
39 $this->serviceName = self::getParam($arguments, self::$SERVICE_PARAM, "");
40 $this->tokenName = self::getParam($arguments, self::$TOKEN_PARAM, "");
41 $this->requestToken = self::getParam($arguments, self::$REQUEST_TOKEN_PARAM, null);
42 $this->requestTokenSecret = self::getParam($arguments, self::$REQUEST_TOKEN_SECRET_PARAM, null);
43 $this->origClientState = self::getParam($arguments, self::$CLIENT_STATE_PARAM, null);
44 $this->bypassSpecCache = '1' == self::getParam($arguments, self::$BYPASS_SPEC_CACHE_PARAM, null);
47 private static function getParam(array $arguments, $name, $defaultValue) {
48 if (isset($arguments[$name])) {
49 return $arguments[$name];
50 } else {
51 return $defaultValue;
55 public function getBypassSpecCache() {
56 return $this->bypassSpecCache;
59 public function getRequestToken() {
60 return $this->requestToken;
63 public function getRequestTokenSecret() {
64 return $this->requestTokenSecret;
67 public function getServiceName() {
68 return $this->serviceName;
71 public function getTokenName() {
72 return $this->tokenName;
75 public function getOrigClientState() {
76 return $this->origClientState;