This commit is contained in:
Laurent Destailleur 2011-09-24 13:44:04 +00:00
parent 351380aa87
commit b8c0e5e408
5 changed files with 81 additions and 59 deletions

View File

@ -43,10 +43,10 @@ class modGeneratePassNone extends ModeleGenPassword
/** /**
* Constructor * Constructor
* *
* @param DoliDB $DB Database handler * @param DoliDB $db Database handler
* @param conf Handler de conf * @param Conf $conf Handler de conf
* @param lang Handler de langue * @param Translate $langs Handler de langue
* @param user Handler du user connecte * @param User $user Handler du user connecte
*/ */
function modGeneratePassNone($db, $conf, $langs, $user) function modGeneratePassNone($db, $conf, $langs, $user)
{ {
@ -61,6 +61,7 @@ class modGeneratePassNone extends ModeleGenPassword
/** /**
* Return description of module * Return description of module
*
* @return string Description of text * @return string Description of text
*/ */
function getDescription() function getDescription()
@ -71,6 +72,7 @@ class modGeneratePassNone extends ModeleGenPassword
/** /**
* Return an example of password generated by this module * Return an example of password generated by this module
*
* @return string Example of password * @return string Example of password
*/ */
function getExample() function getExample()
@ -80,6 +82,7 @@ class modGeneratePassNone extends ModeleGenPassword
/** /**
* Build new password * Build new password
*
* @return string Return a new generated password * @return string Return a new generated password
*/ */
function getNewGeneratedPassword() function getNewGeneratedPassword()
@ -89,7 +92,9 @@ class modGeneratePassNone extends ModeleGenPassword
/** /**
* Validate a password * Validate a password
* @return int 0 if KO, >0 if OK *
* @param string $password Password to check
* @return int 0 if KO, >0 if OK
*/ */
function validatePassword($password) function validatePassword($password)
{ {

View File

@ -43,10 +43,10 @@ class modGeneratePassStandard extends ModeleGenPassword
/** /**
* Constructor * Constructor
* *
* @param DoliDB $DB Database handler * @param DoliDB $db Database handler
* @param conf Handler de conf * @param Conf $conf Handler de conf
* @param lang Handler de langue * @param Translate $langs Handler de langue
* @param user Handler du user connecte * @param User $user Handler du user connecte
*/ */
function modGeneratePassStandard($db, $conf, $langs, $user) function modGeneratePassStandard($db, $conf, $langs, $user)
{ {
@ -61,6 +61,7 @@ class modGeneratePassStandard extends ModeleGenPassword
/** /**
* Return description of module * Return description of module
*
* @return string Description of module * @return string Description of module
*/ */
function getDescription() function getDescription()
@ -71,6 +72,7 @@ class modGeneratePassStandard extends ModeleGenPassword
/** /**
* Return an example of password generated by this module * Return an example of password generated by this module
*
* @return string Example of password * @return string Example of password
*/ */
function getExample() function getExample()
@ -80,6 +82,7 @@ class modGeneratePassStandard extends ModeleGenPassword
/** /**
* Build new password * Build new password
*
* @return string Return a new generated password * @return string Return a new generated password
*/ */
function getNewGeneratedPassword() function getNewGeneratedPassword()
@ -115,7 +118,9 @@ class modGeneratePassStandard extends ModeleGenPassword
/** /**
* Validate a password * Validate a password
* @return int 0 if KO, >0 if OK *
* @param string $password Password to check
* @return int 0 if KO, >0 if OK
*/ */
function validatePassword($password) function validatePassword($password)
{ {

View File

@ -1,5 +1,5 @@
<?php <?php
/* Copyright (C) 2007-2009 Laurent Destailleur <eldy@users.sourceforge.net> /* Copyright (C) 2007-2011 Laurent Destailleur <eldy@users.sourceforge.net>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -30,54 +30,62 @@ require_once(DOL_DOCUMENT_ROOT.'/lib/functions.lib.php');
*/ */
abstract class ModeleGenPassword abstract class ModeleGenPassword
{ {
var $error=''; var $error='';
/** \brief Return if a module can be used or not /**
* \return boolean true if module can be used * Return if a module can be used or not
*/ *
function isEnabled() * @return boolean true if module can be used
{ */
return true; function isEnabled()
} {
return true;
}
/** \brief Renvoi la description par defaut du modele /**
* \return string Texte descripif * Return description of module
*/ *
function info() * @return string Description of text
{ */
global $langs; function getDescription()
$langs->load("bills"); {
return $langs->trans("NoDescription"); global $langs;
} return $langs->trans("NoDescription");
}
/** \brief Renvoi un exemple de generation /**
* \return string Example * Return an example of password generated by this module
*/ *
function getExample() * @return string Example of password
{ */
global $langs; function getExample()
$langs->load("bills"); {
return $langs->trans("NoExample"); global $langs;
} $langs->load("bills");
return $langs->trans("NoExample");
}
/** /**
* \brief Build new password * Build new password
* \return string Return a new generated password *
* @return string Return a new generated password
*/ */
function getNewGeneratedPassword() function getNewGeneratedPassword()
{ {
global $langs; global $langs;
return $langs->trans("NotAvailable"); return $langs->trans("NotAvailable");
} }
/** /**
* \brief Validate a password * Validate a password
* \return int 0 if KO, >0 if OK *
* @param string $password Password to check
* @return int 0 if KO, >0 if OK
*/ */
function validatePassword($password) function validatePassword($password)
{ {
return 1; return 1;
} }
} }

View File

@ -18,8 +18,11 @@
*/ */
/** /**
* \file htdocs/lib/security.lib.php * \file htdocs/lib/security.lib.php
* \brief Set of function used for dolibarr security * \ingroup core
* \brief Set of function used for dolibarr security.
* Warning, this file must not depends on other library files, except function.lib.php
* because it is used at low code level.
*/ */
@ -28,8 +31,8 @@
* *
* @param string $usertotest Login value to test * @param string $usertotest Login value to test
* @param string $passwordtotest Password value to test * @param string $passwordtotest Password value to test
* @param string $entitytotest Instance to test * @param string $entitytotest Instance of data we must check
* @param array $authmode Array list of selected authentication mode ('http', 'dolibarr', 'xxx'...) * @param array $authmode Array list of selected authentication mode array('http', 'dolibarr', 'xxx'...)
* @return string Login or '' * @return string Login or ''
*/ */
function checkLoginPassEntity($usertotest,$passwordtotest,$entitytotest,$authmode) function checkLoginPassEntity($usertotest,$passwordtotest,$entitytotest,$authmode)
@ -44,14 +47,14 @@ function checkLoginPassEntity($usertotest,$passwordtotest,$entitytotest,$authmod
$login = ''; $login = '';
// Validation of login/pass/entity with a third party login module method // Validation of login/pass/entity with a third party login module method
if (is_array($conf->login_method_modules) && !empty($conf->login_method_modules)) if (! empty($conf->login_method_modules) && is_array($conf->login_method_modules))
{ {
foreach($conf->login_method_modules as $dir) foreach($conf->login_method_modules as $dir)
{ {
$newdir=dol_osencode($dir); $newdir=dol_osencode($dir);
// Check if directory exists // Check if directory exists
if (!is_dir($newdir)) continue; if (! is_dir($newdir)) continue;
$handle=opendir($newdir); $handle=opendir($newdir);
if (is_resource($handle)) if (is_resource($handle))
@ -324,7 +327,7 @@ function dol_loginfunction($langs,$conf,$mysoc)
} }
/** /**
* Fonction pour initialiser un salt pour la fonction crypt * Fonction pour initialiser un salt pour la fonction crypt.
* *
* @param int $type 2=>renvoi un salt pour cryptage DES * @param int $type 2=>renvoi un salt pour cryptage DES
* 12=>renvoi un salt pour cryptage MD5 * 12=>renvoi un salt pour cryptage MD5
@ -338,7 +341,7 @@ function makesalt($type=CRYPT_SALT_LENGTH)
{ {
case 12: // 8 + 4 case 12: // 8 + 4
$saltlen=8; $saltprefix='$1$'; $saltsuffix='$'; break; $saltlen=8; $saltprefix='$1$'; $saltsuffix='$'; break;
case 8: // 8 + 4 (Pour compatibilite, ne devrait pas etre utilise) case 8: // 8 (Pour compatibilite, ne devrait pas etre utilise)
$saltlen=8; $saltprefix='$1$'; $saltsuffix='$'; break; $saltlen=8; $saltprefix='$1$'; $saltsuffix='$'; break;
case 2: // 2 case 2: // 2
default: // by default, fall back on Standard DES (should work everywhere) default: // by default, fall back on Standard DES (should work everywhere)
@ -497,7 +500,7 @@ function dol_decode($chain)
/** /**
* Return a generated password using default module * Return a generated password using default module
* *
* @param boolean $generic Create generic password * @param boolean $generic true=Create generic password (a MD5 string), false=Use the configured password generation module
* @return string New value for password * @return string New value for password
*/ */
function getRandomPassword($generic=false) function getRandomPassword($generic=false)

View File

@ -18,6 +18,7 @@
/** /**
* \file htdocs/lib/ws.lib.php * \file htdocs/lib/ws.lib.php
* \ingroup webservices
* \brief Set of function for manipulating web services * \brief Set of function for manipulating web services
*/ */