Exemplo n.º 1
0
 /**
  * Check domain support
  *
  * Checks if the given domain supports BrowserID/Persona and offers a support document.
  *
  * @access public
  * @static
  * @param string $domain The name of the domain
  * @param array $delegates A list of already seen domains while delegating
  * @return array @see Primary::getWellKnown() or null if not supported
  */
 public static function checkSupport($domain, $delegates = null)
 {
     // Delegates will be populatd via recursion to detect cycles
     if (!is_array($delegates)) {
         $delegates = array();
     }
     /*
       if (config.get('disable_primary_support')) {
       return process.nextTick(function() { cb(null, false); });
     }
     */
     if (!is_string($domain) || strlen($domain) == 0) {
         throw new \Exception("invalid domain");
     }
     $result = Primary::getWellKnown($domain, $delegates);
     if (!$result["body"]) {
         return null;
     }
     try {
         return Primary::parseWellKnownBody($result["body"], $result["domain"], $result["delegates"]);
     } catch (Exception $e) {
         throw new \Exception($domain . ' is a broken browserid primary, malformed dec of support: ' . $e->getMessage());
     }
 }