def save(self, dao, token=None): # Encrypt password with token as the secret if token is None: token = dao.get_config("device_id", None) if token is None: raise MissingToken("Your token has been revoked," " please update your password to acquire a new one.") token = token + "_proxy" password = encrypt(self.password, token) dao.update_config("proxy_password", password) dao.update_config("proxy_username", self.username) dao.update_config("proxy_exceptions", self.exceptions) dao.update_config("proxy_port", self.port) dao.update_config("proxy_type", self.proxy_type) dao.update_config("proxy_config", self.config) dao.update_config("proxy_server", self.server) dao.update_config("proxy_authenticated", self.authenticated)
def set_proxy_settings(self, proxy_settings): session = self.get_session() device_config = self.get_device_config(session) device_config.proxy_config = proxy_settings.config device_config.proxy_type = proxy_settings.proxy_type device_config.proxy_server = proxy_settings.server device_config.proxy_port = proxy_settings.port device_config.proxy_exceptions = proxy_settings.exceptions device_config.proxy_authenticated = proxy_settings.authenticated device_config.proxy_username = proxy_settings.username # Encrypt password with token as the secret token = self.get_first_token(session) if token is None: raise MissingToken("Your token has been revoked," " please update your password to acquire a new one.") password = encrypt(proxy_settings.password, token) device_config.proxy_password = password session.commit() log.debug("Proxy settings successfully updated: %r", proxy_settings) self.invalidate_client_cache()
def set_proxy_settings(self, proxy_settings): session = self.get_session() device_config = self.get_device_config(session) device_config.proxy_config = proxy_settings.config device_config.proxy_type = proxy_settings.proxy_type device_config.proxy_server = proxy_settings.server device_config.proxy_port = proxy_settings.port device_config.proxy_exceptions = proxy_settings.exceptions device_config.proxy_authenticated = proxy_settings.authenticated device_config.proxy_username = proxy_settings.username # Encrypt password with token as the secret token = self.get_first_token(session) if token is None: raise MissingToken( "Your token has been revoked," " please update your password to acquire a new one.") password = encrypt(proxy_settings.password, token) device_config.proxy_password = password session.commit() log.info("Proxy settings successfully updated: %r", proxy_settings) self.invalidate_client_cache()