protected function isExtensionAllowed($filename)
    {
        // retrieve the extension
        $pos = strrpos($filename, '.');
        $extension = '';
        if ($pos !== false) {
            $extension = strtolower(substr($filename, $pos + 1));
        }

        // if we have an extension, validate it agains the black and white lists
        if ($extension) {
            // not in whitelist?
            if (sizeof($this->allowedExtensions) > 0 && !in_array($extension, $this->allowedExtensions)) {
                return false;
            }

            // in blacklist ?
            if (sizeof($this->deniedExtensions) && in_array($extension, $this->deniedExtensions)) {
                return false;
            }
        } elseif (sizeof($this->allowedExtensions) > 0) {
            // no extension given, thus not in the whitelist!
            return false;
        }

        return true;
    }