Author: bhofmann
Date: Wed Dec 22 14:39:55 2010
New Revision: 1051921

URL: http://svn.apache.org/viewvc?rev=1051921&view=rev
Log:
PHP: made GadgetOAuthTokenStore injectable, added AppId as field in OAuth 
TokenKey class, changed some methods to protected to make GadgetOAuthTokenStore 
and OAuthStore easier to overwrite for custom implementations


Modified:
    shindig/trunk/php/config/container.php
    shindig/trunk/php/src/gadgets/oauth/BasicGadgetOAuthTokenStore.php
    shindig/trunk/php/src/gadgets/oauth/BasicOAuthStore.php
    shindig/trunk/php/src/gadgets/oauth/OAuthFetcher.php
    shindig/trunk/php/src/gadgets/oauth/OAuthFetcherFactory.php
    shindig/trunk/php/src/gadgets/oauth/OAuthStore.php

Modified: shindig/trunk/php/config/container.php
URL: 
http://svn.apache.org/viewvc/shindig/trunk/php/config/container.php?rev=1051921&r1=1051920&r2=1051921&view=diff
==============================================================================
--- shindig/trunk/php/config/container.php (original)
+++ shindig/trunk/php/config/container.php Wed Dec 22 14:39:55 2010
@@ -154,7 +154,7 @@ $shindigConfig = array(
   'oauth_lookup_service' => 'BasicOAuthLookupService',
   // The OAuth Store is used to store the (gadgets/)oauth proxy credentials it 
obtained on behalf of the user/gadget combo
   'oauth_store' => 'BasicOAuthStore',
-
+  'gadget_oauth_token_store' => 'BasicGadgetOAuthTokenStore',
  
   // handler for ApiServlet
   'service_handler' => array(

Modified: shindig/trunk/php/src/gadgets/oauth/BasicGadgetOAuthTokenStore.php
URL: 
http://svn.apache.org/viewvc/shindig/trunk/php/src/gadgets/oauth/BasicGadgetOAuthTokenStore.php?rev=1051921&r1=1051920&r2=1051921&view=diff
==============================================================================
--- shindig/trunk/php/src/gadgets/oauth/BasicGadgetOAuthTokenStore.php 
(original)
+++ shindig/trunk/php/src/gadgets/oauth/BasicGadgetOAuthTokenStore.php Wed Dec 
22 14:39:55 2010
@@ -51,7 +51,7 @@ class BasicGadgetOAuthTokenStore extends
     }
   }
 
-  private function storeConsumerInfos($gadgetUri, $oauthConfig) {
+  protected function storeConsumerInfos($gadgetUri, $oauthConfig) {
     foreach ($oauthConfig as $key => $value) {
       $serviceName = $key;
       $consumerInfo = $value;
@@ -59,7 +59,7 @@ class BasicGadgetOAuthTokenStore extends
     }
   }
 
-  private function storeConsumerInfo($gadgetUri, $serviceName, $consumerInfo) {
+  protected function storeConsumerInfo($gadgetUri, $serviceName, 
$consumerInfo) {
     if (! isset($consumerInfo[$this->CONSUMER_SECRET_KEY]) || ! 
isset($consumerInfo[$this->CONSUMER_KEY_KEY]) || ! 
isset($consumerInfo[$this->KEY_TYPE_KEY])) {
       throw new Exception("Invalid configuration in oauth.json");
     }

Modified: shindig/trunk/php/src/gadgets/oauth/BasicOAuthStore.php
URL: 
http://svn.apache.org/viewvc/shindig/trunk/php/src/gadgets/oauth/BasicOAuthStore.php?rev=1051921&r1=1051920&r2=1051921&view=diff
==============================================================================
--- shindig/trunk/php/src/gadgets/oauth/BasicOAuthStore.php (original)
+++ shindig/trunk/php/src/gadgets/oauth/BasicOAuthStore.php Wed Dec 22 14:39:55 
2010
@@ -108,7 +108,7 @@ class BasicOAuthStore implements OAuthSt
     unset($this->tokens[md5(serialize($tokenKey))]);
   }
 
-  private function getTokenInfo($tokenKey) {
+  protected function getTokenInfo($tokenKey) {
     $key = md5(serialize($tokenKey));
     return isset($this->tokens[$key]) ? $this->tokens[$key] : null;
   }

Modified: shindig/trunk/php/src/gadgets/oauth/OAuthFetcher.php
URL: 
http://svn.apache.org/viewvc/shindig/trunk/php/src/gadgets/oauth/OAuthFetcher.php?rev=1051921&r1=1051920&r2=1051921&view=diff
==============================================================================
--- shindig/trunk/php/src/gadgets/oauth/OAuthFetcher.php (original)
+++ shindig/trunk/php/src/gadgets/oauth/OAuthFetcher.php Wed Dec 22 14:39:55 
2010
@@ -214,6 +214,7 @@ class OAuthFetcher extends RemoteContent
     // need to URLDecode so when comparing with the ProviderKey it goes thought
     $tokenKey->setGadgetUri(urldecode($this->authToken->getAppUrl()));
     $tokenKey->setModuleId($this->authToken->getModuleId());
+    $tokenKey->setAppId($this->authToken->getAppId());
     $tokenKey->setServiceName($this->requestParams->getServiceName());
     $tokenKey->setTokenName($this->requestParams->getTokenName());
     // At some point we might want to let gadgets specify whether to use OAuth

Modified: shindig/trunk/php/src/gadgets/oauth/OAuthFetcherFactory.php
URL: 
http://svn.apache.org/viewvc/shindig/trunk/php/src/gadgets/oauth/OAuthFetcherFactory.php?rev=1051921&r1=1051920&r2=1051921&view=diff
==============================================================================
--- shindig/trunk/php/src/gadgets/oauth/OAuthFetcherFactory.php (original)
+++ shindig/trunk/php/src/gadgets/oauth/OAuthFetcherFactory.php Wed Dec 22 
14:39:55 2010
@@ -49,7 +49,8 @@ class OAuthFetcherFactory {
       $this->oauthCrypter = new 
BasicBlobCrypter(srand($BBC->MASTER_KEY_MIN_LEN));
       $specFactory = new BasicGadgetSpecFactory();
       $OAuthStore = Config::get('oauth_store');
-      $basicStore = new BasicGadgetOAuthTokenStore(new $OAuthStore, 
$specFactory);
+      $gadgetOAuthTokenStore = Config::get('gadget_oauth_token_store');
+      $basicStore = new $gadgetOAuthTokenStore(new $OAuthStore, $specFactory);
       $basicStore->initFromConfigFile($fetcher);
       $this->tokenStore = $basicStore;
     } catch (Exeption $e) {}

Modified: shindig/trunk/php/src/gadgets/oauth/OAuthStore.php
URL: 
http://svn.apache.org/viewvc/shindig/trunk/php/src/gadgets/oauth/OAuthStore.php?rev=1051921&r1=1051920&r2=1051921&view=diff
==============================================================================
--- shindig/trunk/php/src/gadgets/oauth/OAuthStore.php (original)
+++ shindig/trunk/php/src/gadgets/oauth/OAuthStore.php Wed Dec 22 14:39:55 2010
@@ -210,6 +210,15 @@ class TokenKey {
   private $moduleId;
   private $tokenName;
   private $serviceName;
+  private $appId;
+
+  public function getAppId() {
+    return $this->appId;
+  }
+
+  public function setAppId($appId) {
+    $this->appId = $appId;
+  }
 
   public function getUserId() {
     return $this->userId;


Reply via email to