/** * @return OAuthRequest */ public function newRequestMessage($method, $url, $parameters) { if (!isset($method)) { $method = $this->getProperty("httpMethod"); if ($method == null) { $method = $this->consumer->getProperty("httpMethod"); if ($method == null) { $method = "GET"; } } } $token = new OAuthToken($this->accessToken, $this->tokenSecret); $message = ShindigOAuthRequest::from_consumer_and_token($this->consumer, $token, $method, $url, $parameters); $signatureMethod = null; if ($parameters[ShindigOAuth::$OAUTH_SIGNATURE_METHOD] == ShindigOAuth::$RSA_SHA1) { $signatureMethod = new OAuthSignatureMethod_RSA_SHA1(); } else { if ($parameters[ShindigOAuth::$OAUTH_SIGNATURE_METHOD] == ShindigOAuth::$HMAC_SHA1) { $signatureMethod = new OAuthSignatureMethod_HMAC_SHA1(); } else { //PLAINTEXT $signatureMethod = new OAuthSignatureMethod_PLAINTEXT(); } } $message->sign_request($signatureMethod, $this->consumer, $token); return $message; }
/** * Parse OAuth WWW-Authenticate header and either add them to an existing * message or create a new message. * * @param msg * @param resp * @return the updated message. */ private function parseAuthHeader(ShindigOAuthRequest $msg = null, RemoteContentRequest $resp) { if ($msg == null) { $msg = ShindigOAuthRequest::from_request(); } $authHeaders = $resp->getResponseHeader("WWW-Authenticate"); if ($authHeaders != null) { $msg->set_parameters(ShindigOAuthUtil::decodeAuthorization($authHeaders)); } return $msg; }
private function addOAuthParams(&$msgParams, SecurityToken $token) { $msgParams[ShindigOAuth::$OAUTH_TOKEN] = ''; $domain = $token->getDomain(); if ($domain != null) { $msgParams[ShindigOAuth::$OAUTH_CONSUMER_KEY] = $domain; } if ($this->keyName != null) { $msgParams[SigningFetcher::$XOAUTH_PUBLIC_KEY_OLD] = $this->keyName; $msgParams[SigningFetcher::$XOAUTH_PUBLIC_KEY_NEW] = $this->keyName; } $nonce = ShindigOAuthRequest::generate_nonce(); $msgParams[ShindigOAuth::$OAUTH_NONCE] = $nonce; $timestamp = time(); $msgParams[ShindigOAuth::$OAUTH_TIMESTAMP] = $timestamp; $msgParams[ShindigOAuth::$OAUTH_SIGNATURE_METHOD] = ShindigOAuth::$RSA_SHA1; }