コード例 #1
0
 /**
  * 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;
 }
コード例 #2
0
 /**
  * Needed in OAuthFetcher.php
  * 
  * Parse the parameters from an OAuth Authorization or WWW-Authenticate
  * header. The realm is included as a parameter. If the given header doesn't
  * start with "OAuth ", return an empty list.
  *
  * @param string $authorization
  * @return array
  */
 public static function decodeAuthorization($authorization)
 {
     $into = array();
     if ($authorization != null) {
         $m = ereg(ShindigOAuthUtil::$AUTHORIZATION, $authorization);
         if ($m !== false) {
             if (strpos($authorization, ShindigOAuthUtil::$AUTH_SCHEME) == 0) {
                 $authorization = str_replace("OAuth ", "", $authorization);
                 $authParams = explode(", ", $authorization);
                 foreach ($authParams as $params) {
                     $m = ereg(ShindigOAuthUtil::$NVP, $params);
                     if ($m == 1) {
                         $keyValue = explode("=", $params);
                         $name = ShindigOAuthUtil::urlencode_rfc3986($keyValue[0]);
                         $value = ShindigOAuthUtil::urlencode_rfc3986(str_replace("\"", "", $keyValue[1]));
                         $into[$name] = $value;
                     }
                 }
             }
         }
     }
     return $into;
 }