def METHOD_NAME(self, username):
    """
    Performs any cleaning on the "username" prior to using it to get or
    create the user object.  Returns the cleaned username.
    By default, changes the username case according to
    `settings.CAS_FORCE_CHANGE_USERNAME_CASE`.
    """
    username_case = settings.CAS_FORCE_CHANGE_USERNAME_CASE
    if username_case == 'lower':
        username = username.lower()
    elif username_case == 'upper':
        username = username.upper()
    elif username_case is not None:
        raise ImproperlyConfigured(
            "Invalid value for the CAS_FORCE_CHANGE_USERNAME_CASE setting. "
            "Valid values are `'lower'`, `'upper'`, and `None`.")
    return username