applied Pavel's patch (2971792)

This commit is contained in:
Roland Gruber 2010-03-17 17:48:42 +00:00
parent 93ae34868a
commit 2da95e0d12
1 changed files with 30 additions and 7 deletions

View File

@ -3,8 +3,8 @@
$Id$ $Id$
This code is part of LDAP Account Manager (http://www.sourceforge.net/projects/lam) This code is part of LDAP Account Manager (http://www.sourceforge.net/projects/lam)
Copyright (C) 2009 Pavel Pozdnyak Copyright (C) 2009 - 2010 Pavel Pozdnyak
2009 Roland Gruber 2009 - 2010 Roland Gruber
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
@ -39,6 +39,8 @@ $Id$
*/ */
class asteriskAccount extends baseModule implements passwordService { class asteriskAccount extends baseModule implements passwordService {
private $asteriskDefaultRealm = "asterisk";
/** /**
* Creates a new asteriskAccount object. * Creates a new asteriskAccount object.
* *
@ -89,6 +91,18 @@ class asteriskAccount extends baseModule implements passwordService {
"Headline" => _("Password"), "Headline" => _("Password"),
"Text" => _("Please enter the password which you want to set for this account.") "Text" => _("Please enter the password which you want to set for this account.")
), ),
'AsteriskRealm' => array(
"Headline" => _("Asterisk realm"),
"Text" => _("Authentication realm for asterisk server (default: asterisk). This value set in sip.conf (option: \"realm\").")
),
);
// config options
$return['config_options']['user'] = array(
array(
array('kind' => 'text', 'text' => '<b>' . _("Users") . ': &nbsp;</b>' . _('Asterisk realm') . ": "),
array('kind' => 'input', 'name' => 'asteriskAccount_AsteriskRealm', 'type' => 'text', 'size' => '30', 'maxlength' => '255'),
array('kind' => 'help', 'value' => 'AsteriskRealm')
)
); );
// profile options // profile options
$return['profile_options'] = array( $return['profile_options'] = array(
@ -328,6 +342,7 @@ class asteriskAccount extends baseModule implements passwordService {
} }
/** /**
* This method specifies if a module manages password attributes. * This method specifies if a module manages password attributes.
* @see passwordService::managesPasswordAttributes * @see passwordService::managesPasswordAttributes
@ -352,7 +367,15 @@ class asteriskAccount extends baseModule implements passwordService {
if (!in_array(get_class($this), $modules)) { if (!in_array(get_class($this), $modules)) {
return array(); return array();
} }
$this->attributes['AstAccountRealmedPassword'][0] = $this->hashPassword($password); $astRealm = $this->asteriskDefaultRealm;
if ($this->get_scope()=='user') {
$asteriskRealmFromProfile = $this->moduleSettings['asteriskAccount_AsteriskRealm'][0];
if ($asteriskRealmFromProfile != ""){
$astRealm = $asteriskRealmFromProfile;
}
}
$password_con = $this->attributes['AstAccountCallerID'][0] . ":" . $astRealm . ":" . $password;
$this->attributes['AstAccountRealmedPassword'][0] = $this->hashPassword($password_con);
return array(); return array();
} }
@ -363,7 +386,7 @@ class asteriskAccount extends baseModule implements passwordService {
* @return String hash * @return String hash
*/ */
private function hashPassword($password) { private function hashPassword($password) {
return base64_encode(hex2bin(md5($password))); return "{MD5}" . md5($password);
} }
} }