public function getOAuthAccessorProviderKey(ProviderKey $providerKey, ProviderInfo $provInfo) { if ($provInfo == null) { throw new OAuthNoDataException("must pass non-null provider info to getOAuthAccessor"); } //AccesorInfo $result = new AccesorInfo(); $result->setHttpMethod($provInfo->getHttpMethod()); $result->setParamLocation($provInfo->getParamLocation()); //ConsumerKeyAndSecret $key = md5(serialize($providerKey)); $consumerKeyAndSecret = null; if (isset($this->consumerInfos[$key])) { $consumerKeyAndSecret = $this->consumerInfos[$key]; } else { throw new OAuthNoDataException("The Key was invalid for consumerInfos, maybe your oauth.json configuration is wrong."); } if ($consumerKeyAndSecret == null) { if ($this->defaultConsumerKey == null || $this->defaultConsumerSecret == null) { throw new OAuthNoDataException("ConsumerKeyAndSecret was null in oauth store"); } else { $consumerKeyAndSecret = new ConsumerKeyAndSecret($this->defaultConsumerKey, $this->defaultConsumerSecret, OAuthStoreVars::$KeyType['RSA_PRIVATE']); } } //OAuthServiceProvider $oauthProvider = $provInfo->getProvider(); if (!isset($oauthProvider)) { throw new OAuthNoDataException("OAuthService provider was null in provider info"); } // Accesing the class $usePublicKeyCrypto = $consumerKeyAndSecret->getKeyType() == OAuthStoreVars::$KeyType['RSA_PRIVATE']; //OAuthConsumer $consumer = $usePublicKeyCrypto ? new OAuthConsumer($consumerKeyAndSecret->getConsumerKey(), null, $oauthProvider) : new OAuthConsumer($consumerKeyAndSecret->getConsumerKey(), $consumerKeyAndSecret->getConsumerSecret(), $oauthProvider); if ($usePublicKeyCrypto) { $consumer->setProperty(OAuthSignatureMethod_RSA_SHA1::$PRIVATE_KEY, $consumerKeyAndSecret->getConsumerSecret()); $result->setSignatureType(OAuthStoreVars::$SignatureType['RSA_SHA1']); } else { $result->setSignatureType(OAuthStoreVars::$SignatureType['HMAC_SHA1']); } $result->setAccessor(new OAuthAccessor($consumer)); return $result; }
/** * Builds the data we'll cache on the client while we make requests. */ private function buildClientAccessState() { try { $oauthState = array(); $accessor = $this->accessorInfo->getAccessor(); $oauthState[self::$ACCESS_TOKEN_KEY] = $accessor->accessToken; $oauthState[self::$ACCESS_TOKEN_SECRET_KEY] = $accessor->tokenSecret; $oauthState[self::$OWNER_KEY] = $this->authToken->getOwnerId(); $this->newClientState = $this->oauthCrypter->wrap($oauthState); } catch (BlobCrypterException $e) { throw new GadgetException("INTERNAL SERVER ERROR: " . $e); } }