adding zend project folders into old campcaster.
This commit is contained in:
parent
56abfaf28e
commit
7ef0c18b26
4045 changed files with 1054952 additions and 0 deletions
106
library/Zend/OpenId/Provider/Storage.php
Normal file
106
library/Zend/OpenId/Provider/Storage.php
Normal file
|
@ -0,0 +1,106 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Zend Framework
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to the new BSD license that is bundled
|
||||
* with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://framework.zend.com/license/new-bsd
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@zend.com so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_OpenId
|
||||
* @subpackage Zend_OpenId_Provider
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: Storage.php 20096 2010-01-06 02:05:09Z bkarwin $
|
||||
*/
|
||||
|
||||
/**
|
||||
* Abstract class to implement external storage for OpenID consumer
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_OpenId
|
||||
* @subpackage Zend_OpenId_Provider
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
abstract class Zend_OpenId_Provider_Storage
|
||||
{
|
||||
|
||||
/**
|
||||
* Stores information about session identified by $handle
|
||||
*
|
||||
* @param string $handle assiciation handle
|
||||
* @param string $macFunc HMAC function (sha1 or sha256)
|
||||
* @param string $secret shared secret
|
||||
* @param string $expires expiration UNIX time
|
||||
* @return void
|
||||
*/
|
||||
abstract public function addAssociation($handle, $macFunc, $secret, $expires);
|
||||
|
||||
/**
|
||||
* Gets information about association identified by $handle
|
||||
* Returns true if given association found and not expired and false
|
||||
* otherwise
|
||||
*
|
||||
* @param string $handle assiciation handle
|
||||
* @param string &$macFunc HMAC function (sha1 or sha256)
|
||||
* @param string &$secret shared secret
|
||||
* @param string &$expires expiration UNIX time
|
||||
* @return bool
|
||||
*/
|
||||
abstract public function getAssociation($handle, &$macFunc, &$secret, &$expires);
|
||||
|
||||
/**
|
||||
* Register new user with given $id and $password
|
||||
* Returns true in case of success and false if user with given $id already
|
||||
* exists
|
||||
*
|
||||
* @param string $id user identity URL
|
||||
* @param string $password encoded user password
|
||||
* @return bool
|
||||
*/
|
||||
abstract public function addUser($id, $password);
|
||||
|
||||
/**
|
||||
* Returns true if user with given $id exists and false otherwise
|
||||
*
|
||||
* @param string $id user identity URL
|
||||
* @return bool
|
||||
*/
|
||||
abstract public function hasUser($id);
|
||||
|
||||
/**
|
||||
* Verify if user with given $id exists and has specified $password
|
||||
*
|
||||
* @param string $id user identity URL
|
||||
* @param string $password user password
|
||||
* @return bool
|
||||
*/
|
||||
abstract public function checkUser($id, $password);
|
||||
|
||||
/**
|
||||
* Returns array of all trusted/untrusted sites for given user identified
|
||||
* by $id
|
||||
*
|
||||
* @param string $id user identity URL
|
||||
* @return array
|
||||
*/
|
||||
abstract public function getTrustedSites($id);
|
||||
|
||||
/**
|
||||
* Stores information about trusted/untrusted site for given user
|
||||
*
|
||||
* @param string $id user identity URL
|
||||
* @param string $site site URL
|
||||
* @param mixed $trusted trust data from extensions or just a boolean value
|
||||
* @return bool
|
||||
*/
|
||||
abstract public function addSite($id, $site, $trusted);
|
||||
}
|
442
library/Zend/OpenId/Provider/Storage/File.php
Normal file
442
library/Zend/OpenId/Provider/Storage/File.php
Normal file
|
@ -0,0 +1,442 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Zend Framework
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to the new BSD license that is bundled
|
||||
* with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://framework.zend.com/license/new-bsd
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@zend.com so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_OpenId
|
||||
* @subpackage Zend_OpenId_Provider
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: File.php 20096 2010-01-06 02:05:09Z bkarwin $
|
||||
*/
|
||||
|
||||
/**
|
||||
* @see Zend_OpenId_Provider_Storage
|
||||
*/
|
||||
require_once "Zend/OpenId/Provider/Storage.php";
|
||||
|
||||
/**
|
||||
* External storage implemmentation using serialized files
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_OpenId
|
||||
* @subpackage Zend_OpenId_Provider
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_OpenId_Provider_Storage_File extends Zend_OpenId_Provider_Storage
|
||||
{
|
||||
|
||||
/**
|
||||
* Directory name to store data files in
|
||||
*
|
||||
* @var string $_dir
|
||||
*/
|
||||
private $_dir;
|
||||
|
||||
/**
|
||||
* Constructs storage object and creates storage directory
|
||||
*
|
||||
* @param string $dir directory name to store data files in
|
||||
* @throws Zend_OpenId_Exception
|
||||
*/
|
||||
public function __construct($dir = null)
|
||||
{
|
||||
if ($dir === null) {
|
||||
$tmp = getenv('TMP');
|
||||
if (empty($tmp)) {
|
||||
$tmp = getenv('TEMP');
|
||||
if (empty($tmp)) {
|
||||
$tmp = "/tmp";
|
||||
}
|
||||
}
|
||||
$user = get_current_user();
|
||||
if (is_string($user) && !empty($user)) {
|
||||
$tmp .= '/' . $user;
|
||||
}
|
||||
$dir = $tmp . '/openid/provider';
|
||||
}
|
||||
$this->_dir = $dir;
|
||||
if (!is_dir($this->_dir)) {
|
||||
if (!@mkdir($this->_dir, 0700, 1)) {
|
||||
throw new Zend_OpenId_Exception(
|
||||
"Cannot access storage directory $dir",
|
||||
Zend_OpenId_Exception::ERROR_STORAGE);
|
||||
}
|
||||
}
|
||||
if (($f = fopen($this->_dir.'/assoc.lock', 'w+')) === null) {
|
||||
throw new Zend_OpenId_Exception(
|
||||
'Cannot create a lock file in the directory ' . $dir,
|
||||
Zend_OpenId_Exception::ERROR_STORAGE);
|
||||
}
|
||||
fclose($f);
|
||||
if (($f = fopen($this->_dir.'/user.lock', 'w+')) === null) {
|
||||
throw new Zend_OpenId_Exception(
|
||||
'Cannot create a lock file in the directory ' . $dir,
|
||||
Zend_OpenId_Exception::ERROR_STORAGE);
|
||||
}
|
||||
fclose($f);
|
||||
}
|
||||
|
||||
/**
|
||||
* Stores information about session identified by $handle
|
||||
*
|
||||
* @param string $handle assiciation handle
|
||||
* @param string $macFunc HMAC function (sha1 or sha256)
|
||||
* @param string $secret shared secret
|
||||
* @param string $expires expiration UNIX time
|
||||
* @return bool
|
||||
*/
|
||||
public function addAssociation($handle, $macFunc, $secret, $expires)
|
||||
{
|
||||
$name = $this->_dir . '/assoc_' . md5($handle);
|
||||
$lock = @fopen($this->_dir . '/assoc.lock', 'w+');
|
||||
if ($lock === false) {
|
||||
return false;
|
||||
}
|
||||
if (!flock($lock, LOCK_EX)) {
|
||||
fclose($lock);
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
$f = @fopen($name, 'w+');
|
||||
if ($f === false) {
|
||||
fclose($lock);
|
||||
return false;
|
||||
}
|
||||
$data = serialize(array($handle, $macFunc, $secret, $expires));
|
||||
fwrite($f, $data);
|
||||
fclose($f);
|
||||
fclose($lock);
|
||||
return true;
|
||||
} catch (Exception $e) {
|
||||
fclose($lock);
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets information about association identified by $handle
|
||||
* Returns true if given association found and not expired and false
|
||||
* otherwise
|
||||
*
|
||||
* @param string $handle assiciation handle
|
||||
* @param string &$macFunc HMAC function (sha1 or sha256)
|
||||
* @param string &$secret shared secret
|
||||
* @param string &$expires expiration UNIX time
|
||||
* @return bool
|
||||
*/
|
||||
public function getAssociation($handle, &$macFunc, &$secret, &$expires)
|
||||
{
|
||||
$name = $this->_dir . '/assoc_' . md5($handle);
|
||||
$lock = @fopen($this->_dir . '/assoc.lock', 'w+');
|
||||
if ($lock === false) {
|
||||
return false;
|
||||
}
|
||||
if (!flock($lock, LOCK_EX)) {
|
||||
fclose($lock);
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
$f = @fopen($name, 'r');
|
||||
if ($f === false) {
|
||||
fclose($lock);
|
||||
return false;
|
||||
}
|
||||
$ret = false;
|
||||
$data = stream_get_contents($f);
|
||||
if (!empty($data)) {
|
||||
list($storedHandle, $macFunc, $secret, $expires) = unserialize($data);
|
||||
if ($handle === $storedHandle && $expires > time()) {
|
||||
$ret = true;
|
||||
} else {
|
||||
fclose($f);
|
||||
@unlink($name);
|
||||
fclose($lock);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
fclose($f);
|
||||
fclose($lock);
|
||||
return $ret;
|
||||
} catch (Exception $e) {
|
||||
fclose($lock);
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes information about association identified by $handle
|
||||
*
|
||||
* @param string $handle assiciation handle
|
||||
* @return bool
|
||||
*/
|
||||
public function delAssociation($handle)
|
||||
{
|
||||
$name = $this->_dir . '/assoc_' . md5($handle);
|
||||
$lock = @fopen($this->_dir . '/assoc.lock', 'w+');
|
||||
if ($lock === false) {
|
||||
return false;
|
||||
}
|
||||
if (!flock($lock, LOCK_EX)) {
|
||||
fclose($lock);
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
@unlink($name);
|
||||
fclose($lock);
|
||||
return true;
|
||||
} catch (Exception $e) {
|
||||
fclose($lock);
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Register new user with given $id and $password
|
||||
* Returns true in case of success and false if user with given $id already
|
||||
* exists
|
||||
*
|
||||
* @param string $id user identity URL
|
||||
* @param string $password encoded user password
|
||||
* @return bool
|
||||
*/
|
||||
public function addUser($id, $password)
|
||||
{
|
||||
$name = $this->_dir . '/user_' . md5($id);
|
||||
$lock = @fopen($this->_dir . '/user.lock', 'w+');
|
||||
if ($lock === false) {
|
||||
return false;
|
||||
}
|
||||
if (!flock($lock, LOCK_EX)) {
|
||||
fclose($lock);
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
$f = @fopen($name, 'x');
|
||||
if ($f === false) {
|
||||
fclose($lock);
|
||||
return false;
|
||||
}
|
||||
$data = serialize(array($id, $password, array()));
|
||||
fwrite($f, $data);
|
||||
fclose($f);
|
||||
fclose($lock);
|
||||
return true;
|
||||
} catch (Exception $e) {
|
||||
fclose($lock);
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if user with given $id exists and false otherwise
|
||||
*
|
||||
* @param string $id user identity URL
|
||||
* @return bool
|
||||
*/
|
||||
public function hasUser($id)
|
||||
{
|
||||
$name = $this->_dir . '/user_' . md5($id);
|
||||
$lock = @fopen($this->_dir . '/user.lock', 'w+');
|
||||
if ($lock === false) {
|
||||
return false;
|
||||
}
|
||||
if (!flock($lock, LOCK_SH)) {
|
||||
fclose($lock);
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
$f = @fopen($name, 'r');
|
||||
if ($f === false) {
|
||||
fclose($lock);
|
||||
return false;
|
||||
}
|
||||
$ret = false;
|
||||
$data = stream_get_contents($f);
|
||||
if (!empty($data)) {
|
||||
list($storedId, $storedPassword, $trusted) = unserialize($data);
|
||||
if ($id === $storedId) {
|
||||
$ret = true;
|
||||
}
|
||||
}
|
||||
fclose($f);
|
||||
fclose($lock);
|
||||
return $ret;
|
||||
} catch (Exception $e) {
|
||||
fclose($lock);
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify if user with given $id exists and has specified $password
|
||||
*
|
||||
* @param string $id user identity URL
|
||||
* @param string $password user password
|
||||
* @return bool
|
||||
*/
|
||||
public function checkUser($id, $password)
|
||||
{
|
||||
$name = $this->_dir . '/user_' . md5($id);
|
||||
$lock = @fopen($this->_dir . '/user.lock', 'w+');
|
||||
if ($lock === false) {
|
||||
return false;
|
||||
}
|
||||
if (!flock($lock, LOCK_SH)) {
|
||||
fclose($lock);
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
$f = @fopen($name, 'r');
|
||||
if ($f === false) {
|
||||
fclose($lock);
|
||||
return false;
|
||||
}
|
||||
$ret = false;
|
||||
$data = stream_get_contents($f);
|
||||
if (!empty($data)) {
|
||||
list($storedId, $storedPassword, $trusted) = unserialize($data);
|
||||
if ($id === $storedId && $password === $storedPassword) {
|
||||
$ret = true;
|
||||
}
|
||||
}
|
||||
fclose($f);
|
||||
fclose($lock);
|
||||
return $ret;
|
||||
} catch (Exception $e) {
|
||||
fclose($lock);
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes information abou specified user
|
||||
*
|
||||
* @param string $id user identity URL
|
||||
* @return bool
|
||||
*/
|
||||
public function delUser($id)
|
||||
{
|
||||
$name = $this->_dir . '/user_' . md5($id);
|
||||
$lock = @fopen($this->_dir . '/user.lock', 'w+');
|
||||
if ($lock === false) {
|
||||
return false;
|
||||
}
|
||||
if (!flock($lock, LOCK_EX)) {
|
||||
fclose($lock);
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
@unlink($name);
|
||||
fclose($lock);
|
||||
return true;
|
||||
} catch (Exception $e) {
|
||||
fclose($lock);
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns array of all trusted/untrusted sites for given user identified
|
||||
* by $id
|
||||
*
|
||||
* @param string $id user identity URL
|
||||
* @return array
|
||||
*/
|
||||
public function getTrustedSites($id)
|
||||
{
|
||||
$name = $this->_dir . '/user_' . md5($id);
|
||||
$lock = @fopen($this->_dir . '/user.lock', 'w+');
|
||||
if ($lock === false) {
|
||||
return false;
|
||||
}
|
||||
if (!flock($lock, LOCK_SH)) {
|
||||
fclose($lock);
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
$f = @fopen($name, 'r');
|
||||
if ($f === false) {
|
||||
fclose($lock);
|
||||
return false;
|
||||
}
|
||||
$ret = false;
|
||||
$data = stream_get_contents($f);
|
||||
if (!empty($data)) {
|
||||
list($storedId, $storedPassword, $trusted) = unserialize($data);
|
||||
if ($id === $storedId) {
|
||||
$ret = $trusted;
|
||||
}
|
||||
}
|
||||
fclose($f);
|
||||
fclose($lock);
|
||||
return $ret;
|
||||
} catch (Exception $e) {
|
||||
fclose($lock);
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Stores information about trusted/untrusted site for given user
|
||||
*
|
||||
* @param string $id user identity URL
|
||||
* @param string $site site URL
|
||||
* @param mixed $trusted trust data from extension or just a boolean value
|
||||
* @return bool
|
||||
*/
|
||||
public function addSite($id, $site, $trusted)
|
||||
{
|
||||
$name = $this->_dir . '/user_' . md5($id);
|
||||
$lock = @fopen($this->_dir . '/user.lock', 'w+');
|
||||
if ($lock === false) {
|
||||
return false;
|
||||
}
|
||||
if (!flock($lock, LOCK_EX)) {
|
||||
fclose($lock);
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
$f = @fopen($name, 'r+');
|
||||
if ($f === false) {
|
||||
fclose($lock);
|
||||
return false;
|
||||
}
|
||||
$ret = false;
|
||||
$data = stream_get_contents($f);
|
||||
if (!empty($data)) {
|
||||
list($storedId, $storedPassword, $sites) = unserialize($data);
|
||||
if ($id === $storedId) {
|
||||
if ($trusted === null) {
|
||||
unset($sites[$site]);
|
||||
} else {
|
||||
$sites[$site] = $trusted;
|
||||
}
|
||||
rewind($f);
|
||||
ftruncate($f, 0);
|
||||
$data = serialize(array($id, $storedPassword, $sites));
|
||||
fwrite($f, $data);
|
||||
$ret = true;
|
||||
}
|
||||
}
|
||||
fclose($f);
|
||||
fclose($lock);
|
||||
return $ret;
|
||||
} catch (Exception $e) {
|
||||
fclose($lock);
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
}
|
57
library/Zend/OpenId/Provider/User.php
Normal file
57
library/Zend/OpenId/Provider/User.php
Normal file
|
@ -0,0 +1,57 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Zend Framework
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to the new BSD license that is bundled
|
||||
* with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://framework.zend.com/license/new-bsd
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@zend.com so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_OpenId
|
||||
* @subpackage Zend_OpenId_Provider
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: User.php 20096 2010-01-06 02:05:09Z bkarwin $
|
||||
*/
|
||||
|
||||
/**
|
||||
* Abstract class to get/store information about logged in user in Web Browser
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_OpenId
|
||||
* @subpackage Zend_OpenId_Provider
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
abstract class Zend_OpenId_Provider_User
|
||||
{
|
||||
|
||||
/**
|
||||
* Stores information about logged in user
|
||||
*
|
||||
* @param string $id user identity URL
|
||||
* @return bool
|
||||
*/
|
||||
abstract public function setLoggedInUser($id);
|
||||
|
||||
/**
|
||||
* Returns identity URL of logged in user or false
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
abstract public function getLoggedInUser();
|
||||
|
||||
/**
|
||||
* Performs logout. Clears information about logged in user.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
abstract public function delLoggedInUser();
|
||||
}
|
104
library/Zend/OpenId/Provider/User/Session.php
Normal file
104
library/Zend/OpenId/Provider/User/Session.php
Normal file
|
@ -0,0 +1,104 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Zend Framework
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to the new BSD license that is bundled
|
||||
* with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://framework.zend.com/license/new-bsd
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@zend.com so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_OpenId
|
||||
* @subpackage Zend_OpenId_Provider
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: Session.php 20096 2010-01-06 02:05:09Z bkarwin $
|
||||
*/
|
||||
|
||||
/**
|
||||
* @see Zend_OpenId_Provider_User
|
||||
*/
|
||||
require_once "Zend/OpenId/Provider/User.php";
|
||||
|
||||
/**
|
||||
* @see Zend_Session_Namespace
|
||||
*/
|
||||
require_once "Zend/Session/Namespace.php";
|
||||
|
||||
/**
|
||||
* Class to get/store information about logged in user in Web Browser using
|
||||
* PHP session
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_OpenId
|
||||
* @subpackage Zend_OpenId_Provider
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_OpenId_Provider_User_Session extends Zend_OpenId_Provider_User
|
||||
{
|
||||
/**
|
||||
* Reference to an implementation of Zend_Session_Namespace object
|
||||
*
|
||||
* @var Zend_Session_Namespace $_session
|
||||
*/
|
||||
private $_session = null;
|
||||
|
||||
/**
|
||||
* Creates Zend_OpenId_Provider_User_Session object with given session
|
||||
* namespace or creates new session namespace named "openid"
|
||||
*
|
||||
* @param Zend_Session_Namespace $session
|
||||
*/
|
||||
public function __construct(Zend_Session_Namespace $session = null)
|
||||
{
|
||||
if ($session === null) {
|
||||
$this->_session = new Zend_Session_Namespace("openid");
|
||||
} else {
|
||||
$this->_session = $session;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Stores information about logged in user in session data
|
||||
*
|
||||
* @param string $id user identity URL
|
||||
* @return bool
|
||||
*/
|
||||
public function setLoggedInUser($id)
|
||||
{
|
||||
$this->_session->logged_in = $id;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns identity URL of logged in user or false
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function getLoggedInUser()
|
||||
{
|
||||
if (isset($this->_session->logged_in)) {
|
||||
return $this->_session->logged_in;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs logout. Clears information about logged in user.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function delLoggedInUser()
|
||||
{
|
||||
unset($this->_session->logged_in);
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue