示例#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)
示例#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_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)
示例#3
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)