/**
  * Get contents of Captcha resources (js, css, gif files).
  *
  * @param string  $fileName
  * 
  * @throws BadRequestHttpException 
  */
 public function getResourceAction($fileName)
 {
     if (!preg_match('/^[a-z_]+\\.(css|gif|js)$/', $fileName)) {
         throw new BadRequestHttpException('Invalid file name.');
     }
     $resourcePath = realpath(Path::getPublicDirPathInLibrary() . $fileName);
     if (!is_file($resourcePath)) {
         throw new BadRequestHttpException(sprintf('File "%s" could not be found.', $fileName));
     }
     // captcha resource file information
     $fileInfo = pathinfo($resourcePath);
     $fileContents = file_get_contents($resourcePath);
     $mimeType = self::getMimeType($fileInfo['extension']);
     return new Response($fileContents, 200, array('content-type' => $mimeType));
 }
 /**
  * Load the captcha configuration defaults.
  *
  * @param SessionInterface  $session
  */
 private static function loadCaptchaConfigDefaults(SessionInterface $session)
 {
     self::includeFile(Path::getCaptchaConfigDefaultsFilePath(), true, $session);
 }
 /**
  * Physical path of user's captcha config file.
  *
  * @param string  $path
  * 
  * @throws FileNotFoundException  when user's captcha config file path is incorrect 
  */
 private function normalizePath($path)
 {
     // physical path of the Symfony's config directory
     $pathInConfigDir = Path::getConfigDirPath() . '/' . $path;
     if (!is_file($pathInConfigDir)) {
         throw new FileNotFoundException(sprintf('File "app/config/%s" could not be found.', $path), 0, null, $path);
     }
     return $pathInConfigDir;
 }