Code

Moved remaining kerberos stuff to the password method.
[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   }
32   // Loads Methods in annother way as  get_available_methods do, (For setup ..)
33   // and loads them,.
34   function get_available_methods_if_not_loaded($path_to_load="../include")
35   {
36     $oh = opendir($path_to_load);
37     $i = 0; 
38     $ret = false;
39     while ($file = readdir($oh)) {
40       $one = strtolower($file); 
41       if((strstr($one,"class_password-methods-" ))&&($one[0]!=".")){
42         require_once($file);
43       }
44     }
45     return(passwordMethod::get_available_methods());
46   }
51   // Crypts a single string, with given Method
52   function crypt_single_str($string,$method)
53   {
54     $available = passwordMethod::get_available_methods();
55     if(!is_array($available))
56     {
57       $available = passwordMethod::get_available_methods_if_not_loaded();
58     }
60     $test = new  $available[$method](false);
61     $newpass =  $test->generate_hash($string);
62     return( $newpass); 
63   }
66   // this function returns all loaded classes for password encryption
67   static function get_available_methods()
68   {
69     global $class_mapping;
70     $ret =false;
71     $i =0;
72     foreach($class_mapping as $class => $path) {
73       if(preg_match('/passwordMethod/i', $class) && !preg_match("/^passwordMethod$/i", $class)){
74         $name = preg_replace ("/passwordMethod/i", "", $class);
75         $test = new $class(false);
76         if($test->is_available()) {
77           $plugname= strtolower(preg_replace ("/passwordMethod/i","",$class));
78           $ret['name'][$i]= $plugname;
79           $ret['class'][$i]=$class;
80           $ret[$i]['name']= $plugname;
81           $ret[$i]['class']= $class;
82           $ret[$plugname]=$class;                    
83           $i++;
84         }
85       }
86     }
87     return($ret);
88   }
89   
91   function remove_from_parent()
92   {
93   }
95 }
96 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
97 ?>