Permalink
Browse files

merge jelix-1.3.x

  • Loading branch information...
2 parents f6a359c + 14862ea commit a128eda7232505868df7ef4520cc4230df64c31f @laurentj laurentj committed Sep 25, 2012
Showing with 604 additions and 151 deletions.
  1. +1 −0 README.md
  2. +1 −0 build/manifests/jelix-modules.mn
  3. +0 −1 lib/installwizard/pages/dbprofile/dbprofile.page.php
  4. +3 −1 lib/jelix-admin-modules/master_admin/controllers/default.classic.php
  5. +1 −1 lib/jelix-modules/jacl/plugins/coord/jacl/jacl.coord.php
  6. +1 −1 lib/jelix-modules/jacl2/plugins/coord/jacl2/jacl2.coord.php
  7. +267 −0 lib/jelix-modules/jauth/classes/password.php
  8. +1 −1 lib/jelix-modules/jauthdb/daos/jelixuser.dao.xml
  9. +5 −4 lib/jelix-modules/jauthdb/install/install.php
  10. +1 −1 lib/jelix-modules/jauthdb/install/install_jauth.schema.mysql.sql
  11. +1 −1 lib/jelix-modules/jauthdb/install/install_jauth.schema.pgsql.sql
  12. +1 −1 lib/jelix-modules/jauthdb/install/install_jauth.schema.sqlite.sql
  13. +1 −0 lib/jelix-plugins/cache/file/file.cache.php
  14. +2 −0 lib/jelix-scripts/commands/initadmin.cmd.php
  15. +1 −0 lib/jelix-scripts/commands/resetfilesrights.cmd.php
  16. +36 −45 lib/jelix-tests/classes/junittestcase.class.php
  17. +100 −32 lib/jelix/auth/jAuth.class.php
  18. +45 −2 lib/jelix/auth/jAuthDriverBase.class.php
  19. +2 −2 lib/jelix/core/jApp.class.php
  20. +3 −1 lib/jelix/core/jBasicErrorHandler.class.php
  21. +2 −2 lib/jelix/core/jCoordinator.class.php
  22. +3 −1 lib/jelix/core/response/jResponseBasicHtml.class.php
  23. +4 −2 lib/jelix/core/response/jResponseSitemap.class.php
  24. +1 −1 lib/jelix/dao/jDaoFactoryBase.class.php
  25. +1 −1 lib/jelix/dao/jDaoGenerator.class.php
  26. +7 −7 lib/jelix/db/jDbTable.class.php
  27. +16 −3 lib/jelix/plugins/auth/class/class.auth.php
  28. +17 −3 lib/jelix/plugins/auth/db/db.auth.php
  29. +4 −4 lib/jelix/plugins/auth/ldap/ldap.auth.php
  30. +16 −0 lib/jelix/plugins/coord/auth/auth.coord.ini.php.dist
  31. +1 −1 lib/jelix/plugins/coord/auth/auth.coord.php
  32. +1 −1 lib/jelix/plugins/db/mysql/mysql.dbschema.php
  33. +1 −0 lib/jelix/plugins/debugbar/soaplog/soaplog.debugbar.php
  34. +1 −0 lib/jelix/plugins/tpl/html/meta.html.php
  35. +24 −3 lib/jelix/utils/jSoapClient.class.php
  36. +1 −0 testapp/modules/jelix_tests/classes/testAuthDriver.class.php
  37. +7 −4 testapp/modules/jelix_tests/tests/jacl.main_api.html_cli.php
  38. +5 −3 testapp/modules/jelix_tests/tests/jacl2_main_api.lib.php
  39. +7 −8 testapp/modules/jelix_tests/tests/jdb.pgsql.html_cli.php
  40. +2 −2 testapp/tests-jelix/jelix/kvdb/jkvdb.lib.php
  41. +10 −11 testapp/tests-jelix/jelix/utils/jMailerTest.php
