Ejemplo n.º 1
0
    def _launch_ssl_dialog(self, domain, details):
        """Launch a dialog used to approve the ssl cert."""
        from ubuntu_sso.utils import get_bin_dir

        bin_dir = get_bin_dir()
        args = (os.path.join(bin_dir, SSL_DIALOG), '--domain', domain,
                                                   '--details', details,
                                                   '--appname', self.appname)
        return spawn_program(args)
Ejemplo n.º 2
0
    def _launch_proxy_creds_dialog(self, domain, retry):
        """Launch the dialog used to get the creds."""
        from ubuntu_sso.utils import get_bin_cmd
        args = get_bin_cmd(UI_PROXY_CREDS_DIALOG)

        args += ['--domain', domain]
        if retry:
            args += ['--retry']
        return spawn_program(args)
Ejemplo n.º 3
0
    def _launch_proxy_creds_dialog(self, domain, retry):
        """Launch the dialog used to get the creds."""
        from ubuntu_sso.utils import get_bin_dir

        bin_dir = get_bin_dir()
        args = (os.path.join(bin_dir, UI_PROXY_CREDS_DIALOG), '--domain',
                                                                  domain)
        if retry:
            args += ('--retry',)
        return spawn_program(args)
Ejemplo n.º 4
0
    def _launch_ssl_dialog(self, domain, details):
        """Launch a dialog used to approve the ssl cert."""
        from ubuntu_sso.utils import get_bin_cmd

        args = get_bin_cmd(UI_SSL_DIALOG)
        args += ['--domain', domain,
                 '--details', details,
                 '--appname', self.appname]

        return spawn_program(args)
Ejemplo n.º 5
0
    def _show_ui(self, login_only):
        """Show the UI and wait for it to finish.

        Upon analyzing returning code from the UI process, emit proper signals
        to the caller.

        The caller can specify a preference for the UI, but if the preferred
        one is not available, the service will try to open any available UI.

        If no GUI is available, GUINotAvailableError will be raised.

        """
        guis = (self.ui_executable, UI_EXECUTABLE_QT)
        for gui_exe_name in guis:
            try:
                args = get_bin_cmd(gui_exe_name)
            except OSError:
                logger.error('The given UI %r does not exist.',
                             gui_exe_name)
            else:
                break
        else:
            raise GUINotAvailableError('Can not find a GUI to present to the '
                                       'user (tried with %r). Aborting.' %
                                       repr(guis))

        for arg in ('app_name', 'help_text', 'ping_url', 'policy_url',
                    'tc_url', 'window_id'):
            value = getattr(self, arg)
            if value:
                args.append('--%s' % arg)
                if not isinstance(value, compat.basestring):
                    value = compat.text_type(value)
                args.append(value)

        if login_only:
            args.append('--login_only')

        return_code = yield runner.spawn_program(args)
        logger.info('_show_ui: received from the ui return code %r.',
                    return_code)

        credentials = None
        if return_code == USER_SUCCESS:
            credentials = yield self.find_credentials()
        elif return_code == USER_CANCELLATION:
            raise UserCancellationError()
        else:
            raise CredentialsError(return_code)

        defer.returnValue(credentials)
Ejemplo n.º 6
0
    def _show_ui(self, login_only):
        """Shows the UI, connect outcome signals."""
        ui_exe_path = os.path.join(get_bin_dir(), self.ui_executable)
        if not os.path.exists(ui_exe_path):
            logger.debug('Falling back to the GTK+ UI since the given %r '
                         'does not exist', ui_exe_path)
            ui_exe_path = os.path.join(get_bin_dir(), UI_EXECUTABLE_GTK)

        assert os.path.exists(ui_exe_path)

        args = [ui_exe_path]
        for arg in ('app_name', 'help_text', 'ping_url', 'policy_url',
                    'tc_url', 'window_id'):
            value = getattr(self, arg)
            if value:
                args.append('--%s' % arg)
                if not isinstance(value, basestring):
                    value = str(value)
                args.append(value)

        if login_only:
            args.append('--login_only')

        return_code = yield runner.spawn_program(args)
        logger.info('_show_ui: received from the ui return code %r.',
                    return_code)

        credentials = None
        if return_code == USER_SUCCESS:
            credentials = yield self.find_credentials()
        elif return_code == USER_CANCELLATION:
            raise UserCancellationError()
        else:
            raise CredentialsError(return_code)

        defer.returnValue(credentials)