Code

Updated gotomasses.
[gosa.git] / gosa-core / include / password-methods / 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   }
38   // Loads Methods in annother way as  get_available_methods do, (For setup ..)
39   // and loads them,.
40   #FIXME: This stopped working after moving around pw-methods
41   function get_available_methods_if_not_loaded($path_to_load="../include")
42   {
43     $oh = opendir($path_to_load);
44     $i = 0; 
45     $ret = false;
46     while ($file = readdir($oh)) {
47       $one = strtolower($file); 
48       if((strstr($one,"class_password-methods-" ))&&($one[0]!=".")){
49         require_once($file);
50       }
51     }
52     return(passwordMethod::get_available_methods());
53   }
56   // Crypts a single string, with given Method
57   function crypt_single_str($string,$method)
58   {
59     $available = passwordMethod::get_available_methods();
60     if(!is_array($available))
61     {
62       $available = passwordMethod::get_available_methods_if_not_loaded();
63     }
65     $test = new  $available[$method](false);
66     $newpass =  $test->generate_hash($string);
67     return( $newpass); 
68   }
71   // this function returns all loaded classes for password encryption
72   static function get_available_methods()
73   {
74     global $class_mapping, $config;
75     $ret =false;
76     $i =0;
77     foreach($class_mapping as $class => $path) {
78       if(preg_match('/passwordMethod/i', $class) && !preg_match("/^passwordMethod$/i", $class)){
79         $name = preg_replace ("/passwordMethod/i", "", $class);
80         $test = new $class($config);
81         if($test->is_available()) {
82           $plugname= $test->get_hash_name();
83           $ret['name'][$i]= $plugname;
84           $ret['class'][$i]=$class;
85           $ret[$i]['name']= $plugname;
86           $ret[$i]['class']= $class;
87           $ret[$plugname]=$class;                    
88           $i++;
89         }
90       }
91     }
92     return($ret);
93   }
94   
96   // Method to let password backends remove additional information besides
97   // the userPassword attribute
98   function remove_from_parent()
99   {
100   }
103   // Method to let passwords backends manage additional information
104   // besides the userAttribute entry
105   function set_password($password)
106   {
107   }
110   // Return true if this password method provides a configuration dialog
111   function is_configurable()
112   {
113     return FALSE;
114   }
117   // Provide a subdialog to configure a password method
118   function configure()
119   {
120     return "";
121   }
123   
124   // Save information to LDAP
125   function save($dn)
126   {
127   }
131 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
132 ?>