Beispiel #1
0
 /**
  * Return whether a URL can be fetched.  Returns false if the URL
  * scheme is not allowed or is not supported by this fetcher
  * implementation; returns true otherwise.
  *
  * @return bool
  */
 function canFetchURL($url)
 {
     if ($this->isHTTPS($url) && !$this->supportsSSL()) {
         Auth_OpenID::log("HTTPS URL unsupported fetching %s", $url);
         return false;
     }
     if (!$this->allowedURL($url)) {
         Auth_OpenID::log("URL fetching not allowed for '%s'", $url);
         return false;
     }
     return true;
 }
 function post($url, $body, $extra_headers = null)
 {
     if (!$this->canFetchURL($url)) {
         return null;
     }
     $this->reset();
     $c = curl_init();
     if (defined('CURLOPT_NOSIGNAL')) {
         curl_setopt($c, CURLOPT_NOSIGNAL, true);
     }
     curl_setopt($c, CURLOPT_POST, true);
     curl_setopt($c, CURLOPT_POSTFIELDS, $body);
     curl_setopt($c, CURLOPT_TIMEOUT, $this->timeout);
     curl_setopt($c, CURLOPT_URL, $url);
     curl_setopt($c, CURLOPT_WRITEFUNCTION, array($this, "_writeData"));
     if (defined('Auth_OpenID_VERIFY_HOST')) {
         curl_setopt($c, CURLOPT_SSL_VERIFYPEER, true);
         curl_setopt($c, CURLOPT_SSL_VERIFYHOST, 2);
     }
     curl_exec($c);
     $code = curl_getinfo($c, CURLINFO_HTTP_CODE);
     if (!$code) {
         Auth_OpenID::log("Got no response code when fetching %s", $url);
         Auth_OpenID::log("CURL error (%s): %s", curl_errno($c), curl_error($c));
         return null;
     }
     if (defined('Auth_OpenID_VERIFY_HOST') && $this->isHTTPS($url)) {
         Auth_OpenID::log('OpenID: Verified SSL host %s using ' . 'curl/post', $url);
     }
     $body = $this->data;
     curl_close($c);
     $new_headers = $extra_headers;
     foreach ($this->headers as $header) {
         if (strpos($header, ': ')) {
             list($name, $value) = explode(': ', $header, 2);
             $new_headers[$name] = $value;
         }
     }
     Auth_OpenID::log("Successfully fetched '%s': POST response code %s", $url, $code);
     return new Auth_Yadis_HTTPResponse($url, $code, $new_headers, $body);
 }
