<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def login(self, username, password):
 """ Log into the WS interface and get the authentication token if login is: - accepted, returns True - refused, returns False In case of any error, raises a BackendException :param username: login name :type username: str :param password: password :type password: str :param generate: Can have these values: enabled | force | disabled :type generate: str :return: return True if authentication is successfull, otherwise False :rtype: bool """

        logger.debug("login for: %s", username)

        # Configured as not authenticated WS
        if not username and not password:
            self.set_token(token=None)
            return False

        if not username or not password:
            logger.error("Username or password cannot be None!")
            self.set_token(token=None)
            return False

        endpoint = 'login'
        json = {'username': username, 'password': password}
        response = self.get_response(method='POST', endpoint=endpoint, json=json)
        if response.status_code == 401:
            logger.error("Access denied to %s", self.url_endpoint_root)
            self.set_token(token=None)
            return False

        resp = self.decode(response=response)

        if 'token' in resp:
            self.set_token(token=resp['token'])
            return True

        return False