Code

Updated logview to display the target object too.
[gosa.git] / include / class_password-methods.inc
1 <?php
2 /*
3    This code is part of GOsa (https://gosa.gonicus.de)
4    Copyright (C) 2004  Cajus Pollmeier
6    This program is free software; you can redistribute it and/or modify
7    it under the terms of the GNU General Public License as published by
8    the Free Software Foundation; either version 2 of the License, or
9    (at your option) any later version.
11    This program is distributed in the hope that it will be useful,
12    but WITHOUT ANY WARRANTY; without even the implied warranty of
13    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14    GNU General Public License for more details.
16    You should have received a copy of the GNU General Public License
17    along with this program; if not, write to the Free Software
18    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19  */
22 class passwordMethod
23 {
24   var $config = false;
25   var $attrs= array();
27   // Konstructor
28   function passwordMethod($config)
29   {
30   }
33   function get_hash_name()
34   {
35   }
37   // Loads Methods in annother way as  get_available_methods do, (For setup ..)
38   // and loads them,.
39   function get_available_methods_if_not_loaded($path_to_load="../include")
40   {
41     $oh = opendir($path_to_load);
42     $i = 0; 
43     $ret = false;
44     while ($file = readdir($oh)) {
45       $one = strtolower($file); 
46       if((strstr($one,"class_password-methods-" ))&&($one[0]!=".")){
47         require_once($file);
48       }
49     }
50     return(passwordMethod::get_available_methods());
51   }
55   // Crypts a single string, with given Method
56   function crypt_single_str($string,$method)
57   {
58     $available = passwordMethod::get_available_methods();
59     if(!is_array($available))
60     {
61       $available = passwordMethod::get_available_methods_if_not_loaded();
62     }
64     $test = new  $available[$method](false);
65     $newpass =  $test->generate_hash($string);
66     return( $newpass); 
67   }
70   // this function returns all loaded classes for password encryption
71   static function get_available_methods()
72   {
73     global $class_mapping, $config;
74     $ret =false;
75     $i =0;
76     foreach($class_mapping as $class => $path) {
77       if(preg_match('/passwordMethod/i', $class) && !preg_match("/^passwordMethod$/i", $class)){
78         $name = preg_replace ("/passwordMethod/i", "", $class);
79         $test = new $class($config);
80         if($test->is_available()) {
81           $plugname= $test->get_hash_name();
82           $ret['name'][$i]= $plugname;
83           $ret['class'][$i]=$class;
84           $ret[$i]['name']= $plugname;
85           $ret[$i]['class']= $class;
86           $ret[$plugname]=$class;                    
87           $i++;
88         }
89       }
90     }
91     return($ret);
92   }
93   
95   // Method to let password backends remove additional information besides
96   // the userPassword attribute
97   function remove_from_parent()
98   {
99   }
102   // Method to let passwords backends manage additional information
103   // besides the userAttribute entry
104   function set_password()
105   {
106   }
109   // Return true if this password method provides a configuration dialog
110   function is_configurable()
111   {
112     return FALSE;
113   }
116   // Provide a subdialog to configure a password method
117   function configure()
118   {
119     return "";
120   }
124 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
125 ?>