View
1 README.md
@@ -22,6 +22,7 @@ Read [the first chapter of the manual to install Jelix and to create an applicat
Documentation and community
===========================
+
You have a full manual to learn Jelix. You can read it [direcly on the website](http://docs.jelix.org/en/manual-1.5),
or you can [download the PDF edition](http://download.jelix.org/jelix/documentation/en/manual-jelix-1.5.pdf).
View
1 build/manifests/jelix-modules.mn
@@ -148,6 +148,7 @@ cd lib/jelix-modules/jauth
urls_ws.xml
cd lib/jelix-modules/jauth/classes
! jauth.listener.php
+ password.php
cd lib/jelix-modules/jauth/controllers
! login.classic.php
! loginsw.classic.php
View
1 lib/installwizard/pages/dbprofile/dbprofile.page.php
@@ -340,7 +340,6 @@ protected function check_mysql($params) {
protected function check_oci($params) {
throw new Exception('oci not supported');
- return false;
}
protected function check_pgsql($params) {
View
4 lib/jelix-admin-modules/master_admin/controllers/default.classic.php
@@ -23,7 +23,9 @@ function index() {
$resp->title = jLocale::get('gui.dashboard.title');
$resp->body->assignZone('MAIN','dashboard');
$user = jAuth::getUserSession();
- if ($user->login == 'admin' && ($user->password == md5('admin') || $user->password == sha1('admin'))) {
+ $driver = jAuth::getDriver();
+ if (method_exists($driver, 'checkPassword') &&
+ $user->login == 'admin' && $driver->checkPassword('admin', $user->password)) {
jMessage::add(jLocale::get('gui.message.admin.password'), 'error');
}
$resp->body->assign('selectedMenuItem','dashboard');
View
2 lib/jelix-modules/jacl/plugins/coord/jacl/jacl.coord.php
@@ -50,7 +50,7 @@ public function beforeAction ($params){
}
if(!$aclok){
- if($this->config['on_error'] == 1
+ if(jApp::coord()->request->isAjax() || $this->config['on_error'] == 1
|| !jApp::coord()->request->isAllowedResponse('jResponseRedirect')){
throw new jException($this->config['error_message']);
}else{
View
2 lib/jelix-modules/jacl2/plugins/coord/jacl2/jacl2.coord.php
@@ -51,7 +51,7 @@ public function beforeAction ($params){
}
if(!$aclok){
- if($this->config['on_error'] == 1
+ if(jApp::coord()->request->isAjax() || $this->config['on_error'] == 1
|| !jApp::coord()->request->isAllowedResponse('jResponseRedirect')){
throw new jException($this->config['error_message']);
}else{
View
267 lib/jelix-modules/jauth/classes/password.php
@@ -0,0 +1,267 @@
+<?php
+/**
+ * A Compatibility library with PHP 5.5's simplified password hashing API.
+ *
+ * @author Anthony Ferrara <ircmaxell@php.net>
+ * @contributor Laurent Jouanneau <laurent@jelix.org>
+ * @license http://www.opensource.org/licenses/mit-license.html MIT License
+ * @copyright 2012 The Authors
+ */
+
+ /**
+ * function to check if the password API can be used
+ * In some PHP version ( <5.3.7), crypt() with blowfish is vulnerable.
+ * But this issue has been fixed on some older PHP version (php 5.3.3 for most of them) in some
+ * distro, like Debian squeeze.
+ * @see http://www.php.net/security/crypt_blowfish.php
+ */
+function can_use_password_API () {
+ if (version_compare(PHP_VERSION, '5.3.7', '>=')) {
+ if (!defined('_PASSWORD_CRYPT_HASH_FORMAT'))
+ define('_PASSWORD_CRYPT_HASH_FORMAT', '$2y$%02d$');
+ if (!defined('_PASSWORD_CRYPT_PROLOG'))
+ define('_PASSWORD_CRYPT_PROLOG', '$2y$');
+ return true;
+ }
+ if (version_compare(PHP_VERSION, '5.3.3', '<')) {
+ return false;
+ }
+ // On debian squeeze, crypt() has been fixed in PHP 5.3.3
+ // http://security-tracker.debian.org/tracker/CVE-2011-2483
+ // so we can use crypt() securely with $2a$ ($2y$ is not available)
+ if (preg_match('/squeeze(\d+)$/', PHP_VERSION, $m)) {
+ if (intval($m[1]) >= 4) {
+ if (!defined('_PASSWORD_CRYPT_HASH_FORMAT'))
+ define('_PASSWORD_CRYPT_HASH_FORMAT', '$2a$%02d$');
+ if (!defined('_PASSWORD_CRYPT_PROLOG'))
+ define('_PASSWORD_CRYPT_PROLOG', '$2a$');
+ return true;
+ }
+ }
+ //FIXME crypt() in PHP 5.3.3 is fixed also on other distro like RedHat.
+ // however I don't know if it supports 2y, and how does PHP_VERSION look like
+ return false;
+}
+
+
+
+if (!can_use_password_API()) {
+ trigger_error("The Password Compatibility Library requires PHP >= 5.3.7 or PHP >= 5.3.3-7+squeeze4 on debian", E_USER_WARNING);
+ // Prevent defining the functions
+ return;
+}
+
+if (!defined('PASSWORD_BCRYPT')) {
+
+ define('PASSWORD_BCRYPT', 1);
+ define('PASSWORD_DEFAULT', PASSWORD_BCRYPT);
+
+ /**
+ * Hash the password using the specified algorithm
+ *
+ * @param string $password The password to hash
+ * @param int $algo The algorithm to use (Defined by PASSWORD_* constants)
+ * @param array $options The options for the algorithm to use
+ *
+ * @returns string|false The hashed password, or false on error.
+ */
+ function password_hash($password, $algo, array $options = array()) {
+ if (!function_exists('crypt')) {
+ trigger_error("Crypt must be loaded for password_hash to function", E_USER_WARNING);
+ return null;
+ }
+ if (!is_string($password)) {
+ trigger_error("password_hash(): Password must be a string", E_USER_WARNING);
+ return null;
+ }
+ if (!is_int($algo)) {
+ trigger_error("password_hash() expects parameter 2 to be long, " . gettype($algo) . " given", E_USER_WARNING);
+ return null;
+ }
+ switch ($algo) {
+ case PASSWORD_BCRYPT:
+ // Note that this is a C constant, but not exposed to PHP, so we don't define it here.
+ $cost = 10;
+ if (isset($options['cost'])) {
+ $cost = $options['cost'];
+ if ($cost < 4 || $cost > 31) {
+ trigger_error(sprintf("password_hash(): Invalid bcrypt cost parameter specified: %d", $cost), E_USER_WARNING);
+ return null;
+ }
+ }
+ $required_salt_len = 22;
+ $hash_format = sprintf(_PASSWORD_CRYPT_HASH_FORMAT, $cost);
+ break;
+ default:
+ trigger_error(sprintf("password_hash(): Unknown password hashing algorithm: %s", $algo), E_USER_WARNING);
+ return null;
+ }
+ if (isset($options['salt'])) {
+ switch (gettype($options['salt'])) {
+ case 'NULL':
+ case 'boolean':
+ case 'integer':
+ case 'double':
+ case 'string':
+ $salt = (string) $options['salt'];
+ break;
+ case 'object':
+ if (method_exists($options['salt'], '__tostring')) {
+ $salt = (string) $options['salt'];
+ break;
+ }
+ case 'array':
+ case 'resource':
+ default:
+ trigger_error('password_hash(): Non-string salt parameter supplied', E_USER_WARNING);
+ return null;
+ }
+ if (strlen($salt) < $required_salt_len) {
+ trigger_error(sprintf("password_hash(): Provided salt is too short: %d expecting %d", strlen($salt), $required_salt_len), E_USER_WARNING);
+ return null;
+ } elseif (0 == preg_match('#^[a-zA-Z0-9./]+$#D', $salt)) {
+ $salt = str_replace('+', '.', base64_encode($salt));
+ }
+ } else {
+ $buffer = '';
+ $raw_length = (int) ($required_salt_len * 3 / 4 + 1);
+ $buffer_valid = false;
+ if (function_exists('mcrypt_create_iv')) {
+ $buffer = mcrypt_create_iv($raw_length, MCRYPT_DEV_URANDOM);
+ if ($buffer) {
+ $buffer_valid = true;
+ }
+ }
+ if (!$buffer_valid && function_exists('openssl_random_pseudo_bytes')) {
+ $buffer = openssl_random_pseudo_bytes($raw_length);
+ if ($buffer) {
+ $buffer_valid = true;
+ }
+ }
+ if (!$buffer_valid && file_exists('/dev/urandom')) {
+ $f = @fopen('/dev/urandom', 'r');
+ if ($f) {
+ $read = strlen($buffer);
+ while ($read < $raw_length) {
+ $buffer .= fread($f, $raw_length - $read);
+ $read = strlen($buffer);
+ }
+ fclose($f);
+ if ($read >= $raw_length) {
+ $buffer_valid = true;
+ }
+ }
+ }
+ if (!$buffer_valid || strlen($buffer) < $raw_length) {
+ $bl = strlen($buffer);
+ for ($i = 0; $i < $raw_length; $i++) {
+ if ($i < $bl) {
+ $buffer[$i] = $buffer[$i] ^ chr(mt_rand(0, 255));
+ } else {
+ $buffer .= chr(mt_rand(0, 255));
+ }
+ }
+ }
+ $salt = str_replace('+', '.', base64_encode($buffer));
+
+ }
+ $salt = substr($salt, 0, $required_salt_len);
+
+ $hash = $hash_format . $salt;
+
+ $ret = crypt($password, $hash);
+
+ if (!is_string($ret) || strlen($ret) <= 13) {
+ return false;
+ }
+
+ return $ret;
+ }
+
+ /**
+ * Get information about the password hash. Returns an array of the information
+ * that was used to generate the password hash.
+ *
+ * array(
+ * 'algo' => 1,
+ * 'algoName' => 'bcrypt',
+ * 'options' => array(
+ * 'cost' => 10,
+ * ),
+ * )
+ *
+ * @param string $hash The password hash to extract info from
+ *
+ * @return array The array of information about the hash.
+ */
+ function password_get_info($hash) {
+ $return = array(
+ 'algo' => 0,
+ 'algoName' => 'unknown',
+ 'options' => array(),
+ );
+ if (substr($hash, 0, 4) == _PASSWORD_CRYPT_PROLOG && strlen($hash) == 60) {
+ $return['algo'] = PASSWORD_BCRYPT;
+ $return['algoName'] = 'bcrypt';
+ list($cost) = sscanf($hash, _PASSWORD_CRYPT_HASH_FORMAT);
+ $return['options']['cost'] = $cost;
+ }
+ return $return;
+ }
+
+ /**
+ * Determine if the password hash needs to be rehashed according to the options provided
+ *
+ * If the answer is true, after validating the password using password_verify, rehash it.
+ *
+ * @param string $hash The hash to test
+ * @param int $algo The algorithm used for new password hashes
+ * @param array $options The options array passed to password_hash
+ *
+ * @return boolean True if the password needs to be rehashed.
+ */
+ function password_needs_rehash($hash, $algo, array $options = array()) {
+ $info = password_get_info($hash);
+ if ($info['algo'] != $algo) {
+ return true;
+ }
+ switch ($algo) {
+ case PASSWORD_BCRYPT:
+ $cost = isset($options['cost']) ? $options['cost'] : 10;
+ if ($cost != $info['options']['cost']) {
+ return true;
+ }
+ break;
+ }
+ return false;
+ }
+
+ /**
+ * Verify a password against a hash using a timing attack resistant approach
+ *
+ * @param string $password The password to verify
+ * @param string $hash The hash to verify against
+ *
+ * @return boolean If the password matches the hash
+ */
+ function password_verify($password, $hash) {
+ if (!function_exists('crypt')) {
+ trigger_error("Crypt must be loaded for password_verify to function", E_USER_WARNING);
+ return false;
+ }
+ $ret = crypt($password, $hash);
+ if (!is_string($ret) || strlen($ret) != strlen($hash) || strlen($ret) <= 13) {
+ return false;
+ }
+
+ $status = 0;
+ for ($i = 0; $i < strlen($ret); $i++) {
+ $status |= (ord($ret[$i]) ^ ord($hash[$i]));
+ }
+
+ return $status === 0;
+ }
+}
+
+
+
View
2 lib/jelix-modules/jauthdb/daos/jelixuser.dao.xml
@@ -11,7 +11,7 @@
datatype="string" required="yes" maxlength="255" />
<property name="password" fieldname="usr_password" datatype="string"
- maxlength="50" selectpattern="%s" updatepattern="" insertpattern="%s" />
+ maxlength="120" selectpattern="%s" updatepattern="" insertpattern="%s" />
</record>
<factory>
<method name="getByLoginPassword" type="selectfirst">
View
9 lib/jelix-modules/jauthdb/install/install.php
@@ -48,13 +48,14 @@ function install() {
if ($this->getParameter('defaultuser')) {
require_once(JELIX_LIB_PATH.'auth/jAuth.class.php');
require_once(JELIX_LIB_PATH.'plugins/auth/db/db.auth.php');
- $confIni = parse_ini_file(jApp::configPath($authconfig), true);
- $driver = new dbAuthDriver($confIni['Db']);
- $password = $driver->cryptPassword('admin');
+ $confIni = parse_ini_file(jApp::configPath($authconfig), true);
+ $authConfig = jAuth::loadConfig($confIni);
+ $driver = new dbAuthDriver($authConfig['Db']);
+ $passwordHash = $driver->cryptPassword('admin');
$cn = $this->dbConnection();
$cn->exec("INSERT INTO ".$cn->prefixTable('jlx_user')." (usr_login, usr_password, usr_email ) VALUES
- ('admin', ".$cn->quote($password)." , 'admin@localhost.localdomain')");
+ ('admin', ".$cn->quote($passwordHash)." , 'admin@localhost.localdomain')");
}
}
}
View
2 lib/jelix-modules/jauthdb/install/install_jauth.schema.mysql.sql
@@ -1,7 +1,7 @@
CREATE TABLE IF NOT EXISTS `%%PREFIX%%jlx_user` (
`usr_login` varchar(50) NOT NULL DEFAULT '',
- `usr_password` varchar(50) NOT NULL DEFAULT '',
+ `usr_password` varchar(120) NOT NULL DEFAULT '',
`usr_email` varchar(255) NOT NULL DEFAULT '',
PRIMARY KEY (`usr_login`)
) ENGINE=MyISAM ;
View
2 lib/jelix-modules/jauthdb/install/install_jauth.schema.pgsql.sql
@@ -1,6 +1,6 @@
CREATE TABLE %%PREFIX%%jlx_user (
usr_login character varying(50) NOT NULL DEFAULT '',
- usr_password character varying(50) NOT NULL DEFAULT '',
+ usr_password character varying(120) NOT NULL DEFAULT '',
usr_email character varying(255) NOT NULL DEFAULT ''
);
View
2 lib/jelix-modules/jauthdb/install/install_jauth.schema.sqlite.sql
@@ -1,6 +1,6 @@
CREATE TABLE %%PREFIX%%jlx_user (
usr_login varchar(50) NOT NULL DEFAULT '',
- usr_password varchar(50) NOT NULL DEFAULT '',
+ usr_password varchar(120) NOT NULL DEFAULT '',
usr_email varchar(255) NOT NULL DEFAULT '',
PRIMARY KEY (usr_login)
);
View
1 lib/jelix-plugins/cache/file/file.cache.php
@@ -248,6 +248,7 @@ public function decrement ($key,$var=1){
}
return ( $this->set($key,(int)$data,filemtime($this->_getCacheFilePath($key))) ) ? (int)$data : false;
}
+ return false;
}
/**
View
2 lib/jelix-scripts/commands/initadmin.cmd.php
@@ -92,6 +92,8 @@ public function run(){
$inifile->setValue('modulesPath', 'lib:jelix-admin-modules/,'.$modulePath, 0, null, true);
}
+ $installConfig->setValue('jacl.installed', '0', $entrypoint);
+ $inifile->setValue('jacl.access', '0', 'modules');
$installConfig->setValue('jacldb.installed', '0', $entrypoint);
$inifile->setValue('jacldb.access', '0', 'modules');
$installConfig->setValue('junittests.installed', '0', $entrypoint);
View
1 lib/jelix-scripts/commands/resetfilesrights.cmd.php
@@ -79,5 +79,6 @@ protected function setRights($path) {
}
unset($dir);
unset($dirContent);
+ return true;
}
}
View
81 lib/jelix-tests/classes/junittestcase.class.php
@@ -88,11 +88,11 @@ function _checkIdentical($xml, $value, $name, $errormessage){
$nodename = dom_import_simplexml($xml)->nodeName;
switch($nodename){
case 'object':
- if(isset($xml['class'])){
- $ok = $this->assertInternalType((string)$xml['class'], $value, $name.': not a '.(string)$xml['class'].' object'.$errormessage);
- }else
- $ok = $this->assertTrue(is_object($value), $name.': not an object'.$errormessage);
- if(!$ok) return false;
+ if (isset($xml['class'])) {
+ $this->assertInstanceOf((string)$xml['class'], $value, $name.': not a '.(string)$xml['class'].' object'.$errormessage);
+ } else {
+ $this->assertTrue(is_object($value), $name.': not an object'.$errormessage);
+ }
foreach ($xml->children() as $child) {
if(isset($child['property'])){
@@ -111,23 +111,18 @@ function _checkIdentical($xml, $value, $name, $errormessage){
trigger_error('no method or attribute on '.(dom_import_simplexml($child)->nodeName), E_USER_WARNING);
continue;
}
- $ok &= $this->_checkIdentical($child, $v, $name.'->'.$n,$errormessage);
+ $this->_checkIdentical($child, $v, $name.'->'.$n,$errormessage);
}
-
- if(!$ok)
- $this->fail($name.' : non identical objects'.$errormessage);
- return $ok;
+ return true;
case 'array':
- $ok = $this->assertInternalType('array', $value, $name.': not an array'.$errormessage);
- if(!$ok) return false;
-
+ $this->assertInternalType('array', $value, $name.': not an array'.$errormessage);
if(trim((string)$xml) != ''){
if( false === eval('$v='.(string)$xml.';')){
$this->fail("invalid php array syntax");
return false;
}
- return $this->assertEquals($v,$value,'negative test on '.$name.': %s'.$errormessage);
+ $this->assertEquals($v,$value,'negative test on '.$name.': %s'.$errormessage);
}else{
$key=0;
foreach ($xml->children() as $child) {
@@ -138,56 +133,52 @@ function _checkIdentical($xml, $value, $name, $errormessage){
}else{
$n = $key ++;
}
-
- if($this->assertTrue(array_key_exists($n,$value),$name.'['.$n.'] doesn\'t exist arrrg'.$errormessage)){
- $v = $value[$n];
- $ok &= $this->_checkIdentical($child, $v, $name.'['.$n.']',$errormessage);
- }else $ok= false;
+ $this->assertTrue(array_key_exists($n,$value),$name.'['.$n.'] doesn\'t exist arrrg'.$errormessage);
+ $v = $value[$n];
+ $this->_checkIdentical($child, $v, $name.'['.$n.']',$errormessage);
}
- return $ok;
}
- break;
+ return true;
case 'string':
- $ok = $this->assertInternalType('string', $value,$name.': not a string'.$errormessage);
- if(!$ok) return false;
+ $this->assertInternalType('string', $value, $name.': not a string'.$errormessage);
if(isset($xml['value'])){
- return $this->assertEquals((string)$xml['value'],$value, $name.': bad value. %s'.$errormessage);
+ $this->assertEquals((string)$xml['value'],$value, $name.': bad value. %s'.$errormessage);
}
- else
- return true;
+ return true;
case 'int':
case 'integer':
- $ok = $this->assertTrue(is_integer($value), $name.': not an integer ('.$value.') '.$errormessage);
- if(!$ok) return false;
- if(isset($xml['value'])){
- return $this->assertEquals(intval((string)$xml['value']),$value, $name.': bad value. %s'.$errormessage);
- }else
- return true;
+ $this->assertTrue(is_integer($value), $name.': not an integer ('.$value.') '.$errormessage);
+ if (isset($xml['value'])) {
+ $this->assertEquals(intval((string)$xml['value']),$value, $name.': bad value. %s'.$errormessage);
+ }
+ return true;
case 'float':
case 'double':
- $ok = $this->assertInternalType('float', $value,$name.': not a float ('.$value.') '.$errormessage);
- if(!$ok) return false;
+ $this->assertInternalType('float', $value,$name.': not a float ('.$value.') '.$errormessage);
if(isset($xml['value'])){
- return $this->assertEquals( floatval((string)$xml['value']),$value,$name.': bad value. %s'.$errormessage);
- }else
- return true;
+ $this->assertEquals( floatval((string)$xml['value']),$value,$name.': bad value. %s'.$errormessage);
+ }
+ return true;
case 'boolean':
- $ok = $this->assertInternalType('boolean', $value,$name.': not a boolean ('.$value.') '.$errormessage);
- if(!$ok) return false;
+ $this->assertInternalType('boolean', $value,$name.': not a boolean ('.$value.') '.$errormessage);
if(isset($xml['value'])){
$v = ((string)$xml['value'] == 'true');
- return $this->assertEquals($v ,$value, $name.': bad value. %s'.$errormessage);
- }else
- return true;
+ $this->assertEquals($v ,$value, $name.': bad value. %s'.$errormessage);
+ }
+ return true;
case 'null':
- return $this->assertNull($value, $name.': not null ('.$value.') '.$errormessage);
+ $this->assertNull($value, $name.': not null ('.$value.') '.$errormessage);
+ return true;
case 'notnull':
- return $this->assertNotNull($value, $name.' is null'.$errormessage);
+ $this->assertNotNull($value, $name.' is null'.$errormessage);
+ return true;
case 'resource':
- return $this->assertInternalType('resource', $value,$name.': not a resource'.$errormessage);
+ $this->assertInternalType('resource', $value,$name.': not a resource'.$errormessage);
+ return true;
default:
$this->fail("_checkIdentical: balise inconnue ".$nodename.$errormessage);
+ return false;
}
}
}
View
132 lib/jelix/auth/jAuth.class.php
@@ -27,6 +27,8 @@
require(JELIX_LIB_PATH.'auth/jAuthDriverBase.class.php');
#endif
+
+
/**
* This is the main class for authentification process
* @package jelix
@@ -35,42 +37,108 @@
class jAuth {
/**
+ * @deprecated
+ * @see jAuth::getConfig()
+ */
+ protected static function _getConfig() {
+ return self::loadConfig();
+ }
+
+ protected static $config = null;
+ protected static $driver = null;
+ /**
* Load the configuration of authentification, stored in the auth plugin config
* @return array
+ * @since 1.2.10
*/
- protected static function _getConfig(){
- static $config = null;
- if($config == null){
- $plugin = jApp::coord()->getPlugin('auth');
- if($plugin === null)
- throw new jException('jelix~auth.error.plugin.missing');
- $config = & $plugin->config;
+ public static function loadConfig($newconfig = null){
+
+ if (self::$config === null || $newconfig) {
+ if (!$newconfig) {
+ $plugin = jApp::coord()->getPlugin('auth');
+ if($plugin === null)
+ throw new jException('jelix~auth.error.plugin.missing');
+ $config = & $plugin->config;
+ }
+ else {
+ $config = $newconfig;
+ }
if (!isset($config['session_name'])
|| $config['session_name'] == '')
$config['session_name'] = 'JELIX_USER';
if (!isset( $config['persistant_cookie_path'])
- || $config['persistant_cookie_path'] == '')
- $config['persistant_cookie_path'] = jApp::config()->urlengine['basePath'];
+ || $config['persistant_cookie_path'] == '') {
+ if (jApp::config())
+ $config['persistant_cookie_path'] = jApp::config()->urlengine['basePath'];
+ else
+ $config['persistant_cookie_path'] = '/';
+ }
+
+ // Read hash method configuration. If not empty, cryptPassword will use
+ // the new API of PHP 5.5 (password_verify and so on...)
+ $password_hash_method = (isset($config['password_hash_method'])? $config['password_hash_method']:0);
+
+ if ($password_hash_method === '' || (! is_numeric($password_hash_method))) {
+ $password_hash_method = 0;
+ }
+ else {
+ $password_hash_method= intval($password_hash_method);
+ }
+
+ if ($password_hash_method > 0) {
+ require_once(jApp::getModulePath('jauth').'classes/password.php');
+ if (!can_use_password_API()) {
+ $password_hash_method = 0;
+ }
+ }
+
+ $password_hash_options = (isset($config['password_hash_options'])?$config['password_hash_options']:'');
+ if ($password_hash_options != '') {
+ $list = '{"'.str_replace(array('=',';'), array('":"', '","'), $config['password_hash_options']).'"}';
+ $json = new jJson(SERVICES_JSON_LOOSE_TYPE);
+ $password_hash_options = @$json->decode($list);
+ if (!$password_hash_options)
+ $password_hash_options = array();
+ }
+ else {
+ $password_hash_options = array();
+ }
+
+ $config['password_hash_method'] = $password_hash_method;
+ $config['password_hash_options'] = $password_hash_options;
+
+ $config[$config['driver']]['password_hash_method'] = $password_hash_method;
+ $config[$config['driver']]['password_hash_options'] = $password_hash_options;
+ self::$config = $config;
}
- return $config;
+ return self::$config;
+ }
+
+ /**
+ * @deprecated
+ * @see jAuth::getDriver()
+ */
+ protected static function _getDriver() {
+ return self::getDriver();
}
/**
* return the auth driver
* @return jIAuthDriver
+ * @since 1.2.10
*/
- protected static function _getDriver(){
- static $driver = null;
- if($driver == null){
- $config = self::_getConfig();
+ public static function getDriver(){
+ if (self::$driver === null) {
+ $config = self::loadConfig();
$db = strtolower($config['driver']);
$driver = jApp::loadPlugin($db, 'auth', '.auth.php', $config['driver'].'AuthDriver', $config[$config['driver']]);
if(is_null($driver))
throw new jException('jelix~auth.error.driver.notfound',$db);
+ self::$driver = $driver;
}
- return $driver;
+ return self::$driver;
}
/**
@@ -79,7 +147,7 @@ protected static function _getDriver(){
* @return string the value. null if it doesn't exist
*/
public static function getDriverParam($paramName) {
- $config = self::_getConfig();
+ $config = self::loadConfig();
$config = $config[$config['driver']];
if(isset($config[$paramName]))
return $config[$paramName];
@@ -98,7 +166,7 @@ public static function getDriverParam($paramName) {
* @return object the user
*/
public static function getUser($login){
- $dr = self::_getDriver();
+ $dr = self::getDriver();
return $dr->getUser($login);
}
@@ -115,7 +183,7 @@ public static function getUser($login){
* @since 1.0b2
*/
public static function createUserObject($login,$password){
- $dr = self::_getDriver();
+ $dr = self::getDriver();
return $dr->createUserObject($login,$password);
}
@@ -137,7 +205,7 @@ public static function createUserObject($login,$password){
* @return object the user (eventually, with additional data)
*/
public static function saveNewUser($user){
- $dr = self::_getDriver();
+ $dr = self::getDriver();
if($dr->saveNewUser($user))
jEvent::notify ('AuthNewUser', array('user'=>$user));
return $user;
@@ -162,12 +230,12 @@ public static function saveNewUser($user){
* @param object $user user data
*/
public static function updateUser($user){
- $dr = self::_getDriver();
+ $dr = self::getDriver();
if($dr->updateUser($user) === false)
return false;
if(self::isConnected() && self::getUserSession()->login === $user->login){
- $config = self::_getConfig();
+ $config = self::loadConfig();
$_SESSION[$config['session_name']] = $user;
}
jEvent::notify ('AuthUpdateUser', array('user'=>$user));
@@ -182,7 +250,7 @@ public static function updateUser($user){
* @return boolean true if ok
*/
public static function removeUser($login){
- $dr = self::_getDriver();
+ $dr = self::getDriver();
$eventresp = jEvent::notify ('AuthCanRemoveUser', array('login'=>$login));
foreach($eventresp->getResponse() as $rep){
if(!isset($rep['canremove']) || $rep['canremove'] === false)
@@ -203,7 +271,7 @@ public static function removeUser($login){
* @return array array of object
*/
public static function getUserList($pattern = '%'){
- $dr = self::_getDriver();
+ $dr = self::getDriver();
return $dr->getUserlist($pattern);
}
@@ -215,11 +283,11 @@ public static function getUserList($pattern = '%'){
* @return boolean true if the change succeed
*/
public static function changePassword($login, $newpassword){
- $dr = self::_getDriver();
+ $dr = self::getDriver();
if($dr->changePassword($login, $newpassword)===false)
return false;
if(self::isConnected() && self::getUserSession()->login === $login){
- $config = self::_getConfig();
+ $config = self::loadConfig();
$_SESSION[$config['session_name']] = self::getUser($login);
}
return true;
@@ -232,7 +300,7 @@ public static function changePassword($login, $newpassword){
* @return object|false if ok, returns the user as object
*/
public static function verifyPassword($login, $password){
- $dr = self::_getDriver();
+ $dr = self::getDriver();
return $dr->verifyPassword($login, $password);
}
@@ -245,8 +313,8 @@ public static function verifyPassword($login, $password){
*/
public static function login($login, $password, $persistant=false){
- $dr = self::_getDriver();
- $config = self::_getConfig();
+ $dr = self::getDriver();
+ $config = self::loadConfig();
$eventresp = jEvent::notify ('AuthBeforeLogin', array('login'=>$login));
foreach($eventresp->getResponse() as $rep){
@@ -293,7 +361,7 @@ public static function login($login, $password, $persistant=false){
* @return boolean true if persistant session in enabled
*/
public static function isPersistant(){
- $config = self::_getConfig();
+ $config = self::loadConfig();
if(!isset($config['persistant_enable']))
return false;
else
@@ -305,7 +373,7 @@ public static function isPersistant(){
*/
public static function logout(){
- $config = self::_getConfig();
+ $config = self::loadConfig();
jEvent::notify ('AuthLogout', array('login'=>$_SESSION[$config['session_name']]->login));
$_SESSION[$config['session_name']] = new jAuthDummyUser();
@@ -321,7 +389,7 @@ public static function logout(){
* @return boolean
*/
public static function isConnected(){
- $config = self::_getConfig();
+ $config = self::loadConfig();
return (isset($_SESSION[$config['session_name']]) && $_SESSION[$config['session_name']]->login != '');
}
@@ -330,7 +398,7 @@ public static function isConnected(){
* @return object the user data
*/
public static function getUserSession (){
- $config = self::_getConfig();
+ $config = self::loadConfig();
if (! isset ($_SESSION[$config['session_name']]))
$_SESSION[$config['session_name']] = new jAuthDummyUser();
return $_SESSION[$config['session_name']];
View
47 lib/jelix/auth/jAuthDriverBase.class.php
@@ -14,15 +14,25 @@
class jAuthDriverBase {
protected $_params;
+ protected $passwordHashMethod;
+ protected $passwordHashOptions;
function __construct($params){
$this->_params = $params;
+ $this->passwordHashOptions = $params['password_hash_options'];
+ $this->passwordHashMethod = $params['password_hash_method'];
}
/**
- * crypt the password
+ * hash the given password
+ * @param string $password the password to hash
+ * @return string the hash password
*/
- public function cryptPassword($password) {
+ public function cryptPassword($password, $forceOldHash = false) {
+ if (!$forceOldHash && $this->passwordHashMethod) {
+ return password_hash($password, $this->passwordHashMethod, $this->passwordHashOptions);
+ }
+
if (isset($this->_params['password_crypt_function'])) {
$f = $this->_params['password_crypt_function'];
if ($f != '') {
@@ -41,12 +51,45 @@ public function cryptPassword($password) {
}
return $password;
}
+
+ /**
+ * @param string $givenPassword the password to verify
+ * @param string $currentPasswordHash the hash of the real password
+ * @return boolean|string false if password does not correspond. True if it is ok. A string
+ * containing a new hash if it is ok and need to store a new hash
+ */
+ public function checkPassword($givenPassword, $currentPasswordHash) {
+ if ($currentPasswordHash[0] == '$' && $this->passwordHashMethod) {
+ // ok, we have hash for standard API, let's use standard API
+ if (!password_verify($givenPassword, $currentPasswordHash)) {
+ return false;
+ }
+
+ // check if rehash is needed,
+ if (password_needs_rehash($currentPasswordHash, $this->passwordHashMethod, $this->passwordHashOptions)) {
+ return password_hash($givenPassword, $this->passwordHashMethod, $this->passwordHashOptions);
+ }
+ }
+ else {
+ // verify with the old hash api
+ if ($currentPasswordHash != $this->cryptPassword($givenPassword, true)) {
+ return false;
+ }
+
+ if ($this->passwordHashMethod) {
+ // if there is a method to hash with the standard API, let's rehash the password
+ return password_hash($givenPassword, $this->passwordHashMethod, $this->passwordHashOptions);
+ }
+ }
+ return true;
+ }
}
/**
* function to use to crypt password. use the password_salt value in the config
* file of the plugin.
+ * @deprecated
*/
function sha1WithSalt($salt, $password) {
return sha1($salt.':'.$password);
View
4 lib/jelix/core/jApp.class.php
@@ -217,7 +217,7 @@ public static function loadPlugin($name, $type, $suffix, $classname, $args = nul
*/
public static function isModuleEnabled ($moduleName, $includingExternal = false) {
if (!self::$_config)
- throw Exception ('Configuration is not loaded');
+ throw new Exception ('Configuration is not loaded');
if ($includingExternal && isset(self::$_config->_externalModulesPathList[$moduleName])) {
return true;
}
@@ -233,7 +233,7 @@ public static function isModuleEnabled ($moduleName, $includingExternal = false)
*/
public static function getModulePath($module, $includingExternal = false){
if (!self::$_config)
- throw Exception ('Configuration is not loaded');
+ throw new Exception ('Configuration is not loaded');
if (!isset(self::$_config->_modulesPathList[$module])) {
if ($includingExternal && isset(self::$_config->_externalModulesPathList[$module])) {
View
4 lib/jelix/core/jBasicErrorHandler.class.php
@@ -134,7 +134,9 @@ static function handleError ($type, $code, $message, $file, $line, $trace) {
$HEADBOTTOM = '';
$BODYTOP = '';
$BODYBOTTOM = htmlspecialchars($msg);
- $basePath = '';
+ $BASEPATH = '';
+ if (jApp::config() && isset(jApp::config()->urlengine['basePath']))
+ $BASEPATH = jApp::config()->urlengine['basePath'];
header("HTTP/1.1 500 Internal jelix error");
header('Content-type: text/html');
include($file);
View
4 lib/jelix/core/jCoordinator.class.php
@@ -91,8 +91,8 @@ private function _loadPlugins(){
// so we don't have to check if the value $conf is empty or not
if ($conf == '1') {
$confname = 'coordplugin_'.$name;
- if (isset($config->confname))
- $conf = $config->confname;
+ if (isset($config->$confname))
+ $conf = $config->$confname;
else
$conf = array();
}
View
4 lib/jelix/core/response/jResponseBasicHtml.class.php
@@ -99,6 +99,7 @@ class jResponseBasicHtml extends jResponse {
* - $HEADBOTTOM: content before th </head> tag
* - $BODYTOP: content just after the <body> tag, at the top of the page
* - $BODYBOTTOM: content just before the </body> tag, at the bottom of the page
+ * - $BASEPATH: base path of the application, for links of your style sheets etc..
* @var string
*/
public $htmlFile = '';
@@ -213,6 +214,7 @@ public function output(){
$HEADBOTTOM = implode("\n", $this->_headBottom);
$BODYTOP = implode("\n", $this->_bodyTop);
$BODYBOTTOM = implode("\n", $this->_bodyBottom);
+ $BASEPATH = jApp::config()->urlengine['basePath'];
ob_start();
foreach($this->plugins as $name=>$plugin)
@@ -257,7 +259,7 @@ public function outputErrors(){
$HEADBOTTOM = implode("\n", $this->_headBottom);
$BODYTOP = implode("\n", $this->_bodyTop);
$BODYBOTTOM = implode("\n", $this->_bodyBottom);
- $basePath = jApp::config()->urlengine['basePath'];
+ $BASEPATH = jApp::config()->urlengine['basePath'];
header("HTTP/{$this->httpVersion} 500 Internal jelix error");
header('Content-Type: text/html;charset='.$this->_charset);
View
6 lib/jelix/core/response/jResponseSitemap.class.php
@@ -122,7 +122,7 @@ public function __construct() {
* @param string $lastmod The date of last modification of the file
* @param string $changefreq How frequently the page is likely to change
* @param string $priority The priority of this URL relative to other URLs
- * @return void
+ * @return boolean true if addition is ok, else false
*/
public function addUrl($loc, $lastmod = null, $changefreq = null, $priority = null) {
@@ -146,13 +146,14 @@ public function addUrl($loc, $lastmod = null, $changefreq = null, $priority = nu
}
$this->urlList[] = $url;
+ return true;
}
/**
* add a URL in a sitemap file
* @param string $loc URL of sitemap file
* @param string $lastmod The date of last modification of the sitemap file
- * @return void
+ * @return boolean true if addition is ok, else false
*/
public function addSitemap($loc, $lastmod = null) {
@@ -168,6 +169,7 @@ public function addSitemap($loc, $lastmod = null) {
}
$this->urlSitemap[] = $sitemap;
+ return true;
}
/**
View
2 lib/jelix/dao/jDaoFactoryBase.class.php
@@ -330,7 +330,7 @@ public function countAll(){
*/
final public function deleteBy ($searchcond){
if ($searchcond->isEmpty ()){
- return;
+ return 0;
}
$query = 'DELETE FROM '.$this->_conn->encloseName($this->_tables[$this->_primaryTable]['realname']).' WHERE ';
View
2 lib/jelix/dao/jDaoGenerator.class.php
@@ -682,7 +682,7 @@ protected function _writeFieldsInfoWith ($info, $start = '', $end='', $beetween
$result[] = $start . $field->$info . $end;
}
- return implode ($beetween,$result);;
+ return implode ($beetween,$result);
}
/**
View
14 lib/jelix/db/jDbTable.class.php
@@ -211,7 +211,7 @@ public function getReferences() {
if ($this->references === null)
$this->_loadReferences();
return $this->references;
- }
+ }
public function getReference($refName) {
if ($this->references === null)
@@ -222,21 +222,21 @@ public function getReference($refName) {
return null;
}
- public function addReference(jDbReference $reference) {
+ public function addReference(jDbReference $reference) {
$this->alterReference($reference);
- }
-
- public function alterReference(jDbReference $reference) {
+ }
+
+ public function alterReference(jDbReference $reference) {
$ref = $this->getReference($reference->name);
if ($ref) {
$this->_dropReference($ref);
}
$this->_createReference($reference);
$this->references[$reference->name] = $reference;
- }
+ }
public function dropReference($refName) {
- $ref = $this->getReference($reference->name);
+ $ref = $this->getReference($refName);
if ($ref) {
$this->_dropReference($ref);
}
View
19 lib/jelix/plugins/auth/class/class.auth.php
@@ -73,6 +73,7 @@ public function updatePassword($login, $cryptedpassword);
* @param string $login the user login
* @param string $password the new encrypted password
* @return object user informations
+ * @deprecated since 1.2.10
*/
public function getByLoginPassword($login, $cryptedpassword);
}
@@ -136,11 +137,23 @@ public function changePassword($login, $newpassword){
public function verifyPassword($login, $password){
if (trim($password) == '')
return false;
- $classuser = jClasses::create($this->_params['class']);
+ $class = jClasses::create($this->_params['class']);
+ $user = $class->getByLogin($login);
+ if (!$user) {
+ return false;
+ }
- $user = $classuser->getByLoginPassword($login, $this->cryptPassword($password));
+ $result = $this->checkPassword($password, $user->password);
+ if ($result === false)
+ return false;
- return ($user?$user:false);
+ if ($result !== true) {
+ // it is a new hash for the password, let's update it persistently
+ $user->password = $result;
+ $class->updatePassword($login, $result);
+ }
+
+ return $user;
}
}
View
20 lib/jelix/plugins/auth/db/db.auth.php
@@ -18,7 +18,7 @@
*/
class dbAuthDriver extends jAuthDriverBase implements jIAuthDriver {
- function __construct($params){
+ function __construct($params) {
parent::__construct($params);
if(!isset($this->_params['profile'])) {
if(isset($this->_params['profil']))
@@ -77,7 +77,21 @@ public function verifyPassword($login, $password){
if (trim($password) == '')
return false;
$daouser = jDao::get($this->_params['dao'], $this->_params['profile']);
- $user = $daouser->getByLoginPassword($login, $this->cryptPassword($password));
- return ($user?$user:false);
+ $user = $daouser->getByLogin($login);
+ if (!$user) {
+ return false;
+ }
+
+ $result = $this->checkPassword($password, $user->password);
+ if ($result === false)
+ return false;
+
+ if ($result !== true) {
+ // it is a new hash for the password, let's update it persistently
+ $user->password = $result;
+ $daouser->updatePassword($login, $result);
+ }
+
+ return $user;
}
}
View
8 lib/jelix/plugins/auth/ldap/ldap.auth.php
@@ -81,7 +81,7 @@ public function saveNewUser($user){
return false;
}
$result = ldap_add($connect, $this->_buildUserDn($user->login), $entries);
- ldapd_close($connect);
+ ldap_close($connect);
return $result;
}
@@ -92,7 +92,7 @@ public function removeUser($login){
if ($connect === false) {
return false;
}
- $result = ldap_delete($connect, $this->_buildUserDn($user->login));
+ $result = ldap_delete($connect, $this->_buildUserDn($login));
ldap_close($connect);
return $result;
}
@@ -195,9 +195,8 @@ public function changePassword($login, $newpassword) {
if ($connect === false) {
return false;
}
- $result = ldap_mod_replace($connect, $this->_buildUserDn($user->login), $entries);
+ $result = ldap_mod_replace($connect, $this->_buildUserDn($login), $entries);
ldap_close($connect);
-
return $result;
}
@@ -282,6 +281,7 @@ protected function setAttributesLDAP(&$user, $attributes) {
break;
case $this->_params['uidProperty']:
$user->login = $attributes[$attribute];
+ break;
default:
$user->$attribute = $attributes[$attribute];
break;
View
16 lib/jelix/plugins/coord/auth/auth.coord.ini.php.dist
@@ -73,8 +73,23 @@ persistant_duration = 1
; base path for the cookie. If empty, it uses the basePath value from the main configuration.
persistant_cookie_path =
+
+;=========== parameters for password hashing
+
+; method of the hash. "" means old hashing behavior of jAuth
+; (using password_* parameters in drivers ).
+; Prefer to choose "default" (or "bcrypt").
+password_hash_method =
+
+; options for the hash method. list of "name:value" separated by a ";"
+password_hash_options =
+
;=========== Parameters for drivers
+
+
+
+
;------- parameters for the "Db" driver
[Db]
; name of the dao to get user data
@@ -135,3 +150,4 @@ password_crypt_function = sha1
; if you want to use a salt with sha1:
;password_crypt_function = "1:sha1WithSalt"
;password_salt = "here_your_salt"
+
View
2 lib/jelix/plugins/coord/auth/auth.coord.php
@@ -107,7 +107,7 @@ public function beforeAction ($params){
if($needAuth){
if($notLogged){
- if($this->config['on_error'] == 1
+ if(jApp::coord()->request->isAjax() || $this->config['on_error'] == 1
|| !jApp::coord()->request->isAllowedResponse('jResponseRedirect')){
throw new jException($this->config['error_message']);
}else{
View
2 lib/jelix/plugins/db/mysql/mysql.dbschema.php
@@ -210,7 +210,7 @@ protected function _createReference(jDbReference $ref) {
$fcols[] = $conn->encloseName($c);
}
- $sql .= impode(',', $cols).') REFERENCES '.$conn->encloseName($ref->fTable).'(';
+ $sql .= implode(',', $cols).') REFERENCES '.$conn->encloseName($ref->fTable).'(';
$sql .= implode(',', $fcols).')';
if ($ref->onUpdate) {
View
1 lib/jelix/plugins/debugbar/soaplog/soaplog.debugbar.php
@@ -56,6 +56,7 @@ function show($debugbar) {
$info->popupContent .= '<li>
<h5><a href="#" onclick="jxdb.toggleDetails(this);return false;"><span>'.htmlspecialchars($msg->getMessage()).'</span></a></h5>
<div>';
+ $info->popupContent .= "Duration: ".$msg->getDuration()."s<br />";
$info->popupContent .= "<h6>Headers</h6><pre>".$msg->getHeaders()."</pre>";
$info->popupContent .= "<h6>Request</h6><pre>".$this->xmlprettyprint($msg->getRequest())."</pre>";
$info->popupContent .= "<h6>Response</h6><pre>".$this->xmlprettyprint($msg->getResponse())."</pre>";
View
1 lib/jelix/plugins/tpl/html/meta.html.php
@@ -105,6 +105,7 @@ function jtpl_meta_html_html($tpl, $method, $param=null, $params=array())
break;
case 'generator':
$resp->addMetaGenerator($param);
+ break;
case 'jquery':
$resp->addJSLink(jApp::config()->urlengine['jqueryPath'].'jquery.js');
break;
View
27 lib/jelix/utils/jSoapClient.class.php
@@ -25,13 +25,18 @@ class jLogSoapMessage extends jLogMessage {
* @var string
*/
protected $response;
+ /**
+ * @var string
+ */
+ protected $duration;
- public function __construct($function_name, $soapClient, $category='default') {
+ public function __construct($function_name, $soapClient, $category='default', $duration = 0) {
$this->category = $category;
$this->headers = $soapClient->__getLastRequestHeaders();
$this->request = $soapClient->__getLastRequest ();
$this->response = $soapClient->__getLastResponse();
$this->functionName = $function_name;
+ $this->duration = $duration;
$this->message = 'Soap call: '.$function_name.'()';
}
@@ -47,8 +52,13 @@ public function getRequest() {
return $this->request;
}
+ public function getDuration() {
+ return $this->duration;
+ }
+
public function getFormatedMessage() {
$message = 'Soap call: '.$this->functionName."()\n";
+ $message .= "DURATION: ".$this->duration."s\n";
$message .= "HEADERS:\n\t".str_replace("\n","\n\t",$this->headers)."\n";
$message .= "REQUEST:\n\t".str_replace("\n","\n\t",$this->request)."\n";
$message .= "RESPONSE:\n\t".str_replace("\n","\n\t",$this->response)."\n";
@@ -60,18 +70,29 @@ public function getFormatedMessage() {
class SoapClientDebug extends SoapClient {
public function __call ( $function_name , $arguments) {
+ $timeExecutionBegin = $this->_microtimeFloat();
$result = parent::__call($function_name , $arguments);
- $log = new jLogSoapMessage($function_name, $this, 'soap');
+ $timeExecutionEnd = $this->_microtimeFloat();
+
+ $log = new jLogSoapMessage($function_name, $this, 'soap', $timeExecutionEnd - $timeExecutionBegin);
jLog::log($log,'soap');
return $result;
}
public function __soapCall ( $function_name , $arguments, $options=array(), $input_headers=null, &$output_headers=null) {
+ $timeExecutionBegin = $this->_microtimeFloat();
$result = parent::__soapCall($function_name , $arguments, $options, $input_headers, $output_headers);
- $log = new jLogSoapMessage($function_name, $this, 'soap');
+ $timeExecutionEnd = $this->_microtimeFloat();
+
+ $log = new jLogSoapMessage($function_name, $this, 'soap', $timeExecutionEnd - $timeExecutionBegin);
jLog::log($log,'soap');
return $result;
}
+
+ protected function _microtimeFloat() {
+ list($usec, $sec) = explode(" ", microtime());
+ return ((float)$usec + (float)$sec);
+ }
}
View
1 testapp/modules/jelix_tests/classes/testAuthDriver.class.php
@@ -38,6 +38,7 @@ public function update($user) {
public function getByLogin($login) {
$user = new testAuthDriverUser();
$user->login = $login;
+ $user->password = md5('foo');
return $user;
}
View
11 testapp/modules/jelix_tests/tests/jacl.main_api.html_cli.php
@@ -16,15 +16,18 @@ class UTjacl extends jUnitTestCaseDb {
protected $oldAuthPlugin;
public function setUpRun (){
- $conf = parse_ini_file(jApp::configPath().'auth_class.coord.ini.php',true);
-
$coord = jApp::coord();
require_once( JELIX_LIB_PATH.'plugins/coord/auth/auth.coord.php');
+
+ $confContent = parse_ini_file(JELIX_APP_CONFIG_PATH.'auth_class.coord.ini.php',true);
+ $config = jAuth::loadConfig($confContent);
+
if (isset($coord->plugins['auth']))
$this->oldAuthPlugin = $coord->plugins['auth'];
- $coord->plugins['auth'] = new AuthCoordPlugin($conf);
-
+ $coord->plugins['auth'] = new AuthCoordPlugin($config);
$this->config = & $coord->plugins['auth']->config;
+
+
$_SESSION[$this->config['session_name']] = new jAuthDummyUser();
$this->dbProfile = 'jacl_profile';
View
8 testapp/modules/jelix_tests/tests/jacl2_main_api.lib.php
@@ -17,13 +17,15 @@
protected $oldAuthPlugin;
public function setUpRun (){
- $conf = parse_ini_file(jApp::configPath().'auth_class.coord.ini.php',true);
-
$coord = jApp::coord();
require_once( JELIX_LIB_PATH.'plugins/coord/auth/auth.coord.php');
+
+ $confContent = parse_ini_file(jApp::configPath().'auth_class.coord.ini.php',true);
+ $config = jAuth::loadConfig($confContent);
+
if (isset($coord->plugins['auth']))
$this->oldAuthPlugin = $coord->plugins['auth'];
- $coord->plugins['auth'] = new AuthCoordPlugin($conf);
+ $coord->plugins['auth'] = new AuthCoordPlugin($config);
$this->config = & $coord->plugins['auth']->config;
$_SESSION[$this->config['session_name']] = new jAuthDummyUser();
View
15 testapp/modules/jelix_tests/tests/jdb.pgsql.html_cli.php
@@ -11,23 +11,22 @@
*/
class UTjDbPgsql extends jUnitTestCaseDb {
- protected $dbProfile ='pgsql_profile';
+ protected $dbProfile = 'pgsql_profile';
+ protected $noDb = false;
function skip() {
- try{
- $prof = jProfiles::get('jdb', $this->dbProfile, true);
- }
- catch (Exception $e) {
- $this->skipIf(true, 'UTjDbPgsql cannot be run: '.$e->getMessage());
- }
+ $this->skipIf(($this->noDb !== false), 'UTjDbPgsql cannot be run: '.$this->noDb);
}
function setUpRun() {
try{
+ // check if we have profile
$prof = jProfiles::get('jdb', $this->dbProfile, true);
$this->emptyTable('product_test');
}
- catch (Exception $e) {}
+ catch (Exception $e) {
+ $this->noDb = $e->getMessage();
+ }
}
function testTools(){
View
4 testapp/tests-jelix/jelix/kvdb/jkvdb.lib.php
@@ -62,8 +62,8 @@ public function testMultipleGet (){
$kv->set('getKey', 'string for data');
$kv->setWithTtl('expiredKey','data expired',strtotime("-1 day"));
$data = $kv->get(array('getKey','expiredKey','inexistentKey'));
- if ($this->assertTrue(isset($data['getKey'])))
- $this->assertTrue($data['getKey']=='string for data');
+ $this->assertTrue(isset($data['getKey']));
+ $this->assertTrue($data['getKey']=='string for data');
$this->assertTrue(!isset($data['expiredKey']));
$this->assertTrue(!isset($data['inexistentKey']));
}
View
21 testapp/tests-jelix/jelix/utils/jMailerTest.php
@@ -44,17 +44,16 @@ public function testFileMail() {
$this->assertEquals(jApp::varPath().'mails/', $mail->filePath);
$this->assertEquals(jApp::varPath().'mails/mail.txt', $mail->getStorageFile2());
- if ($this->assertTrue(file_exists(jApp::varPath().'mails/mail.txt'))) {
- $content = file_get_contents(jApp::varPath().'mails/mail.txt');
-
- $this->assertTrue(strpos($content, 'Return-Path: toto@truc.com') !== false);
- $this->assertTrue(strpos($content, 'To: titi@machin.local, toto@machin.local') !== false);
- $this->assertTrue(strpos($content, 'From: Super Me <toto@truc.local>') !== false);
- $this->assertTrue(strpos($content, 'Subject: Email test') !== false);
- $this->assertTrue(strpos($content, 'Content-Transfer-Encoding: 8bit') !== false);
- $this->assertTrue(strpos($content, 'Content-Type: text/plain; charset="UTF-8"') !== false);
- $this->assertTrue(strpos($content, 'This is a test mail') !== false);
- }
+ $this->assertTrue(file_exists(jApp::varPath().'mails/mail.txt'));
+ $content = file_get_contents(jApp::varPath().'mails/mail.txt');
+
+ $this->assertTrue(strpos($content, 'Return-Path: toto@truc.com') !== false);
+ $this->assertTrue(strpos($content, 'To: titi@machin.local, toto@machin.local') !== false);
+ $this->assertTrue(strpos($content, 'From: Super Me <toto@truc.local>') !== false);
+ $this->assertTrue(strpos($content, 'Subject: Email test') !== false);
+ $this->assertTrue(strpos($content, 'Content-Transfer-Encoding: 8bit') !== false);
+ $this->assertTrue(strpos($content, 'Content-Type: text/plain; charset="UTF-8"') !== false);
+ $this->assertTrue(strpos($content, 'This is a test mail') !== false);
}
}

0 comments on commit a128eda

Please sign in to comment.