protected function createIdpMetadataFile()
    {
        $url = $this->getConfig()->getIdpEntityID() . $this->getConfig()->getIdpMetadataFileTarget();

        try {
            $idp = file_get_contents($url);
            $path = $this->getConfig()->getSamlMetadataBaseDir() . '/' . $this->getConfig()->getIdpMetadataFile();
            $this->createDir($path);

            if (@file_put_contents($path, $idp) === false) {
                throw new \Exception(sprintf('Unable to write IdP Metadata on %s', $path));
            }
        } catch (\Exception $e) {
            throw new \Exception(sprintf('Unable to fetch IdP Metadata on %s', $url));
        }
    }