1 <?php
2 /*
3 * This code is part of GOsa (http://www.gosa-project.org)
4 * Copyright (C) 2003-2008 GONICUS GmbH
5 *
6 * ID: $$Id$$
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 */
23 class passwordMethod
24 {
25 var $config = false;
26 var $attrs= array();
28 // Konstructor
29 function passwordMethod($config)
30 {
31 }
34 function get_hash_name()
35 {
36 }
39 // Loads Methods in annother way as get_available_methods do, (For setup ..)
40 // and loads them,.
41 #FIXME: This stopped working after moving around pw-methods
42 function get_available_methods_if_not_loaded($path_to_load="../include")
43 {
44 $oh = opendir($path_to_load);
45 $i = 0;
46 $ret = false;
47 while ($file = readdir($oh)) {
48 $one = strtolower($file);
49 if((strstr($one,"class_password-methods-" ))&&($one[0]!=".")){
50 require_once($file);
51 }
52 }
53 return(passwordMethod::get_available_methods());
54 }
57 // Crypts a single string, with given Method
58 function crypt_single_str($string,$method)
59 {
60 $available = passwordMethod::get_available_methods();
61 if(!is_array($available))
62 {
63 $available = passwordMethod::get_available_methods_if_not_loaded();
64 }
66 $test = new $available[$method](false);
67 $newpass = $test->generate_hash($string);
68 return( $newpass);
69 }
72 // this function returns all loaded classes for password encryption
73 static function get_available_methods()
74 {
75 global $class_mapping, $config;
76 $ret =false;
77 $i =0;
78 foreach($class_mapping as $class => $path) {
79 if(preg_match('/passwordMethod/i', $class) && !preg_match("/^passwordMethod$/i", $class)){
80 $name = preg_replace ("/passwordMethod/i", "", $class);
81 $test = new $class($config);
82 if($test->is_available()) {
83 $plugname= $test->get_hash_name();
84 $ret['name'][$i]= $plugname;
85 $ret['class'][$i]=$class;
86 $ret[$i]['name']= $plugname;
87 $ret[$i]['class']= $class;
88 $ret[$plugname]=$class;
89 $i++;
90 }
91 }
92 }
93 return($ret);
94 }
97 // Method to let password backends remove additional information besides
98 // the userPassword attribute
99 function remove_from_parent()
100 {
101 }
104 // Method to let passwords backends manage additional information
105 // besides the userAttribute entry
106 function set_password($password)
107 {
108 }
111 // Return true if this password method provides a configuration dialog
112 function is_configurable()
113 {
114 return FALSE;
115 }
118 // Provide a subdialog to configure a password method
119 function configure()
120 {
121 return "";
122 }
125 // Save information to LDAP
126 function save($dn)
127 {
128 }
131 }
132 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
133 ?>