Beispiel #3
0
 function setOpenIDNamespace($openid_ns_uri, $implicit)
 {
     if (!in_array($openid_ns_uri, $this->allowed_openid_namespaces)) {
         Auth_OpenID::log('Invalid null namespace: "%s"', $openid_ns_uri);
         return false;
     }
     $succeeded = $this->namespaces->addAlias($openid_ns_uri, Auth_OpenID_NULL_NAMESPACE, $implicit);
     if ($succeeded === false) {
         return false;
     }
     $this->_openid_ns_uri = $openid_ns_uri;
     return true;
 }
 function post($url, $body, $extra_headers = null)
 {
     if (!$this->canFetchURL($url)) {
         return null;
     }
     $this->reset();
     $c = curl_init();
     if (defined('CURLOPT_NOSIGNAL')) {
         curl_setopt($c, CURLOPT_NOSIGNAL, true);
     }
     if (defined('Auth_OpenID_HTTP_PROXY')) {
         curl_setopt($c, CURLOPT_PROXY, Auth_OpenID_HTTP_PROXY);
     }
     curl_setopt($c, CURLOPT_POST, true);
     curl_setopt($c, CURLOPT_POSTFIELDS, $body);
     curl_setopt($c, CURLOPT_TIMEOUT, $this->timeout);
     curl_setopt($c, CURLOPT_URL, $url);
     curl_setopt($c, CURLOPT_WRITEFUNCTION, array($this, "_writeData"));
     if (defined('Auth_OpenID_VERIFY_HOST')) {
         // set SSL verification options only if Auth_OpenID_VERIFY_HOST
         // is explicitly set, otherwise use system default.
         if (Auth_OpenID_VERIFY_HOST) {
             curl_setopt($c, CURLOPT_SSL_VERIFYPEER, true);
             curl_setopt($c, CURLOPT_SSL_VERIFYHOST, 2);
             if (defined('Auth_OpenID_CAINFO')) {
                 curl_setopt($c, CURLOPT_CAINFO, Auth_OpenID_CAINFO);
             }
         } else {
             curl_setopt($c, CURLOPT_SSL_VERIFYPEER, false);
         }
     }
     curl_exec($c);
     $code = curl_getinfo($c, CURLINFO_HTTP_CODE);
     if (!$code) {
         Auth_OpenID::log("Got no response code when fetching %s", $url);
         Auth_OpenID::log("CURL error (%s): %s", curl_errno($c), curl_error($c));
         return null;
     }
     if (defined('Auth_OpenID_VERIFY_HOST') && Auth_OpenID_VERIFY_HOST == true && $this->isHTTPS($url)) {
         Auth_OpenID::log('OpenID: Verified SSL host %s using ' . 'curl/post', $url);
     }
     $body = $this->data;
     curl_close($c);
     $new_headers = $extra_headers;
     foreach ($this->headers as $header) {
         if (strpos($header, ': ')) {
             list($name, $value) = explode(': ', $header, 2);
             $new_headers[$name] = $value;
         }
     }
     return new Auth_Yadis_HTTPResponse($url, $code, $new_headers, $body);
 }
 function post($url, $body, $extra_headers = null)
 {
     if (!$this->canFetchURL($url)) {
         return null;
     }
     $this->reset();
     $c = curl_init();
     if (defined('CURLOPT_NOSIGNAL')) {
         curl_setopt($c, CURLOPT_NOSIGNAL, true);
     }
     curl_setopt($c, CURLOPT_POST, true);
     curl_setopt($c, CURLOPT_POSTFIELDS, $body);
     curl_setopt($c, CURLOPT_TIMEOUT, $this->timeout);
     curl_setopt($c, CURLOPT_URL, $url);
     curl_setopt($c, CURLOPT_WRITEFUNCTION, array(&$this, "_writeData"));
     // <TYPO3-specific>
     if ($GLOBALS['TYPO3_CONF_VARS']['SYS']['curlProxyServer']) {
         curl_setopt($c, CURLOPT_PROXY, $GLOBALS['TYPO3_CONF_VARS']['SYS']['curlProxyServer']);
         if ($GLOBALS['TYPO3_CONF_VARS']['SYS']['curlProxyTunnel']) {
             curl_setopt($c, CURLOPT_HTTPPROXYTUNNEL, $GLOBALS['TYPO3_CONF_VARS']['SYS']['curlProxyTunnel']);
         }
         if ($GLOBALS['TYPO3_CONF_VARS']['SYS']['curlProxyUserPass']) {
             curl_setopt($c, CURLOPT_PROXYUSERPWD, $GLOBALS['TYPO3_CONF_VARS']['SYS']['curlProxyUserPass']);
         }
     }
     // </TYPO3-specific>
     curl_exec($c);
     $code = curl_getinfo($c, CURLINFO_HTTP_CODE);
     if (!$code) {
         Auth_OpenID::log("Got no response code when fetching %s", $url);
         return null;
     }
     $body = $this->data;
     curl_close($c);
     $new_headers = $extra_headers;
     foreach ($this->headers as $header) {
         if (strpos($header, ': ')) {
             list($name, $value) = explode(': ', $header, 2);
             $new_headers[$name] = $value;
         }
     }
     Auth_OpenID::log("Successfully fetched '%s': POST response code %s", $url, $code);
     return new Auth_Yadis_HTTPResponse($url, $code, $new_headers, $body);
 }
 function post($url, $body, $extra_headers = null)
 {
     if (!$this->canFetchURL($url)) {
         return null;
     }
     $this->reset();
     $c = curl_init();
     if (defined('CURLOPT_NOSIGNAL')) {
         curl_setopt($c, CURLOPT_NOSIGNAL, true);
     }
     curl_setopt($c, CURLOPT_POST, true);
     curl_setopt($c, CURLOPT_POSTFIELDS, $body);
     curl_setopt($c, CURLOPT_TIMEOUT, $this->timeout);
     curl_setopt($c, CURLOPT_URL, $url);
     curl_setopt($c, CURLOPT_WRITEFUNCTION, array(&$this, "_writeData"));
     curl_exec($c);
     $code = curl_getinfo($c, CURLINFO_HTTP_CODE);
     if (!$code) {
         Auth_OpenID::log("Got no response code when fetching %s", $url);
         return null;
     }
     $body = $this->data;
     curl_close($c);
     if ($extra_headers === null) {
         $new_headers = null;
     } else {
         $new_headers = $extra_headers;
     }
     foreach ($this->headers as $header) {
         if (preg_match("/:/", $header)) {
             list($name, $value) = explode(": ", $header, 2);
             $new_headers[$name] = $value;
         }
     }
     Auth_OpenID::log("Successfully fetched '%s': POST response code %s", $url, $code);
     return new Auth_Yadis_HTTPResponse($url, $code, $new_headers, $body);
 }