You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@shindig.apache.org by ch...@apache.org on 2008/07/04 17:34:00 UTC

svn commit: r674076 - in /incubator/shindig/trunk/php/src/gadgets/oauth: GadgetOAuthTokenStore.php OAuthFetcher.php OAuthFetcherFactory.php OAuthRequestParams.php

Author: chabotc
Date: Fri Jul  4 08:33:59 2008
New Revision: 674076

URL: http://svn.apache.org/viewvc?rev=674076&view=rev
Log:
Some modifications to how OAuth is managed & some minor cleanups

Modified:
    incubator/shindig/trunk/php/src/gadgets/oauth/GadgetOAuthTokenStore.php
    incubator/shindig/trunk/php/src/gadgets/oauth/OAuthFetcher.php
    incubator/shindig/trunk/php/src/gadgets/oauth/OAuthFetcherFactory.php
    incubator/shindig/trunk/php/src/gadgets/oauth/OAuthRequestParams.php

Modified: incubator/shindig/trunk/php/src/gadgets/oauth/GadgetOAuthTokenStore.php
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/php/src/gadgets/oauth/GadgetOAuthTokenStore.php?rev=674076&r1=674075&r2=674076&view=diff
==============================================================================
--- incubator/shindig/trunk/php/src/gadgets/oauth/GadgetOAuthTokenStore.php (original)
+++ incubator/shindig/trunk/php/src/gadgets/oauth/GadgetOAuthTokenStore.php Fri Jul  4 08:33:59 2008
@@ -120,7 +120,7 @@
 	 *         passed to an OAuthMessage.sign method), as well as httpMethod and
 	 *         signatureType fields.
 	 */
-	public function getOAuthAccessor(TokenKey $tokenKey)
+	public function getOAuthAccessor(TokenKey $tokenKey, $ignoreCache)
 	{
 		$gadgetUri = $tokenKey->getGadgetUri();
 		if (empty($gadgetUri)) {
@@ -130,12 +130,7 @@
 		if (empty($getUserId)) {
 			throw new OAuthStoreException("found empty userId in TokenKey");
 		}
-		$remoteContentRequest = new RemoteContentRequest($gadgetUri);
-		$remoteContentRequest->getRequest($gadgetUri, false);
-		$spec = $this->specFactory->fetchRequest($remoteContentRequest);
-		$specParser = new GadgetSpecParser();
-		$context = new ProxyGadgetContext($gadgetUri);
-		$gadgetSpec = $specParser->parse($spec->getResponseContent(), $context);
+		$gadgetSpec = $this->specFactory->getGadgetSpecUri($gadgetUri, $ignoreCache);
 		$provInfo = $this->getProviderInfo($gadgetSpec, $tokenKey->getServiceName());
 		return $this->store->getOAuthAccessorTokenKey($tokenKey, $provInfo);
 	}

Modified: incubator/shindig/trunk/php/src/gadgets/oauth/OAuthFetcher.php
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/php/src/gadgets/oauth/OAuthFetcher.php?rev=674076&r1=674075&r2=674076&view=diff
==============================================================================
--- incubator/shindig/trunk/php/src/gadgets/oauth/OAuthFetcher.php (original)
+++ incubator/shindig/trunk/php/src/gadgets/oauth/OAuthFetcher.php Fri Jul  4 08:33:59 2008
@@ -176,7 +176,7 @@
 	protected function lookupOAuthMetadata()
 	{
 		$tokenKey = $this->buildTokenKey();
-		$this->accessorInfo = $this->tokenStore->getOAuthAccessor($tokenKey);
+		$this->accessorInfo = $this->tokenStore->getOAuthAccessor($tokenKey, $this->bypassSpecCache);
 		// The persistent data store may be out of sync with reality; we trust
 		// the state we stored on the client to be accurate.
 		$accessor = $this->accessorInfo->getAccessor();
@@ -269,7 +269,7 @@
 	 * @throws GadgetException
 	 */
 	private function checkCanApprove()
-	{
+	{
 		$pageOwner = $this->authToken->getOwnerId();
 		$pageViewer = $this->authToken->getViewerId();
 		$stateOwner = @$this->origClientState[self::$OWNER_KEY];
@@ -307,7 +307,7 @@
 	private function newRequestMessageMethod($method, $url, $params)
 	{
 		if (! isset($params)) {
-			throw new Exception("params was null in " + "newRequestMessage " + "Use newRequesMessage if you don't have a params to pass");
+			throw new Exception("params was null in " . "newRequestMessage " . "Use newRequesMessage if you don't have a params to pass");
 		}
 		switch ($this->accessorInfo->getSignatureType()) {
 			case OAuth::$RSA_SHA1:

Modified: incubator/shindig/trunk/php/src/gadgets/oauth/OAuthFetcherFactory.php
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/php/src/gadgets/oauth/OAuthFetcherFactory.php?rev=674076&r1=674075&r2=674076&view=diff
==============================================================================
--- incubator/shindig/trunk/php/src/gadgets/oauth/OAuthFetcherFactory.php (original)
+++ incubator/shindig/trunk/php/src/gadgets/oauth/OAuthFetcherFactory.php Fri Jul  4 08:33:59 2008
@@ -48,8 +48,9 @@
 	{
 		try {
 			$BBC = new BasicBlobCrypter();
-			$this->oauthCrypter = new BasicBlobCrypter(srand($BBC->MASTER_KEY_MIN_LEN));
-			$basicStore = new BasicGadgetOAuthTokenStore(new BasicOAuthStore(), $fetcher);
+			$this->oauthCrypter = new BasicBlobCrypter(srand($BBC->MASTER_KEY_MIN_LEN));
+			$specFactory = new BasicGadgetSpecFactory($fetcher);
+			$basicStore = new BasicGadgetOAuthTokenStore(new BasicOAuthStore(), $specFactory);
 			$basicStore->initFromConfigFile($fetcher);
 			$this->tokenStore = $basicStore;
 		} catch (Exeption $e) {

Modified: incubator/shindig/trunk/php/src/gadgets/oauth/OAuthRequestParams.php
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/php/src/gadgets/oauth/OAuthRequestParams.php?rev=674076&r1=674075&r2=674076&view=diff
==============================================================================
--- incubator/shindig/trunk/php/src/gadgets/oauth/OAuthRequestParams.php (original)
+++ incubator/shindig/trunk/php/src/gadgets/oauth/OAuthRequestParams.php Fri Jul  4 08:33:59 2008
@@ -73,8 +73,11 @@
 	}
 
 	public static function parseBypassSpecCacheParam()
-	{
-		return "1" == $_REQUEST[self::$BYPASS_SPEC_CACHE_PARAM];
+	{
+		if (isset($_REQUEST[self::$BYPASS_SPEC_CACHE_PARAM])) {
+			return "1" == $_REQUEST[self::$BYPASS_SPEC_CACHE_PARAM];
+		}
+		return false;
 	}
 
 	public function getServiceName()