'Returns a `User` if a correct username and password have been supplied
using HTTP Basic authentication.  Otherwise returns `None`.'

def authenticate(self, request):

    auth = get_authorization_header(request).split()
    if ((not auth) or (auth[0].lower() != 'basic')):
        return None
    if (len(auth) == 1):
        msg = _(u'Invalid    basic    header.    No    credentials    provided.')
        raise exceptions.AuthenticationFailed(msg)
    elif (len(auth) > 2):
        msg = _(u'Invalid    basic    header.    Credentials    string    should    not    contain    spaces.')
        raise exceptions.AuthenticationFailed(msg)
    try:
        auth_parts = base64.b64decode(auth[1]).decode(HTTP_HEADER_ENCODING).partition(u':')
    except (TypeError, UnicodeDecodeError, binascii.Error):
        msg = _(u'Invalid    basic    header.    Credentials    not    correctly    base64    encoded.')
        raise exceptions.AuthenticationFailed(msg)
    (userid, password) = (auth_parts[0], auth_parts[2])
    return self.authenticate_credentials(userid, password)
