/** * The class constructor. * * @param $cas_parent the CASClient instance that creates the object. * @param $dsn_or_pdo a dsn string to use for creating a PDO object or a PDO object * @param $username the username to use when connecting to the database * @param $password the password to use when connecting to the database * @param $table the table to use for storing and retrieving PGT's * @param $driver_options any driver options to use when connecting to the database */ public function __construct($cas_parent, $dsn_or_pdo, $username = '', $password = '', $table = '', $driver_options = null) { phpCAS::traceBegin(); // call the ancestor's constructor parent::__construct($cas_parent); // set default values if (empty($table)) { $table = CAS_PGT_STORAGE_DB_DEFAULT_TABLE; } if (!is_array($driver_options)) { $driver_options = array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION); } // store the specified parameters if ($dsn_or_pdo instanceof PDO) { $this->_pdo = $dsn_or_pdo; } else { $this->_dsn = $dsn_or_pdo; $this->_username = $username; $this->_password = $password; $this->_driver_options = $driver_options; } // store the table name $this->_table = $table; phpCAS::traceEnd(); }
/** * The class constructor, called by CASClient::SetPGTStorageFile(). * * @param $cas_parent the CASClient instance that creates the object. * @param $format the format used to store the PGT's (`plain' and `xml' allowed). * @param $path the path where the PGT's should be stored * * @public */ function __construct($cas_parent, $format, $path) { phpCAS::traceBegin(); // call the ancestor's constructor parent::__construct($cas_parent); if (empty($format)) { $format = CAS_PGT_STORAGE_FILE_DEFAULT_FORMAT; } if (empty($path)) { $path = CAS_PGT_STORAGE_FILE_DEFAULT_PATH; } // check that the path is an absolute path if (getenv("OS") == "Windows_NT") { if (!preg_match('`^[a-zA-Z]:`', $path)) { phpCAS::error('an absolute path is needed for PGT storage to file'); } } else { if ($path[0] != '/') { phpCAS::error('an absolute path is needed for PGT storage to file'); } // store the path (with a leading and trailing '/') $path = preg_replace('|[/]*$|', '/', $path); $path = preg_replace('|^[/]*|', '/', $path); } $this->_path = $path; // check the format and store it switch ($format) { case CAS_PGT_STORAGE_FILE_FORMAT_PLAIN: case CAS_PGT_STORAGE_FILE_FORMAT_XML: $this->_format = $format; break; default: phpCAS::error('unknown PGT file storage format (`' . CAS_PGT_STORAGE_FILE_FORMAT_PLAIN . '\' and `' . CAS_PGT_STORAGE_FILE_FORMAT_XML . '\' allowed)'); } phpCAS::traceEnd(); }