File:
0.00.1a/core/auth/AuthenticationFactory.php (
View as Code)
1: 2: /* -------------------------------------------------------------
3: This file is part of FreeDESK
4:
5: FreeDESK is (C) Copyright 2012 David Cutting
6:
7: FreeDESK is free software: you can redistribute it and/or modify
8: it under the terms of the GNU General Public License as published by
9: the Free Software Foundation, either version 3 of the License, or
10: (at your option) any later version.
11:
12: FreeDESK is distributed in the hope that it will be useful,
13: but WITHOUT ANY WARRANTY; without even the implied warranty of
14: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15: GNU General Public License for more details.
16:
17: You should have received a copy of the GNU General Public License
18: along with FreeDESK. If not, see www.gnu.org/licenses
19:
20: For more information see www.purplepixie.org/freedesk/
21: -------------------------------------------------------------- */
22:
23: /**
24: * Authentication Factory - creates a concrete AuthMethod class as requested
25: **/
26: class AuthenticationFactory
27: {
28: /**
29: * Create class as asked for or return a bool false
30: * @param mixed &$DESK Current FreeDESK instance
31: * @param string $method Method of Authentication
32: * @return mixed Class on success or bool false on failure
33: **/
34: static function Create(&$DESK, $method)
35: {
36: $methods = $DESK->PluginManager->GetType("Auth");
37:
38: foreach($methods as $pmethod)
39: {
40: if ($method == $pmethod->subtype)
41: {
42: if (class_exists($pmethod->classname))
43: {
44: return new $pmethod->classname($DESK);
45: }
46: else
47: return false; // method found but illegal class
48: }
49: }
50: return false; // no method found
51: }
52: }
53:
54: ?>
55: