def get_credentials(self, acc): self.__check_valid(acc) try: return Credentials(base64.decodestring(acc["username"]), base64.decodestring(acc["password"])) except Exception, e: raise KeyringException("Cannot decode the base64 username or password for account %s" % (acc.get_name()), e)
def set_account_data(self, account_name): host = self.builder.get_object("host_entry").get_text() port = self.builder.get_object("port_entry").get_text() username = self.builder.get_object("username_entry").get_text() password = self.builder.get_object("password_entry").get_text() ssl = self.builder.get_object("ssl_check").get_active() if host == '' or username == '' or password == '': raise Exception( _("The host, user name and the password are mandatory")) if not self.account: props = { "name": account_name, "provider_name": self.provider.get_name(), "host": host, "port": port, "ssl": ssl, "labels": self.__get_labels() } self.account = AccountCacheMails(props, self.provider) self.account.notifications = {} else: self.account["host"] = host self.account["port"] = port self.account["ssl"] = ssl self.account["labels"] = self.__get_labels() credentials = Credentials(username, password) self.account.set_credentials(credentials) return self.account
def set_account_data_from_widget(self, account_name, widget, account=None): host = self._get_text_value("Host") username = self._get_text_value("User") password = self._get_text_value("Password") port = self._get_text_value("Port") ssl = self._get_check_value("Use SSL") if host == '' or username == '' or password == '': raise Exception( _("The host, user name and the password are mandatory")) if not account: props = { 'name': account_name, 'provider_name': self.get_name(), 'host': host, 'port': port, 'ssl': ssl } account = self.load_account(props) else: account["host"] = host account["port"] = int(port) account["ssl"] = ssl account.set_credentials(Credentials(username, password)) return account
def get_credentials(self, acc): self.lock.acquire() try: logger.debug( "Getting credentials with gnome keyring for account %s" % (acc.get_name())) attrs = gk.Attribute.list_new() gk.Attribute.list_append_string(attrs, 'account_name', acc.get_name()) try: (result, items) = gk.find_items_sync(gk.ItemType.NETWORK_PASSWORD, attrs) except gk.NoMatchError, e: items = list() if len(items) < 1: raise KeyringException( "Cannot find the keyring data for the account %s" % (acc.get_name())) logger.debug("items ok") username = '' for attr in gk.Attribute.list_to_glist(items[0].attributes): if attr.name == 'username': username = attr.get_string() return Credentials(username, items[0].secret)
def set_account_data (self, account_name): pin = self.pin_entry.get_text() if pin=='': raise Exception(_("The PIN is mandatory to set the Twitter account")) self.auth.get_access_token(pin) access_key = self.auth.access_token.key access_secret = self.auth.access_token.secret if not self.account: props = {"name" : account_name, "provider_name" : self.provider.get_name()} self.account = AccountCacheMails(props, self.provider) self.account.notifications = {} credentials = Credentials(access_key, access_secret) self.account.set_credentials(credentials) return self.account
def set_account_data_from_widget(self, account_name, widget, account=None): username = self._get_text_value("User") password = self._get_text_value("Password") if username == '' or password == '': raise Exception(_("The user name and the password are mandatory")) if not account: props = { 'name': account_name, 'provider_name': self.get_name(), 'activate_url': self.activate_url } account = self.load_account(props) account.set_credentials(Credentials(username, password)) return account
def set_account_data_from_widget(self, account_name, widget, account=None): username = self.builder.get_object("username_entry").get_text() password = self.builder.get_object("password_entry").get_text() if not account: props = { "name": account_name, "provider_name": self.get_name(), "labels": self.__get_labels() } account = AccountCacheMails(props, self) account.notifications = {} else: account["labels"] = self.__get_labels() credentials = Credentials(username, password) account.set_credentials(credentials) return account
def set_account_data_from_widget(self, account_name, widget, account=None): username = self._get_text_value ("User") password = self._get_text_value ("Password") show_notifications = self._get_check_value("Show notifications") if username=='' or password=='': raise Exception(_("The user name and the password are mandatory")) if not account: props = {'name' : account_name, 'provider_name' : self.get_name(), 'show_notifications' : show_notifications, 'activate_url' : "http://reader.google.com"} account = self.load_account(props) else: account["show_notifications"] = show_notifications credentials = Credentials(username, password) account.set_credentials(credentials) return account
def load_accounts(self): accs_conf = self.sc.get_accounts_config() for conf in accs_conf.values(): provider = self.pm.get_provider(conf['provider_name']) if provider: try: acc = provider.load_account(conf) if acc.has_credentials(): credentials = Credentials("", "") try: credentials = keyring.get_keyring( ).get_credentials(acc) except Exception, e: logger.exception( "Cannot load credentials for account " + conf["name"] + ": %s", e) acc.set_credentials(credentials) self.add_account(acc) except Exception, e: logger.exception( "Cannot load the account " + conf["name"] + ": %s", e)
def get_credentials(self, acc): self.__check_valid(acc) return Credentials(acc["username"], acc["password"])