コード例 #1
0
 async def login_with_smartcard(self, key_file):
     message = None
     exception = None
     try:
         device = await load_device_with_smartcard(key_file)
         if ParsecApp.is_device_connected(
             device.organization_addr.organization_id, device.device_id
         ):
             message = _("TEXT_LOGIN_ERROR_ALREADY_CONNECTED")
         else:
             self.start_core(device)
     except LocalDeviceCertificatePinCodeUnavailableError:
         # User cancelled the prompt
         self.login_failed.emit()
     except LocalDeviceError as exc:
         message = _("TEXT_LOGIN_ERROR_AUTHENTICATION_FAILED")
         exception = exc
     except ModuleNotFoundError as exc:
         message = _("TEXT_LOGIN_SMARTCARD_NOT_AVAILABLE")
         exception = exc
     except (RuntimeError, MountpointConfigurationError, MountpointDriverCrash) as exc:
         message = _("TEXT_LOGIN_MOUNTPOINT_ERROR")
         exception = exc
     except Exception as exc:
         message = _("TEXT_LOGIN_UNKNOWN_ERROR")
         exception = exc
         logger.exception("Unhandled error during login")
     finally:
         if message:
             show_error(self, message, exception=exception)
             self.login_failed.emit()
コード例 #2
0
    def login_with_password(self, key_file, password):
        message = None
        exception = None
        try:
            device = load_device_with_password(key_file, password)
            if ParsecApp.is_device_connected(
                device.organization_addr.organization_id, device.device_id
            ):
                message = _("TEXT_LOGIN_ERROR_ALREADY_CONNECTED")
            else:
                self.start_core(device)
        except LocalDeviceError as exc:
            message = _("TEXT_LOGIN_ERROR_AUTHENTICATION_FAILED")
            exception = exc

        except (RuntimeError, MountpointConfigurationError, MountpointDriverCrash) as exc:
            message = _("TEXT_LOGIN_MOUNTPOINT_ERROR")
            exception = exc

        except Exception as exc:
            message = _("TEXT_LOGIN_UNKNOWN_ERROR")
            exception = exc
            logger.exception("Unhandled error during login")
        finally:
            if message:
                show_error(self, message, exception=exception)
                self.login_failed.emit()
コード例 #3
0
 def reload_devices(self):
     while self.combo_username.count():
         self.combo_username.removeItem(0)
     # Display devices in `<organization>:<user>@<device>` format
     self.devices = {}
     for available_device in list_available_devices(self.config.config_dir):
         if not ParsecApp.is_device_connected(
                 available_device.organization_id,
                 available_device.device_id):
             name = f"{available_device.organization_id}: {available_device.user_display} @ {available_device.device_display}"
             self.combo_username.addItem(name)
             self.devices[name] = available_device
     last_device = self.config.gui_last_device
     if last_device and last_device in self.devices:
         self.combo_username.setCurrentText(last_device)
     if len(self.devices):
         self.widget_no_device.hide()
         self.widget_login.show()
     else:
         self.widget_no_device.show()
         self.widget_login.hide()
         if ParsecApp.connected_devices:
             self.label_no_device.setText(
                 _("TEXT_LOGIN_NO_AVAILABLE_DEVICE"))
         else:
             self.label_no_device.setText(
                 _("TEXT_LOGIN_NO_DEVICE_ON_MACHINE"))
コード例 #4
0
 def reload_devices(self):
     self._clear_widget()
     devices = [
         device for device in list_available_devices(self.config.config_dir)
         if not ParsecApp.is_device_connected(device.organization_id,
                                              device.device_id)
     ]
     if not len(devices):
         no_device_widget = LoginNoDevicesWidget()
         no_device_widget.create_organization_clicked.connect(
             self.create_organization_clicked.emit)
         no_device_widget.join_organization_clicked.connect(
             self.join_organization_clicked.emit)
         self.widget.layout().addWidget(no_device_widget)
         no_device_widget.setFocus()
     elif len(devices) == 1:
         self._on_account_clicked(devices[0], hide_back=True)
     else:
         accounts_widget = LoginAccountsWidget(devices)
         accounts_widget.account_clicked.connect(self._on_account_clicked)
         self.widget.layout().addWidget(accounts_widget)
         accounts_widget.setFocus()
コード例 #5
0
 def list_devices_and_enrollments(self):
     pendings = PkiEnrollmentSubmitterSubmittedCtx.list_from_disk(
         config_dir=self.config.config_dir)
     devices = [
         device for device in list_available_devices(self.config.config_dir)
         if not ParsecApp.is_device_connected(device.organization_id,
                                              device.device_id)
     ]
     if not len(devices) and not len(pendings):
         no_device_widget = LoginNoDevicesWidget()
         no_device_widget.create_organization_clicked.connect(
             self.create_organization_clicked.emit)
         no_device_widget.join_organization_clicked.connect(
             self.join_organization_clicked.emit)
         no_device_widget.recover_device_clicked.connect(
             self.recover_device_clicked.emit)
         self.widget.layout().addWidget(no_device_widget)
         no_device_widget.setFocus()
     elif len(devices) == 1 and not len(pendings):
         self._on_account_clicked(devices[0], hide_back=True)
     else:
         # If the GUI has a last used device, we look for it in our devices list
         # and insert it to the front, so it will be shown first
         if self.config.gui_last_device:
             last_used = next(
                 (d for d in devices
                  if d.device_id.str == self.config.gui_last_device), None)
             if last_used:
                 devices.remove(last_used)
                 devices.insert(0, last_used)
         accounts_widget = LoginAccountsWidget(self.config, self.jobs_ctx,
                                               devices, pendings)
         accounts_widget.account_clicked.connect(self._on_account_clicked)
         accounts_widget.pending_finalize_clicked.connect(
             self._on_pending_finalize_clicked)
         accounts_widget.pending_clear_clicked.connect(
             self._on_pending_clear_clicked)
         self.widget.layout().addWidget(accounts_widget)
         accounts_widget.setFocus()
コード例 #6
0
ファイル: login_widget.py プロジェクト: anthrax3/parsec-cloud
 def reload_devices(self):
     while self.combo_username.count():
         self.combo_username.removeItem(0)
     devices = list_available_devices(self.config.config_dir)
     # Display devices in `<organization>:<device_id>` format
     self.devices = {}
     for o, d, t, kf in devices:
         if not ParsecApp.is_device_connected(o, d):
             self.combo_username.addItem(f"{o}:{d}")
             self.devices[f"{o}:{d}"] = (o, d, t, kf)
     last_device = self.config.gui_last_device
     if last_device and last_device in self.devices:
         self.combo_username.setCurrentText(last_device)
     if len(self.devices):
         self.widget_no_device.hide()
         self.widget_login.show()
     else:
         self.widget_no_device.show()
         self.widget_login.hide()
         if ParsecApp.connected_devices:
             self.label_no_device.setText(_("TEXT_LOGIN_NO_AVAILABLE_DEVICE"))
         else:
             self.label_no_device.setText(_("TEXT_LOGIN_NO_DEVICE_ON_MACHINE"))