def _on_proxy_authentication_required(self, url, authenticator,
                                       proxy_host):
     """Called when a proxy needs authentication."""
     msg = "<b>{}</b> requires a username and password.".format(
         html_utils.escape(proxy_host))
     answer = message.ask(title="Proxy authentication required",
                          text=msg,
                          mode=usertypes.PromptMode.user_pwd,
                          abort_on=[self.shutting_down, self.load_started])
     if answer is not None:
         authenticator.setUser(answer.user)
         authenticator.setPassword(answer.password)
     else:
         try:
             # pylint: disable=no-member, useless-suppression
             sip.assign(authenticator, QAuthenticator())
         except AttributeError:
             url_string = url.toDisplayString()
             error_page = jinja.render(
                 'error.html',
                 title="Error loading page: {}".format(url_string),
                 url=url_string,
                 error="Proxy authentication required",
                 icon='')
             self.set_html(error_page)
Beispiel #2
0
 def _on_proxy_authentication_required(self, url, authenticator,
                                       proxy_host):
     """Called when a proxy needs authentication."""
     msg = "<b>{}</b> requires a username and password.".format(
         html_utils.escape(proxy_host))
     answer = message.ask(
         title="Proxy authentication required", text=msg,
         mode=usertypes.PromptMode.user_pwd,
         abort_on=[self.shutting_down, self.load_started])
     if answer is not None:
         authenticator.setUser(answer.user)
         authenticator.setPassword(answer.password)
     else:
         try:
             # pylint: disable=no-member, useless-suppression
             sip.assign(authenticator, QAuthenticator())
             # pylint: enable=no-member, useless-suppression
         except AttributeError:
             url_string = url.toDisplayString()
             error_page = jinja.render(
                 'error.html',
                 title="Error loading page: {}".format(url_string),
                 url=url_string, error="Proxy authentication required",
                 icon='')
             self.set_html(error_page)
Beispiel #3
0
 def handleAuthenticationRequired(self, requestUrl, auth):
     netrc_file = os.path.expanduser('~/.netrc')
     try:
         info = netrc.netrc(netrc_file)
         (login, account, password) = info.hosts['occweb']
         auth.setPassword(password)
         auth.setUser(login)
     except:
         sip.assign(auth, QtN.QAuthenticator())
Beispiel #4
0
 def _on_authentication_required(self, url, authenticator):
     # FIXME:qtwebengine support .netrc
     answer = shared.authentication_required(
         url, authenticator, abort_on=[self.shutting_down,
                                       self.load_started])
     if answer is None:
         try:
             # pylint: disable=no-member, useless-suppression
             sip.assign(authenticator, QAuthenticator())
         except AttributeError:
             # WORKAROUND for
             # https://www.riverbankcomputing.com/pipermail/pyqt/2016-December/038400.html
             url_string = url.toDisplayString()
             error_page = jinja.render(
                 'error.html',
                 title="Error loading page: {}".format(url_string),
                 url=url_string, error="Authentication required", icon='')
             self.set_html(error_page)
 def _on_authentication_required(self, url, authenticator):
     netrc_success = False
     if not self.data.netrc_used:
         self.data.netrc_used = True
         netrc_success = shared.netrc_authentication(url, authenticator)
     if not netrc_success:
         abort_on = [self.shutting_down, self.load_started]
         answer = shared.authentication_required(url, authenticator,
                                                 abort_on)
     if not netrc_success and answer is None:
         try:
             # pylint: disable=no-member, useless-suppression
             sip.assign(authenticator, QAuthenticator())
             # pylint: enable=no-member, useless-suppression
         except AttributeError:
             # WORKAROUND for
             # https://www.riverbankcomputing.com/pipermail/pyqt/2016-December/038400.html
             self._show_error_page(url, "Authentication required")
