Skip to content
Snippets Groups Projects
Commit 5a138976 authored by Tim van Dijen's avatar Tim van Dijen
Browse files

Replace SimpleSAML_AuthMemCookie with namespaced version

parent c858a2e0
No related branches found
No related tags found
No related merge requests found
<?php
namespace SimpleSAML;
/**
* This is a helper class for the Auth MemCookie module.
......@@ -10,17 +11,17 @@
*
* @deprecated This class has been deprecated and will be removed in SSP 2.0. Use the memcookie module instead.
*/
class SimpleSAML_AuthMemCookie
{
class AuthMemCookie
{
/**
* @var SimpleSAML_AuthMemCookie This is the singleton instance of this class.
* @var AuthMemCookie This is the singleton instance of this class.
*/
private static $instance = null;
/**
* @var \SimpleSAML\Configuration The configuration for Auth MemCookie.
* @var Configuration The configuration for Auth MemCookie.
*/
private $amcConfig;
......@@ -28,12 +29,12 @@ class SimpleSAML_AuthMemCookie
/**
* This function is used to retrieve the singleton instance of this class.
*
* @return SimpleSAML_AuthMemCookie The singleton instance of this class.
* @return AuthMemCookie The singleton instance of this class.
*/
public static function getInstance()
{
if (self::$instance === null) {
self::$instance = new SimpleSAML_AuthMemCookie();
self::$instance = new AuthMemCookie();
}
return self::$instance;
......@@ -46,7 +47,7 @@ class SimpleSAML_AuthMemCookie
private function __construct()
{
// load AuthMemCookie configuration
$this->amcConfig = \SimpleSAML\Configuration::getConfig('authmemcookie.php');
$this->amcConfig = Configuration::getConfig('authmemcookie.php');
}
......@@ -71,7 +72,7 @@ class SimpleSAML_AuthMemCookie
{
$cookieName = $this->amcConfig->getString('cookiename', 'AuthMemCookie');
if (!is_string($cookieName) || strlen($cookieName) === 0) {
throw new Exception(
throw new \Exception(
"Configuration option 'cookiename' contains an invalid value. This option should be a string."
);
}
......@@ -119,7 +120,7 @@ class SimpleSAML_AuthMemCookie
$class = class_exists('Memcache') ? 'Memcache' : (class_exists('Memcached') ? 'Memcached' : false);
if (!$class) {
throw new Exception('Missing Memcached implementation. You must install either the Memcache or Memcached extension.');
throw new \Exception('Missing Memcached implementation. You must install either the Memcache or Memcached extension.');
}
// Create the Memcache(d) object.
......
......@@ -24,7 +24,7 @@ try {
}
// load Auth MemCookie configuration
$amc = SimpleSAML_AuthMemCookie::getInstance();
$amc = \SimpleSAML\AuthMemCookie::getInstance();
$sourceId = $amc->getAuthSource();
$s = new \SimpleSAML\Auth\Simple($sourceId);
......@@ -33,7 +33,7 @@ try {
$s->requireAuth();
// generate session id and save it in a cookie
$sessionID = SimpleSAML\Utils\Random::generateID();
$sessionID = \SimpleSAML\Utils\Random::generateID();
$cookieName = $amc->getCookieName();
\SimpleSAML\Utils\HTTP::setCookie($cookieName, $sessionID);
......@@ -45,7 +45,7 @@ try {
// username
$usernameAttr = $amc->getUsernameAttr();
if (!array_key_exists($usernameAttr, $attributes)) {
throw new Exception(
throw new \Exception(
"The user doesn't have an attribute named '".$usernameAttr.
"'. This attribute is expected to contain the username."
);
......@@ -56,7 +56,7 @@ try {
$groupsAttr = $amc->getGroupsAttr();
if ($groupsAttr !== null) {
if (!array_key_exists($groupsAttr, $attributes)) {
throw new Exception(
throw new \Exception(
"The user doesn't have an attribute named '".$groupsAttr.
"'. This attribute is expected to contain the groups the user is a member of."
);
......@@ -97,10 +97,10 @@ try {
// register logout handler
$session = \SimpleSAML\Session::getSessionFromRequest();
$session->registerLogoutHandler($sourceId, 'SimpleSAML_AuthMemCookie', 'logoutHandler');
$session->registerLogoutHandler($sourceId, '\SimpleSAML\AuthMemCookie', 'logoutHandler');
// redirect the user back to this page to signal that the login is completed
\SimpleSAML\Utils\HTTP::redirectTrustedURL(\SimpleSAML\Utils\HTTP::getSelfURL());
} catch (Exception $e) {
} catch (\Exception $e) {
throw new \SimpleSAML\Error\Error('CONFIG', $e);
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment