Ejemplo n.º 1
0
    def find_user_password(self, realm, authuri):
        authinfo = urllib2.HTTPPasswordMgrWithDefaultRealm.find_user_password(
            self, realm, authuri)
        user, passwd = authinfo
        if user and passwd:
            self._writedebug(user, passwd)
            return (user, passwd)

        if not user or not passwd:
            res = httpconnectionmod.readauthforuri(self.ui, authuri, user)
            if res:
                group, auth = res
                user, passwd = auth.get('username'), auth.get('password')
                self.ui.debug("using auth.%s.* for authentication\n" % group)
        if not user or not passwd:
            if not self.ui.interactive():
                raise util.Abort(_('http authorization required'))

            self.ui.write(_("http authorization required\n"))
            self.ui.write(_("realm: %s\n") % realm)
            if user:
                self.ui.write(_("user: %s\n") % user)
            else:
                user = self.ui.prompt(_("user:"), default=None)

            if not passwd:
                passwd = self.ui.getpass()

        self.add_password(realm, authuri, user, passwd)
        self._writedebug(user, passwd)
        return (user, passwd)
Ejemplo n.º 2
0
    def find_user_password(self, realm, authuri):
        authinfo = urllib2.HTTPPasswordMgrWithDefaultRealm.find_user_password(
            self, realm, authuri)
        user, passwd = authinfo
        if user and passwd:
            self._writedebug(user, passwd)
            return (user, passwd)

        if not user or not passwd:
            res = httpconnectionmod.readauthforuri(self.ui, authuri, user)
            if res:
                group, auth = res
                user, passwd = auth.get('username'), auth.get('password')
                self.ui.debug("using auth.%s.* for authentication\n" % group)
        if not user or not passwd:
            if not self.ui.interactive():
                raise util.Abort(_('http authorization required'))

            self.ui.write(_("http authorization required\n"))
            self.ui.write(_("realm: %s\n") % realm)
            if user:
                self.ui.write(_("user: %s\n") % user)
            else:
                user = self.ui.prompt(_("user:"), default=None)

            if not passwd:
                passwd = self.ui.getpass()

        self.add_password(realm, authuri, user, passwd)
        self._writedebug(user, passwd)
        return (user, passwd)
Ejemplo n.º 3
0
 def https_open(self, req):
     res = httpconnectionmod.readauthforuri(self.ui, req.get_full_url())
     if res:
         group, auth = res
         self.auth = auth
         self.ui.debug("using auth.%s.* for authentication\n" % group)
     else:
         self.auth = None
     return self.do_open(self._makeconnection, req)
Ejemplo n.º 4
0
 def https_open(self, req):
     # req.get_full_url() does not contain credentials and we may
     # need them to match the certificates.
     url = req.get_full_url()
     user, password = self.pwmgr.find_stored_password(url)
     res = httpconnectionmod.readauthforuri(self.ui, url, user)
     if res:
         group, auth = res
         self.auth = auth
         self.ui.debug("using auth.%s.* for authentication\n" % group)
     else:
         self.auth = None
     return self.do_open(self._makeconnection, req)
Ejemplo n.º 5
0
 def https_open(self, req):
     # req.get_full_url() does not contain credentials and we may
     # need them to match the certificates.
     url = req.get_full_url()
     user, password = self.pwmgr.find_stored_password(url)
     res = httpconnectionmod.readauthforuri(self.ui, url, user)
     if res:
         group, auth = res
         self.auth = auth
         self.ui.debug("using auth.%s.* for authentication\n" % group)
     else:
         self.auth = None
     return self.do_open(self._makeconnection, req)