summaryrefslogtreecommitdiff
path: root/passlib
diff options
context:
space:
mode:
authorEli Collins <elic@assurancetechnologies.com>2011-03-22 19:33:10 -0400
committerEli Collins <elic@assurancetechnologies.com>2011-03-22 19:33:10 -0400
commit58a8f6b2e93d22e8acb9bef5e1640a1e945bc1e5 (patch)
treeca4d536e10e7a24466e171d91a0fb66d6827754a /passlib
parentde2622bd4f6477983d09a001000f0e30856065d3 (diff)
downloadpasslib-58a8f6b2e93d22e8acb9bef5e1640a1e945bc1e5.tar.gz
big rename: changed base handler class names
============================================ renamed the classes in passlib.utils.handlers, for clarity in code: * BaseHash -> SimpleHandler * ExtHash -> ExtendedHandler * BackendExtHash -> MultiBackendHandler
Diffstat (limited to 'passlib')
-rw-r--r--passlib/handlers/bcrypt.py4
-rw-r--r--passlib/handlers/des_crypt.py10
-rw-r--r--passlib/handlers/digests.py4
-rw-r--r--passlib/handlers/ldap_digests.py8
-rw-r--r--passlib/handlers/md5_crypt.py6
-rw-r--r--passlib/handlers/misc.py6
-rw-r--r--passlib/handlers/mysql.py6
-rw-r--r--passlib/handlers/nthash.py4
-rw-r--r--passlib/handlers/oracle.py4
-rw-r--r--passlib/handlers/phpass.py4
-rw-r--r--passlib/handlers/sha1_crypt.py4
-rw-r--r--passlib/handlers/sha2_crypt.py6
-rw-r--r--passlib/handlers/sun_md5_crypt.py4
-rw-r--r--passlib/tests/_test_bad_register.py6
-rw-r--r--passlib/tests/test_context.py6
-rw-r--r--passlib/tests/test_registry.py18
-rw-r--r--passlib/tests/test_utils_handlers.py36
-rw-r--r--passlib/tests/utils.py16
-rw-r--r--passlib/utils/handlers.py40
19 files changed, 96 insertions, 96 deletions
diff --git a/passlib/handlers/bcrypt.py b/passlib/handlers/bcrypt.py
index 65714c1..cb5614b 100644
--- a/passlib/handlers/bcrypt.py
+++ b/passlib/handlers/bcrypt.py
@@ -22,7 +22,7 @@ except ImportError: #pragma: no cover - though should run whole suite w/o pybcry
pybcrypt_hashpw = None
#libs
from passlib.utils import os_crypt, classproperty
-from passlib.utils.handlers import BackendExtHash
+from passlib.utils.handlers import MultiBackendHandler
#TODO: make this a lazy import, generally don't want to load it.
##from passlib.utils._slow_bcrypt import raw_bcrypt as slow_raw_bcrypt
@@ -36,7 +36,7 @@ __all__ = [
#=========================================================
#handler
#=========================================================
-class bcrypt(BackendExtHash):
+class bcrypt(MultiBackendHandler):
"""This class implements the BCrypt password hash, and follows the :ref:`password-hash-api`.
It supports a fixed-length salt, and a variable number of rounds.
diff --git a/passlib/handlers/des_crypt.py b/passlib/handlers/des_crypt.py
index 110ed09..d237dff 100644
--- a/passlib/handlers/des_crypt.py
+++ b/passlib/handlers/des_crypt.py
@@ -59,7 +59,7 @@ from warnings import warn
#site
#libs
from passlib.utils import h64, classproperty, os_crypt
-from passlib.utils.handlers import BackendExtHash, ExtHash
+from passlib.utils.handlers import MultiBackendHandler, ExtendedHandler
from passlib.utils.des import mdes_encrypt_int_block
#pkg
#local
@@ -136,7 +136,7 @@ def raw_ext_crypt(secret, rounds, salt):
#=========================================================
#handler
#=========================================================
-class des_crypt(BackendExtHash):
+class des_crypt(MultiBackendHandler):
"""This class implements the des-crypt password hash, and follows the :ref:`password-hash-api`.
It supports a fixed-length salt.
@@ -227,7 +227,7 @@ class des_crypt(BackendExtHash):
#=========================================================
#handler
#=========================================================
-class bsdi_crypt(ExtHash):
+class bsdi_crypt(ExtendedHandler):
"""This class implements the BSDi-Crypt password hash, and follows the :ref:`password-hash-api`.
It supports a fixed-length salt, and a variable number of rounds.
@@ -312,7 +312,7 @@ class bsdi_crypt(ExtHash):
#=========================================================
#
#=========================================================
-class bigcrypt(ExtHash):
+class bigcrypt(ExtendedHandler):
"""This class implements the BigCrypt password hash, and follows the :ref:`password-hash-api`.
It supports a fixed-length salt.
@@ -387,7 +387,7 @@ class bigcrypt(ExtHash):
#=========================================================
#
#=========================================================
-class crypt16(ExtHash):
+class crypt16(ExtendedHandler):
"""This class implements the crypt16 password hash, and follows the :ref:`password-hash-api`.
It supports a fixed-length salt.
diff --git a/passlib/handlers/digests.py b/passlib/handlers/digests.py
index 56cc869..c4d13a6 100644
--- a/passlib/handlers/digests.py
+++ b/passlib/handlers/digests.py
@@ -10,7 +10,7 @@ from warnings import warn
#site
#libs
from passlib.utils.md4 import md4
-from passlib.utils.handlers import BaseHash
+from passlib.utils.handlers import SimpleHandler
#pkg
#local
__all__ = [
@@ -25,7 +25,7 @@ __all__ = [
#=========================================================
#helpers for hexidecimal hashes
#=========================================================
-class HexDigestHash(BaseHash):
+class HexDigestHash(SimpleHandler):
"this provides a template for supporting passwords stored as plain hexidecimal hashes"
setting_kwds = ()
context_kwds = ()
diff --git a/passlib/handlers/ldap_digests.py b/passlib/handlers/ldap_digests.py
index 5e907cb..7942f3f 100644
--- a/passlib/handlers/ldap_digests.py
+++ b/passlib/handlers/ldap_digests.py
@@ -10,7 +10,7 @@ import re
from warnings import warn
#site
#libs
-from passlib.utils.handlers import ExtHash, BaseHash
+from passlib.utils.handlers import ExtendedHandler, SimpleHandler
#pkg
#local
__all__ = [
@@ -25,7 +25,7 @@ __all__ = [
#=========================================================
#reference - http://www.openldap.org/doc/admin24/security.html
-class _Base64DigestHelper(BaseHash):
+class _Base64DigestHelper(SimpleHandler):
"helper for ldap_md5 / ldap_sha1"
#_ident
@@ -46,7 +46,7 @@ class _Base64DigestHelper(BaseHash):
raise ValueError, "not a %s hash" % (cls.name,)
return cls._ident + cls._hash(secret).digest().encode("base64").strip()
-class _SaltedBase64DigestHelper(ExtHash):
+class _SaltedBase64DigestHelper(ExtendedHandler):
"helper for ldap_salted_md5 / ldap_salted_sha1"
setting_kwds = ("salt",)
@@ -145,7 +145,7 @@ class ldap_salted_sha1(_SaltedBase64DigestHelper):
_pat = re.compile(r"^\{SSHA\}(?P<tmp>[+/a-zA-Z0-9]{32})$")
_default_chk = '\x00' * 20
-class ldap_cleartext(BaseHash):
+class ldap_cleartext(SimpleHandler):
"""This class stores passwords in plaintext, and follows the :ref:`password-hash-api`.
Unicode passwords will be encoded using utf-8.
diff --git a/passlib/handlers/md5_crypt.py b/passlib/handlers/md5_crypt.py
index 19f40a3..07081a0 100644
--- a/passlib/handlers/md5_crypt.py
+++ b/passlib/handlers/md5_crypt.py
@@ -10,7 +10,7 @@ from warnings import warn
#site
#libs
from passlib.utils import h64, os_crypt, classproperty
-from passlib.utils.handlers import ExtHash, BackendExtHash
+from passlib.utils.handlers import ExtendedHandler, MultiBackendHandler
#pkg
#local
__all__ = [
@@ -126,7 +126,7 @@ _chk_offsets = (
#=========================================================
#handler
#=========================================================
-class md5_crypt(BackendExtHash):
+class md5_crypt(MultiBackendHandler):
"""This class implements the MD5-Crypt password hash, and follows the :ref:`password-hash-api`.
It supports a variable-length salt.
@@ -216,7 +216,7 @@ class md5_crypt(BackendExtHash):
#=========================================================
#apache variant of md5-crypt
#=========================================================
-class apr_md5_crypt(ExtHash):
+class apr_md5_crypt(ExtendedHandler):
"""This class implements the Apr-MD5-Crypt password hash, and follows the :ref:`password-hash-api`.
It supports a variable-length salt.
diff --git a/passlib/handlers/misc.py b/passlib/handlers/misc.py
index 6b6b3e4..c0c402a 100644
--- a/passlib/handlers/misc.py
+++ b/passlib/handlers/misc.py
@@ -8,7 +8,7 @@ import logging; log = logging.getLogger(__name__)
from warnings import warn
#site
#libs
-from passlib.utils.handlers import BaseHash
+from passlib.utils.handlers import SimpleHandler
#pkg
#local
__all__ = [
@@ -19,7 +19,7 @@ __all__ = [
#=========================================================
#handler
#=========================================================
-class unix_fallback(BaseHash):
+class unix_fallback(SimpleHandler):
"""This class fallback behavior for unix shadow files, and follows the :ref:`password-hash-api`.
This class does not implement a hash, but instead provides fallback
@@ -57,7 +57,7 @@ class unix_fallback(BaseHash):
raise ValueError, "no hash provided"
return not hash
-class plaintext(BaseHash):
+class plaintext(SimpleHandler):
"""This class stores passwords in plaintext, and follows the :ref:`password-hash-api`.
Unicode passwords will be encoded using utf-8.
diff --git a/passlib/handlers/mysql.py b/passlib/handlers/mysql.py
index bea0416..c8f8331 100644
--- a/passlib/handlers/mysql.py
+++ b/passlib/handlers/mysql.py
@@ -30,7 +30,7 @@ from warnings import warn
#site
#libs
#pkg
-from passlib.utils.handlers import BaseHash
+from passlib.utils.handlers import SimpleHandler
#local
__all__ = [
'mysql323',
@@ -40,7 +40,7 @@ __all__ = [
#=========================================================
#backend
#=========================================================
-class mysql323(BaseHash):
+class mysql323(SimpleHandler):
"""This class implements the MySQL 3.2.3 password hash, and follows the :ref:`password-hash-api`.
It has no salt and a single fixed round.
@@ -109,7 +109,7 @@ class mysql323(BaseHash):
#=========================================================
#handler
#=========================================================
-class mysql41(BaseHash):
+class mysql41(SimpleHandler):
"""This class implements the MySQL 4.1 password hash, and follows the :ref:`password-hash-api`.
It has no salt and a single fixed round.
diff --git a/passlib/handlers/nthash.py b/passlib/handlers/nthash.py
index b4d4224..0824710 100644
--- a/passlib/handlers/nthash.py
+++ b/passlib/handlers/nthash.py
@@ -9,7 +9,7 @@ from warnings import warn
#site
#libs
from passlib.utils.md4 import md4
-from passlib.utils.handlers import ExtHash
+from passlib.utils.handlers import ExtendedHandler
#pkg
#local
__all__ = [
@@ -19,7 +19,7 @@ __all__ = [
#=========================================================
#handler
#=========================================================
-class nthash(ExtHash):
+class nthash(ExtendedHandler):
"""This class implements the NT Password hash in a manner compatible with the :ref:`modular-crypt-format`, and follows the :ref:`password-hash-api`.
It has no salt and a single fixed round.
diff --git a/passlib/handlers/oracle.py b/passlib/handlers/oracle.py
index 9f04d72..1e67b53 100644
--- a/passlib/handlers/oracle.py
+++ b/passlib/handlers/oracle.py
@@ -13,7 +13,7 @@ from warnings import warn
#pkg
from passlib.utils import xor_bytes
from passlib.utils.des import des_encrypt_block
-from passlib.utils.handlers import ExtHash
+from passlib.utils.handlers import ExtendedHandler
#local
__all__ = [
"oracle10g",
@@ -135,7 +135,7 @@ class oracle10(object):
#=========================================================
#oracle11
#=========================================================
-class oracle11(ExtHash):
+class oracle11(ExtendedHandler):
"""This class implements the Oracle11g password hash, and follows the :ref:`password-hash-api`.
It supports a fixed-length salt.
diff --git a/passlib/handlers/phpass.py b/passlib/handlers/phpass.py
index cbf6c70..6c93554 100644
--- a/passlib/handlers/phpass.py
+++ b/passlib/handlers/phpass.py
@@ -16,7 +16,7 @@ from warnings import warn
#site
#libs
from passlib.utils import h64
-from passlib.utils.handlers import ExtHash
+from passlib.utils.handlers import ExtendedHandler
#pkg
#local
__all__ = [
@@ -26,7 +26,7 @@ __all__ = [
#=========================================================
#phpass
#=========================================================
-class phpass(ExtHash):
+class phpass(ExtendedHandler):
"""This class implements the PHPass Portable Hash, and follows the :ref:`password-hash-api`.
It supports a fixed-length salt, and a variable number of rounds.
diff --git a/passlib/handlers/sha1_crypt.py b/passlib/handlers/sha1_crypt.py
index 482c3ce..ab7af26 100644
--- a/passlib/handlers/sha1_crypt.py
+++ b/passlib/handlers/sha1_crypt.py
@@ -14,7 +14,7 @@ from warnings import warn
#site
#libs
from passlib.utils import h64
-from passlib.utils.handlers import ExtHash
+from passlib.utils.handlers import ExtendedHandler
from passlib.utils.pbkdf2 import hmac_sha1
#pkg
#local
@@ -23,7 +23,7 @@ __all__ = [
#=========================================================
#sha1-crypt
#=========================================================
-class sha1_crypt(ExtHash):
+class sha1_crypt(ExtendedHandler):
"""This class implements the SHA1-Crypt password hash, and follows the :ref:`password-hash-api`.
It supports a variable-length salt, and a variable number of rounds.
diff --git a/passlib/handlers/sha2_crypt.py b/passlib/handlers/sha2_crypt.py
index 7a795cf..e15203c 100644
--- a/passlib/handlers/sha2_crypt.py
+++ b/passlib/handlers/sha2_crypt.py
@@ -10,7 +10,7 @@ from warnings import warn
#site
#libs
from passlib.utils import h64, os_crypt, classproperty
-from passlib.utils.handlers import BackendExtHash
+from passlib.utils.handlers import MultiBackendHandler
#pkg
#local
__all__ = [
@@ -205,7 +205,7 @@ _512_offsets = (
#=========================================================
#handler
#=========================================================
-class sha256_crypt(BackendExtHash):
+class sha256_crypt(MultiBackendHandler):
"""This class implements the SHA256-Crypt password hash, and follows the :ref:`password-hash-api`.
It supports a variable-length salt, and a variable number of rounds.
@@ -350,7 +350,7 @@ class sha256_crypt(BackendExtHash):
#=========================================================
#sha 512 crypt
#=========================================================
-class sha512_crypt(BackendExtHash):
+class sha512_crypt(MultiBackendHandler):
"""This class implements the SHA512-Crypt password hash, and follows the :ref:`password-hash-api`.
It supports a variable-length salt, and a variable number of rounds.
diff --git a/passlib/handlers/sun_md5_crypt.py b/passlib/handlers/sun_md5_crypt.py
index 3600f74..514c4de 100644
--- a/passlib/handlers/sun_md5_crypt.py
+++ b/passlib/handlers/sun_md5_crypt.py
@@ -26,7 +26,7 @@ from warnings import warn
#site
#libs
from passlib.utils import h64
-from passlib.utils.handlers import ExtHash
+from passlib.utils.handlers import ExtendedHandler
#pkg
#local
__all__ = [
@@ -190,7 +190,7 @@ _chk_offsets = (
#=========================================================
#handler
#=========================================================
-class sun_md5_crypt(ExtHash):
+class sun_md5_crypt(ExtendedHandler):
"""This class implements the Sun-MD5-Crypt password hash, and follows the :ref:`password-hash-api`.
It supports a variable-length salt, and a variable number of rounds.
diff --git a/passlib/tests/_test_bad_register.py b/passlib/tests/_test_bad_register.py
index 50b57c9..39d6443 100644
--- a/passlib/tests/_test_bad_register.py
+++ b/passlib/tests/_test_bad_register.py
@@ -1,13 +1,13 @@
"helper for method in test_registry.py"
from passlib.registry import register_crypt_handler
-from passlib.utils.handlers import BaseHash
+from passlib.utils.handlers import SimpleHandler
-class dummy_bad(BaseHash):
+class dummy_bad(SimpleHandler):
name = "dummy_bad"
setting_kwds = ()
-class alt_dummy_bad(BaseHash):
+class alt_dummy_bad(SimpleHandler):
name = "dummy_bad"
setting_kwds = ()
diff --git a/passlib/tests/test_context.py b/passlib/tests/test_context.py
index 343400c..ed5355e 100644
--- a/passlib/tests/test_context.py
+++ b/passlib/tests/test_context.py
@@ -14,7 +14,7 @@ import sys
#pkg
from passlib import hash
from passlib.context import CryptContext, CryptPolicy
-from passlib.utils.handlers import BaseHash
+from passlib.utils.handlers import SimpleHandler
from passlib.tests.utils import TestCase, mktemp, catch_warnings
from passlib.handlers.md5_crypt import md5_crypt as AnotherHash
from passlib.tests.test_utils_handlers import UnsaltedHash, SaltedHash
@@ -163,10 +163,10 @@ admin.sha512_crypt.max_rounds = 40000
)
#check with bad handler
- self.assertRaises(TypeError, CryptPolicy, schemes=[BaseHash])
+ self.assertRaises(TypeError, CryptPolicy, schemes=[SimpleHandler])
#check with multiple handlers
- class dummy_1(BaseHash):
+ class dummy_1(SimpleHandler):
name = 'dummy_1'
self.assertRaises(KeyError, CryptPolicy, schemes=[dummy_1, dummy_1])
diff --git a/passlib/tests/test_registry.py b/passlib/tests/test_registry.py
index 29b58fd..6839590 100644
--- a/passlib/tests/test_registry.py
+++ b/passlib/tests/test_registry.py
@@ -15,7 +15,7 @@ import sys
from passlib import hash, registry
from passlib.registry import register_crypt_handler, register_crypt_handler_path, \
get_crypt_handler, list_crypt_handlers
-from passlib.utils.handlers import BaseHash
+from passlib.utils.handlers import SimpleHandler
from passlib.tests.utils import TestCase, mktemp, catch_warnings
#module
log = getLogger(__name__)
@@ -23,11 +23,11 @@ log = getLogger(__name__)
#=========================================================
#test registry
#=========================================================
-class dummy_0(BaseHash):
+class dummy_0(SimpleHandler):
name = "dummy_0"
setting_kwds = ()
-class alt_dummy_0(BaseHash):
+class alt_dummy_0(SimpleHandler):
name = "dummy_0"
setting_kwds = ()
@@ -101,14 +101,14 @@ class RegistryTest(TestCase):
self.assertRaises(TypeError, register_crypt_handler, {})
- self.assertRaises(ValueError, register_crypt_handler, BaseHash)
- self.assertRaises(ValueError, register_crypt_handler, type('x', (BaseHash,), dict(name="AB_CD")))
- self.assertRaises(ValueError, register_crypt_handler, type('x', (BaseHash,), dict(name="ab-cd")))
+ self.assertRaises(ValueError, register_crypt_handler, SimpleHandler)
+ self.assertRaises(ValueError, register_crypt_handler, type('x', (SimpleHandler,), dict(name="AB_CD")))
+ self.assertRaises(ValueError, register_crypt_handler, type('x', (SimpleHandler,), dict(name="ab-cd")))
- class dummy_1(BaseHash):
+ class dummy_1(SimpleHandler):
name = "dummy_1"
- class dummy_1b(BaseHash):
+ class dummy_1b(SimpleHandler):
name = "dummy_1"
self.assertTrue('dummy_1' not in list_crypt_handlers())
@@ -128,7 +128,7 @@ class RegistryTest(TestCase):
def test_get_crypt_handler(self):
"test get_crypt_handler()"
- class dummy_1(BaseHash):
+ class dummy_1(SimpleHandler):
name = "dummy_1"
self.assertRaises(KeyError, get_crypt_handler, "dummy_1")
diff --git a/passlib/tests/test_utils_handlers.py b/passlib/tests/test_utils_handlers.py
index 37ff800..f697d9e 100644
--- a/passlib/tests/test_utils_handlers.py
+++ b/passlib/tests/test_utils_handlers.py
@@ -11,13 +11,13 @@ import warnings
#site
#pkg
from passlib.utils import rng, getrandstr
-from passlib.utils.handlers import BackendExtHash, ExtHash, BaseHash
+from passlib.utils.handlers import MultiBackendHandler, ExtendedHandler, SimpleHandler
from passlib.tests.utils import HandlerCase, TestCase, catch_warnings
#module
log = getLogger(__name__)
#=========================================================
-#test support classes - BaseHash, etc
+#test support classes - SimpleHandler, etc
#=========================================================
class SkeletonTest(TestCase):
"test hash support classes"
@@ -27,7 +27,7 @@ class SkeletonTest(TestCase):
#=========================================================
def test_00_base_hash(self):
- class d1(BaseHash):
+ class d1(SimpleHandler):
name = "d1"
setting_kwds = ('dummy',)
@@ -38,7 +38,7 @@ class SkeletonTest(TestCase):
return 'a'
#check internal properties
- self.assertRaises(RuntimeError, getattr, BaseHash, "_has_settings")
+ self.assertRaises(RuntimeError, getattr, SimpleHandler, "_has_settings")
#check identify method
self.assertTrue(d1.identify('a'))
@@ -49,13 +49,13 @@ class SkeletonTest(TestCase):
#check default genconfig
self.assertRaises(NotImplementedError, d1.genconfig, dummy='xxx')
- class d3(BaseHash):
+ class d3(SimpleHandler):
name = 'd3'
setting_kwds = ()
self.assertRaises(TypeError, d3.genconfig, dummy='xxx')
#check default genhash
- class d2(BaseHash):
+ class d2(SimpleHandler):
name = "d2"
setting_kwds = ("dummy",)
self.assertRaises(NotImplementedError, d2.genhash, 'stub', 'hash')
@@ -64,7 +64,7 @@ class SkeletonTest(TestCase):
#ext hash
#=========================================================
def test_10_ext_hash(self):
- class d1(ExtHash):
+ class d1(ExtendedHandler):
setting_kwds = ()
max_salt_chars = 2
@@ -76,9 +76,9 @@ class SkeletonTest(TestCase):
raise ValueError
#check internal properties
- self.assertRaises(RuntimeError, getattr, ExtHash, "_has_settings")
- self.assertRaises(RuntimeError, getattr, ExtHash, "_has_salt")
- self.assertRaises(RuntimeError, getattr, ExtHash, "_has_rounds")
+ self.assertRaises(RuntimeError, getattr, ExtendedHandler, "_has_settings")
+ self.assertRaises(RuntimeError, getattr, ExtendedHandler, "_has_salt")
+ self.assertRaises(RuntimeError, getattr, ExtendedHandler, "_has_rounds")
#check min salt chars
self.assertEqual(d1.min_salt_chars, 2)
@@ -90,7 +90,7 @@ class SkeletonTest(TestCase):
self.assertFalse(d1.identify('b'))
def test_11_norm_checksum(self):
- class d1(ExtHash):
+ class d1(ExtendedHandler):
checksum_chars = 4
checksum_charset = 'x'
self.assertRaises(ValueError, d1.norm_checksum, 'xxx')
@@ -99,7 +99,7 @@ class SkeletonTest(TestCase):
self.assertRaises(ValueError, d1.norm_checksum, 'xxyx')
def test_12_norm_salt(self):
- class d1(ExtHash):
+ class d1(ExtendedHandler):
name = 'd1'
setting_kwds = ('salt',)
min_salt_chars = 1
@@ -119,14 +119,14 @@ class SkeletonTest(TestCase):
self.assertRaises(ValueError, d1.norm_salt, 'aaaa', strict=True)
#check no salt kwd
- class d2(ExtHash):
+ class d2(ExtendedHandler):
name = "d2"
setting_kwds = ("dummy",)
self.assertRaises(TypeError, d2.norm_salt, 1)
self.assertIs(d2.norm_salt(None), None)
def test_13_norm_rounds(self):
- class d1(ExtHash):
+ class d1(ExtendedHandler):
name = 'd1'
setting_kwds = ('rounds',)
min_rounds = 1
@@ -150,7 +150,7 @@ class SkeletonTest(TestCase):
self.assertRaises(ValueError, d1.norm_rounds, None)
#check no rounds keyword
- class d2(ExtHash):
+ class d2(ExtendedHandler):
name = "d2"
setting_kwds = ("dummy",)
self.assertRaises(TypeError, d2.norm_rounds, 1)
@@ -160,7 +160,7 @@ class SkeletonTest(TestCase):
#backend ext hash
#=========================================================
def test_20_backend_ext_hash(self):
- class d1(BackendExtHash):
+ class d1(MultiBackendHandler):
name = 'd1'
setting_kwds = ()
@@ -205,7 +205,7 @@ class SkeletonTest(TestCase):
# to test the unittests themselves, as well as other
# parts of passlib. they shouldn't be used as actual password schemes.
#=========================================================
-class UnsaltedHash(ExtHash):
+class UnsaltedHash(ExtendedHandler):
"test algorithm which lacks a salt"
name = "unsalted_test_hash"
setting_kwds = ()
@@ -228,7 +228,7 @@ class UnsaltedHash(ExtHash):
secret = secret.encode("utf-8")
return hashlib.sha1("boblious" + secret).hexdigest()
-class SaltedHash(ExtHash):
+class SaltedHash(ExtendedHandler):
"test algorithm with a salt"
name = "salted_test_hash"
setting_kwds = ("salt",)
diff --git a/passlib/tests/utils.py b/passlib/tests/utils.py
index 6b4bd0e..e7b59e1 100644
--- a/passlib/tests/utils.py
+++ b/passlib/tests/utils.py
@@ -25,7 +25,7 @@ except ImportError:
from nose.plugins.skip import SkipTest
#pkg
from passlib.utils import classproperty
-from passlib.utils.handlers import BaseHash, ExtHash, BackendExtHash
+from passlib.utils.handlers import SimpleHandler, ExtendedHandler, MultiBackendHandler
#local
__all__ = [
#util funcs
@@ -203,7 +203,7 @@ class TestCase(unittest.TestCase):
#other unittest helpers
#=========================================================
class HandlerCase(TestCase):
- """base class for testing password hash handlers (esp passlib.utils.handlers.BaseHash subclasses)
+ """base class for testing password hash handlers (esp passlib.utils.handlers.SimpleHandler subclasses)
.. todo::
write directions on how to use this class.
@@ -342,9 +342,9 @@ class HandlerCase(TestCase):
#TODO: check optional rounds attributes & salt attributes
def test_04_base_handler(self):
- "check configuration of BaseHash-derived classes"
+ "check configuration of SimpleHandler-derived classes"
cls = self.handler
- if not isinstance(cls, type) or not issubclass(cls, BaseHash):
+ if not isinstance(cls, type) or not issubclass(cls, SimpleHandler):
raise SkipTest
if not cls.name:
@@ -354,9 +354,9 @@ class HandlerCase(TestCase):
raise AssertionError, "class must have .setting_kwds attribute set"
def test_05_ext_handler(self):
- "check configuration of ExtHash-derived classes"
+ "check configuration of ExtendedHandler-derived classes"
cls = self.handler
- if not isinstance(cls, type) or not issubclass(cls, ExtHash):
+ if not isinstance(cls, type) or not issubclass(cls, ExtendedHandler):
raise SkipTest
if any(k not in cls.setting_kwds for k in cls._extra_init_settings):
@@ -393,7 +393,7 @@ class HandlerCase(TestCase):
raise AssertionError, "unknown rounds cost function"
def test_06_backend_handler(self):
- "check configuration of BackendExtHash-derived classes"
+ "check configuration of MultiBackendHandler-derived classes"
h = self.handler
if not hasattr(h, "get_backend"):
raise SkipTest
@@ -674,7 +674,7 @@ class HandlerCase(TestCase):
#=========================================================
def enable_backend_case(handler, name):
"helper to check if a separate test is needed for the specified backend"
- assert issubclass(handler, BackendExtHash), "handler must derived from BackendExtHash"
+ assert issubclass(handler, MultiBackendHandler), "handler must derived from MultiBackendHandler"
assert name in handler.backends, "unknown backend: %r" % (name,)
return enable_option("all-backends") and handler.get_backend() != name and handler.has_backend(name)
diff --git a/passlib/utils/handlers.py b/passlib/utils/handlers.py
index b3a97cd..0f517d4 100644
--- a/passlib/utils/handlers.py
+++ b/passlib/utils/handlers.py
@@ -19,15 +19,15 @@ from passlib.utils import classproperty, h64, getrandstr, rng, is_crypt_handler
__all__ = [
#framework for implementing handlers
- 'BaseHash',
- 'ExtHash',
- 'BackendExtHash',
+ 'SimpleHandler',
+ 'ExtendedHandler',
+ 'MultiBackendHandler',
]
#=========================================================
#base handler
#=========================================================
-class BaseHash(object):
+class SimpleHandler(object):
"""helper for implementing password hash handler with minimal methods
hash implementations should fill out the following:
@@ -118,13 +118,13 @@ class BaseHash(object):
#=====================================================
#=========================================================
-# ExtHash
+# ExtendedHandler
# rounds+salt+xtra phpass, sha256_crypt, sha512_crypt
# rounds+salt bcrypt, ext_des_crypt, sha1_crypt, sun_md5_crypt
# salt apr_md5_crypt, des_crypt, md5_crypt
# nothing mysql_323, mysql_41, nthash, postgres_md5
#=========================================================
-class ExtHash(BaseHash):
+class ExtendedHandler(SimpleHandler):
"""helper class for implementing hash schemes
hash implementations should fill out the following:
@@ -159,8 +159,8 @@ class ExtHash(BaseHash):
#----------------------------------------------
#password hash api - required attributes
#----------------------------------------------
- name = None #required by ExtHash
- setting_kwds = None #required by ExtHash
+ name = None #required by ExtendedHandler
+ setting_kwds = None #required by ExtendedHandler
context_kwds = ()
#----------------------------------------------
@@ -172,7 +172,7 @@ class ExtHash(BaseHash):
#----------------------------------------------
#salt information
#----------------------------------------------
- max_salt_chars = None #required by ExtHash.norm_salt()
+ max_salt_chars = None #required by ExtendedHandler.norm_salt()
@classproperty
def min_salt_chars(cls):
@@ -194,15 +194,15 @@ class ExtHash(BaseHash):
#rounds information
#----------------------------------------------
min_rounds = 0
- max_rounds = None #required by ExtHash.norm_rounds()
- default_rounds = None #if not specified, ExtHash.norm_rounds() will require explicit rounds value every time
+ max_rounds = None #required by ExtendedHandler.norm_rounds()
+ default_rounds = None #if not specified, ExtendedHandler.norm_rounds() will require explicit rounds value every time
rounds_cost = "linear" #common case
#----------------------------------------------
- #misc ExtHash configuration
+ #misc ExtendedHandler configuration
#----------------------------------------------
_strict_rounds_bounds = False #if true, always raises error if specified rounds values out of range - required by spec for some hashes
- _extra_init_settings = () #settings that ExtHash.__init__ should handle by calling norm_<key>()
+ _extra_init_settings = () #settings that ExtendedHandler.__init__ should handle by calling norm_<key>()
#=========================================================
#instance attributes
@@ -227,7 +227,7 @@ class ExtHash(BaseHash):
norm = getattr(self, "norm_" + key)
value = norm(value, strict=strict)
setattr(self, key, value)
- super(ExtHash, self).__init__(**kwds)
+ super(ExtendedHandler, self).__init__(**kwds)
#=========================================================
#init helpers
@@ -240,16 +240,16 @@ class ExtHash(BaseHash):
@classproperty
def _has_salt(cls):
"attr for checking if salts are supported, memoizes itself on first use"
- if cls is ExtHash:
- raise RuntimeError, "not allowed for ExtHash directly"
+ if cls is ExtendedHandler:
+ raise RuntimeError, "not allowed for ExtendedHandler directly"
value = cls._has_salt = 'salt' in cls.setting_kwds
return value
@classproperty
def _has_rounds(cls):
"attr for checking if variable are supported, memoizes itself on first use"
- if cls is ExtHash:
- raise RuntimeError, "not allowed for ExtHash directly"
+ if cls is ExtendedHandler:
+ raise RuntimeError, "not allowed for ExtendedHandler directly"
value = cls._has_rounds = 'rounds' in cls.setting_kwds
return value
@@ -463,8 +463,8 @@ class ExtHash(BaseHash):
#helpful mixin which provides lazy-loading of different backends
#to be used for calc_checksum
#=========================================================
-class BackendExtHash(ExtHash):
- "subclass of ExtHash which provides selecting from multiple backends for checksum calculation"
+class MultiBackendHandler(ExtendedHandler):
+ "subclass of ExtendedHandler which provides selecting from multiple backends for checksum calculation"
#NOTE: subclass must provide:
# * attr 'backends' containing list of known backends (top priority backend first)