/**
* The constructor for the OpenID provider class.
*
* Initializes and validates the configuration.
*/
private function __construct()
{
$config = SimpleSAML_Configuration::getConfig('module_openidProvider.php');
$this->authSource = new SimpleSAML_Auth_Simple($config->getString('auth'));
$this->usernameAttribute = $config->getString('username_attribute');
SimpleSAML_Utilities::maskErrors(E_WARNING | E_STRICT);
try {
$store = new Auth_OpenID_FileStore($config->getString('filestore'));
$this->server = new Auth_OpenID_Server($store);
} catch (Exception $e) {
SimpleSAML_Utilities::popErrorMask();
throw $e;
}
SimpleSAML_Utilities::popErrorMask();
$this->trustStoreDir = realpath($config->getString('filestore')) . '/truststore';
if (!is_dir($this->trustStoreDir)) {
$res = mkdir($this->trustStoreDir, 0777, TRUE);
if (!$res) {
throw new SimpleSAML_Error_Exception('Failed to create directory: ' . $this->trustStoreDir);
}
}
}