Ejemplo n.º 1
0
def get_http_auth_credentials(qurl, authenticator, parent=None):
    qurl = QUrl(qurl)
    qurl.setFragment(None)
    realm = authenticator.realm()
    trealm = (' (%s)' % realm) if realm else ''
    ac = parent and parent.get_login_credentials(qurl.toString())
    d = Credentials(
        _('Please specify a password for {0}{1}').format(
            qurl.toString(), trealm), parent)
    if ac is not None:
        if ac['autologin']:
            authenticator.setUser(ac['username'])
            authenticator.setPassword(ac['password'])
            return
        d.credentials = ac['username'], ac['password']

    if d.exec_() == d.Accepted:
        username, password = d.credentials
        authenticator.setUser(username)
        authenticator.setPassword(password)
        if parent is not None:
            parent.on_login_form_submit(qurl.toString(), username, password)
    else:
        if parent is not None:
            parent.setHtml(
                '<p style="font-family:sans-serif">{} {}</p>'.format(
                    _('Authentication required to access: '),
                    '<a href="{0}">{0}</a>'.format(qurl.toDisplayString())))
Ejemplo n.º 2
0
def get_proxy_auth_credentials(qurl, authenticator, proxy_host, parent=None):
    qurl = QUrl(qurl)
    qurl.setFragment(None)
    d = Credentials(_('Please specify a password for {0} at the proxy: {1}').format(qurl.toString(), proxy_host), parent)
    if d.exec_() == d.Accepted:
        username, password = d.credentials
        authenticator.setUser(username)
        authenticator.setPassword(password)
Ejemplo n.º 3
0
def get_proxy_auth_credentials(qurl, authenticator, proxy_host, parent=None):
    qurl = QUrl(qurl)
    qurl.setFragment(None)
    d = Credentials(
        _('Please specify a password for {0} at the proxy: {1}').format(
            qurl.toString(), proxy_host), parent)
    if d.exec_() == d.Accepted:
        username, password = d.credentials
        authenticator.setUser(username)
        authenticator.setPassword(password)
Ejemplo n.º 4
0
 def current_changed(self, current, previous):
     link = current.data(Qt.UserRole)
     if link is None:
         return
     url = None
     if link.is_external:
         if link.href:
             frag = ('#' + link.anchor.id) if link.anchor.id else ''
             url = QUrl(link.href + frag)
     elif link.anchor.location:
         path = current_container().name_to_abspath(link.anchor.location.name)
         if path and os.path.exists(path):
             url = QUrl.fromLocalFile(path)
             if link.anchor.id:
                 url.setFragment(link.anchor.id)
     if url is None:
         self.view.setHtml('<p>' + _('No destination found for this link'))
         self.current_url = url
     elif url != self.current_url:
         self.current_url = url
         self.view.setUrl(url)
Ejemplo n.º 5
0
 def current_changed(self, current, previous):
     link = current.data(Qt.UserRole)
     if link is None:
         return
     url = None
     if link.is_external:
         if link.href:
             frag = ('#' + link.anchor.id) if link.anchor.id else ''
             url = QUrl(link.href + frag)
     elif link.anchor.location:
         path = current_container().name_to_abspath(link.anchor.location.name)
         if path and os.path.exists(path):
             url = QUrl.fromLocalFile(path)
             if link.anchor.id:
                 url.setFragment(link.anchor.id)
     if url is None:
         self.view.setHtml('<p>' + _('No destination found for this link'))
         self.current_url = url
     elif url != self.current_url:
         self.current_url = url
         self.view.setUrl(url)
Ejemplo n.º 6
0
def get_http_auth_credentials(qurl, authenticator, parent=None):
    qurl = QUrl(qurl)
    qurl.setFragment(None)
    realm = authenticator.realm()
    trealm = (' (%s)' % realm) if realm else ''
    ac = parent and parent.get_login_credentials(qurl.toString())
    d = Credentials(_('Please specify a password for {0}{1}').format(qurl.toString(), trealm), parent)
    if ac is not None:
        if ac['autologin']:
            authenticator.setUser(ac['username'])
            authenticator.setPassword(ac['password'])
            return
        d.credentials = ac['username'], ac['password']

    if d.exec_() == d.Accepted:
        username, password = d.credentials
        authenticator.setUser(username)
        authenticator.setPassword(password)
        if parent is not None:
            parent.on_login_form_submit(qurl.toString(), username, password)
    else:
        if parent is not None:
            parent.setHtml('<p style="font-family:sans-serif">{} {}</p>'.format(
                _('Authentication required to access: '), '<a href="{0}">{0}</a>'.format(qurl.toDisplayString())))