/**
  * @param ClientMetadata $metadata
  * @param $sectorIdentifierUri
  * @return bool
  * @throws HttpException
  */
 public function check(ClientMetadata $metadata, $sectorIdentifierUri)
 {
     $ch = curl_init();
     curl_setopt($ch, CURLOPT_URL, $sectorIdentifierUri);
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
     $response = curl_exec($ch);
     $responseCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
     if ($responseCode !== 200) {
         throw new HttpException($responseCode);
     }
     $allowedUris = json_decode(trim($response));
     if (!is_array($allowedUris)) {
         return false;
     }
     foreach ($metadata->getRedirectUris() as $uri) {
         if (array_search($uri, $allowedUris) === false) {
             return false;
         }
     }
     return true;
 }