Beispiel #6
0
 def _on_authentication_required(self, url, authenticator):
     netrc_success = False
     if not self.data.netrc_used:
         self.data.netrc_used = True
         netrc_success = shared.netrc_authentication(url, authenticator)
     if not netrc_success:
         abort_on = [self.shutting_down, self.load_started]
         answer = shared.authentication_required(url, authenticator,
                                                 abort_on)
     if not netrc_success and answer is None:
         try:
             # pylint: disable=no-member, useless-suppression
             sip.assign(authenticator, QAuthenticator())
             # pylint: enable=no-member, useless-suppression
         except AttributeError:
             # WORKAROUND for
             # https://www.riverbankcomputing.com/pipermail/pyqt/2016-December/038400.html
             self._show_error_page(url, "Authentication required")
Beispiel #7
0
 def _on_authentication_required(self, url, authenticator):
     # FIXME:qtwebengine support .netrc
     answer = shared.authentication_required(
         url, authenticator, abort_on=[self.shutting_down,
                                       self.load_started])
     if answer is None:
         try:
             # pylint: disable=no-member, useless-suppression
             sip.assign(authenticator, QAuthenticator())
         except AttributeError:
             # WORKAROUND for
             # https://www.riverbankcomputing.com/pipermail/pyqt/2016-December/038400.html
             url_string = url.toDisplayString()
             error_page = jinja.render(
                 'error.html',
                 title="Error loading page: {}".format(url_string),
                 url=url_string, error="Authentication required", icon='')
             self.set_html(error_page)
Beispiel #8
0
 def _on_proxy_authentication_required(self, url, authenticator,
                                       proxy_host):
     """Called when a proxy needs authentication."""
     msg = "<b>{}</b> requires a username and password.".format(
         html_utils.escape(proxy_host))
     urlstr = url.toString(QUrl.RemovePassword | QUrl.FullyEncoded)
     answer = message.ask(
         title="Proxy authentication required", text=msg,
         mode=usertypes.PromptMode.user_pwd,
         abort_on=[self.shutting_down, self.load_started], url=urlstr)
     if answer is not None:
         authenticator.setUser(answer.user)
         authenticator.setPassword(answer.password)
     else:
         try:
             # pylint: disable=no-member, useless-suppression
             sip.assign(authenticator, QAuthenticator())
             # pylint: enable=no-member, useless-suppression
         except AttributeError:
             self._show_error_page(url, "Proxy authentication required")
Beispiel #9
0
 def _on_proxy_authentication_required(self, url, authenticator,
                                       proxy_host):
     """Called when a proxy needs authentication."""
     msg = "<b>{}</b> requires a username and password.".format(
         html_utils.escape(proxy_host))
     urlstr = url.toString(QUrl.RemovePassword | QUrl.FullyEncoded)
     answer = message.ask(
         title="Proxy authentication required", text=msg,
         mode=usertypes.PromptMode.user_pwd,
         abort_on=[self.shutting_down, self.load_started], url=urlstr)
     if answer is not None:
         authenticator.setUser(answer.user)
         authenticator.setPassword(answer.password)
     else:
         try:
             # pylint: disable=no-member, useless-suppression
             sip.assign(authenticator, QAuthenticator())
             # pylint: enable=no-member, useless-suppression
         except AttributeError:
             self._show_error_page(url, "Proxy authentication required")
Beispiel #10
0
 def _on_authentication_required(self, url, authenticator):
     netrc_success = False
     if not self.data.netrc_used:
         self.data.netrc_used = True
         netrc_success = shared.netrc_authentication(url, authenticator)
     if not netrc_success:
         abort_on = [self.shutting_down, self.load_started]
         answer = shared.authentication_required(url, authenticator,
                                                 abort_on)
     if not netrc_success and answer is None:
         try:
             # pylint: disable=no-member, useless-suppression
             sip.assign(authenticator, QAuthenticator())
             # pylint: enable=no-member, useless-suppression
         except AttributeError:
             # WORKAROUND for
             # https://www.riverbankcomputing.com/pipermail/pyqt/2016-December/038400.html
             url_string = url.toDisplayString()
             error_page = jinja.render(
                 'error.html',
                 title="Error loading page: {}".format(url_string),
                 url=url_string,
                 error="Authentication required")
             self.set_html(error_page)
Beispiel #11
0
 def reject(self):
     from PyQt5.QtNetwork import QAuthenticator
     import sip
     sip.assign(auth, QAuthenticator())
     return super().reject()