aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarc Alexander <admin@m-a-styles.de>2014-02-02 14:09:09 +0100
committerMarc Alexander <admin@m-a-styles.de>2014-02-02 14:09:09 +0100
commit292961a2771c9237197b9770b23a2a14a981c329 (patch)
tree5c9eee5425d2dd1b7c85648d08098d1ec729bdd5
parent85f1e8afa55356f620a8715ba9fcaaec491dff96 (diff)
downloadforums-292961a2771c9237197b9770b23a2a14a981c329.tar
forums-292961a2771c9237197b9770b23a2a14a981c329.tar.gz
forums-292961a2771c9237197b9770b23a2a14a981c329.tar.bz2
forums-292961a2771c9237197b9770b23a2a14a981c329.tar.xz
forums-292961a2771c9237197b9770b23a2a14a981c329.zip
[feature/passwords] Get rid of set_name/get_name methods for passwords drivers
PHPBB3-11610
-rw-r--r--phpBB/config/passwords.yml8
-rw-r--r--phpBB/phpbb/passwords/driver/base.php18
-rw-r--r--phpBB/phpbb/passwords/driver/driver_interface.php7
-rw-r--r--phpBB/phpbb/passwords/manager.php20
-rw-r--r--tests/auth/provider_apache_test.php5
-rw-r--r--tests/auth/provider_db_test.php5
-rw-r--r--tests/passwords/drivers_test.php5
-rw-r--r--tests/passwords/manager_test.php5
-rw-r--r--tests/security/hash_test.php5
-rw-r--r--tests/test_framework/phpbb_functional_test_case.php5
10 files changed, 8 insertions, 75 deletions
diff --git a/phpBB/config/passwords.yml b/phpBB/config/passwords.yml
index 4eeca4e34f..9e249a2c12 100644
--- a/phpBB/config/passwords.yml
+++ b/phpBB/config/passwords.yml
@@ -11,8 +11,6 @@ services:
arguments:
- @config
- @passwords.driver_helper
- calls:
- - [set_name, [passwords.driver.bcrypt]]
tags:
- { name: passwords.driver }
@@ -21,8 +19,6 @@ services:
arguments:
- @config
- @passwords.driver_helper
- calls:
- - [set_name, [passwords.driver.bcrypt_2y]]
tags:
- { name: passwords.driver }
@@ -31,8 +27,6 @@ services:
arguments:
- @config
- @passwords.driver_helper
- calls:
- - [set_name, [passwords.driver.salted_md5]]
tags:
- { name: passwords.driver }
@@ -41,8 +35,6 @@ services:
arguments:
- @config
- @passwords.driver_helper
- calls:
- - [set_name, [passwords.driver.phpass]]
tags:
- { name: passwords.driver }
diff --git a/phpBB/phpbb/passwords/driver/base.php b/phpBB/phpbb/passwords/driver/base.php
index 91c07a813b..8256fd721c 100644
--- a/phpBB/phpbb/passwords/driver/base.php
+++ b/phpBB/phpbb/passwords/driver/base.php
@@ -42,22 +42,4 @@ abstract class base implements driver_interface
{
return true;
}
-
- /**
- * @inheritdoc
- */
- public function get_name()
- {
- return $this->name;
- }
-
- /**
- * Set driver name
- *
- * @param string $name Driver name
- */
- public function set_name($name)
- {
- $this->name = $name;
- }
}
diff --git a/phpBB/phpbb/passwords/driver/driver_interface.php b/phpBB/phpbb/passwords/driver/driver_interface.php
index 53065dfb02..ebaf0626af 100644
--- a/phpBB/phpbb/passwords/driver/driver_interface.php
+++ b/phpBB/phpbb/passwords/driver/driver_interface.php
@@ -57,11 +57,4 @@ interface driver_interface
* @return string String containing the hash settings
*/
public function get_settings_only($hash, $full = false);
-
- /**
- * Get the driver name
- *
- * @return string Driver name
- */
- public function get_name();
}
diff --git a/phpBB/phpbb/passwords/manager.php b/phpBB/phpbb/passwords/manager.php
index 539fdca954..7aeb496eb5 100644
--- a/phpBB/phpbb/passwords/manager.php
+++ b/phpBB/phpbb/passwords/manager.php
@@ -79,7 +79,7 @@ class manager
{
if ($this->algorithms[$type]->is_supported())
{
- $this->type = $type;
+ $this->type = $this->algorithms[$type]->get_prefix();
break;
}
}
@@ -94,16 +94,12 @@ class manager
{
foreach ($hashing_algorithms as $algorithm)
{
- if (!isset($this->algorithms[$algorithm->get_name()]))
- {
- $this->algorithms[$algorithm->get_name()] = $algorithm;
- }
-
if (!isset($this->type_map[$algorithm->get_prefix()]))
{
- $this->type_map[$algorithm->get_prefix()] = $algorithm->get_name();
+ $this->type_map[$algorithm->get_prefix()] = $algorithm;
}
}
+ $this->algorithms = $hashing_algorithms;
}
/**
@@ -130,9 +126,9 @@ class manager
*/
protected function get_algorithm($prefix)
{
- if (isset($this->type_map[$prefix]) && isset($this->algorithms[$this->type_map[$prefix]]))
+ if (isset($this->type_map[$prefix]))
{
- return $this->algorithms[$this->type_map[$prefix]];
+ return $this->type_map[$prefix];
}
else
{
@@ -216,9 +212,9 @@ class manager
return $this->helper->combined_hash_password($password, $type);
}
- if (isset($this->algorithms[$type]))
+ if (isset($this->type_map[$type]))
{
- $hashing_algorithm = $this->algorithms[$type];
+ $hashing_algorithm = $this->type_map[$type];
}
else
{
@@ -260,7 +256,7 @@ class manager
return $correct;
}
- if ($stored_hash_type->get_name() !== $this->type)
+ if ($stored_hash_type->get_prefix() !== $this->type)
{
$this->convert_flag = true;
}
diff --git a/tests/auth/provider_apache_test.php b/tests/auth/provider_apache_test.php
index dbd98d9a66..1231c16a4c 100644
--- a/tests/auth/provider_apache_test.php
+++ b/tests/auth/provider_apache_test.php
@@ -34,11 +34,6 @@ class phpbb_auth_provider_apache_test extends phpbb_database_test_case
'passwords.driver.phpass' => new \phpbb\passwords\driver\phpass($config, $driver_helper),
);
- foreach ($passwords_drivers as $key => $driver)
- {
- $driver->set_name($key);
- }
-
$passwords_helper = new \phpbb\passwords\helper;
// Set up passwords manager
$passwords_manager = new \phpbb\passwords\manager($config, $passwords_drivers, $passwords_helper, array_keys($passwords_drivers));
diff --git a/tests/auth/provider_db_test.php b/tests/auth/provider_db_test.php
index b18b6a1ae2..91ffcdc2a7 100644
--- a/tests/auth/provider_db_test.php
+++ b/tests/auth/provider_db_test.php
@@ -44,11 +44,6 @@ class phpbb_auth_provider_db_test extends phpbb_database_test_case
'passwords.driver.phpass' => new \phpbb\passwords\driver\phpass($config, $driver_helper),
);
- foreach ($passwords_drivers as $key => $driver)
- {
- $driver->set_name($key);
- }
-
$passwords_helper = new \phpbb\passwords\helper;
// Set up passwords manager
$passwords_manager = new \phpbb\passwords\manager($config, $passwords_drivers, $passwords_helper, array_keys($passwords_drivers));
diff --git a/tests/passwords/drivers_test.php b/tests/passwords/drivers_test.php
index fd45c22fc1..2d26be7da5 100644
--- a/tests/passwords/drivers_test.php
+++ b/tests/passwords/drivers_test.php
@@ -21,11 +21,6 @@ class phpbb_passwords_helper_test extends PHPUnit_Framework_TestCase
'passwords.driver.salted_md5' => new \phpbb\passwords\driver\salted_md5($config, $this->driver_helper),
'passwords.driver.phpass' => new \phpbb\passwords\driver\phpass($config, $this->driver_helper),
);
-
- foreach ($this->passwords_drivers as $key => $driver)
- {
- $driver->set_name($key);
- }
}
public function data_helper_encode64()
diff --git a/tests/passwords/manager_test.php b/tests/passwords/manager_test.php
index e965e3a692..11efaa5afd 100644
--- a/tests/passwords/manager_test.php
+++ b/tests/passwords/manager_test.php
@@ -28,11 +28,6 @@ class phpbb_passwords_manager_test extends PHPUnit_Framework_TestCase
'passwords.driver.phpass' => new \phpbb\passwords\driver\phpass($config, $this->driver_helper),
);
- foreach ($this->passwords_drivers as $key => $driver)
- {
- $driver->set_name($key);
- }
-
$this->helper = new \phpbb\passwords\helper;
// Set up passwords manager
$this->manager = new \phpbb\passwords\manager($config, $this->passwords_drivers, $this->helper, array_keys($this->passwords_drivers));
diff --git a/tests/security/hash_test.php b/tests/security/hash_test.php
index 1bccc6726f..bc1bebd87a 100644
--- a/tests/security/hash_test.php
+++ b/tests/security/hash_test.php
@@ -25,11 +25,6 @@ class phpbb_security_hash_test extends phpbb_test_case
'passwords.driver.phpass' => new \phpbb\passwords\driver\phpass($config, $driver_helper),
);
- foreach ($passwords_drivers as $key => $driver)
- {
- $driver->set_name($key);
- }
-
$passwords_helper = new \phpbb\passwords\helper;
// Set up passwords manager
$passwords_manager = new \phpbb\passwords\manager($config, $passwords_drivers, $passwords_helper, array_keys($passwords_drivers));
diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php
index b61fb25326..71d03746a9 100644
--- a/tests/test_framework/phpbb_functional_test_case.php
+++ b/tests/test_framework/phpbb_functional_test_case.php
@@ -1017,11 +1017,6 @@ class phpbb_functional_test_case extends phpbb_test_case
'passwords.driver.phpass' => new \phpbb\passwords\driver\phpass($config, $driver_helper),
);
- foreach ($passwords_drivers as $key => $driver)
- {
- $driver->set_name($key);
- }
-
$passwords_helper = new \phpbb\passwords\helper;
// Set up passwords manager
$manager = new \phpbb\passwords\manager($config, $passwords_drivers, $passwords_helper, array_keys($passwords_drivers));