# Path: pyfire/auth/backends.py
# class InvalidAuthenticationError(Exception):
#     """Raised upon fail in auth"""
#     pass


from thread import allocate_lock
from pyfire.auth.backends import InvalidAuthenticationError
                self.handlers[backend] = handler
                success = True
        if not success:
            raise AttributeError("backend already known")

    def unregister(self, backend):
        """Unregisters handler for backend"""

        success = False
        with self._lock:
            if backend in self.handlers:
                self.handlers[backend].shutdown()
                del self.handlers[backend]
                success = True
        if not success:
            raise AttributeError("backend unknown")

    def validate_userpass(self, username, password):
        """Checks username and password against all backends. Returns
           backend name where backend reported OK or raises
           InvalidAuthenticationError otherwise.
        """

        result = ""
        with self._lock:
            for backend, handler in self.handlers.iteritems():
                if handler.validate_userpass(username, password):
                    result = backend
                    break
        if result == "":

# Path: pyfire/auth/backends.py
# class InvalidAuthenticationError(Exception):
#     """Raised upon fail in auth"""
#     pass


# Path: pyfire/auth/registry.py
from thread import allocate_lock
from pyfire.auth.backends import InvalidAuthenticationError

                self.handlers[backend] = handler
                success = True
        if not success:
            raise AttributeError("backend already known")

    def unregister(self, backend):
        """Unregisters handler for backend"""

        success = False
        with self._lock:
            if backend in self.handlers:
                self.handlers[backend].shutdown()
                del self.handlers[backend]
                success = True
        if not success:
            raise AttributeError("backend unknown")

    def validate_userpass(self, username, password):
        """Checks username and password against all backends. Returns
           backend name where backend reported OK or raises
           InvalidAuthenticationError otherwise.
        """

        result = ""
        with self._lock:
            for backend, handler in self.handlers.iteritems():
                if handler.validate_userpass(username, password):
                    result = backend
                    break
        if result == "":

            raise InvalidAuthenticationError("username/password invalid")