Example #1
0
    def _authenticate(self):
        """Authenticate with the remote Bugzilla instance.

        Authentication works by means of using a LoginToken of type
        BUGTRACKER. We send the token text to the remote server as a
        parameter to Launchpad.login(), which verifies it using the
        standard launchpad.net/token/$token/+bugtracker-handshake URL.

        If the token is valid, Bugzilla will send us a user ID as a
        return value for the call to Launchpad.login() and will set two
        cookies in the response header, Bugzilla_login and
        Bugzilla_logincookie, which we can then use to re-authenticate
        ourselves for each subsequent method call.
        """
        internal_xmlrpc_server = xmlrpclib.ServerProxy(
            config.checkwatches.xmlrpc_url,
            transport=self.internal_xmlrpc_transport)

        token_text = internal_xmlrpc_server.newBugTrackerToken()

        try:
            self.xmlrpc_proxy.Launchpad.login({'token': token_text})
        except xmlrpclib.Fault as fault:
            message = 'XML-RPC Fault: %s "%s"' % (fault.faultCode,
                                                  fault.faultString)
            raise BugTrackerAuthenticationError(self.baseurl, message)
        except xmlrpclib.ProtocolError as error:
            message = 'Protocol error: %s "%s"' % (error.errcode, error.errmsg)
            raise BugTrackerAuthenticationError(self.baseurl, message)
Example #2
0
    def _authenticate(self):
        """Authenticate with the Trac instance."""
        token_text = self._generateAuthenticationToken()
        base_auth_url = urlappend(self.baseurl, 'launchpad-auth')
        auth_url = urlappend(base_auth_url, token_text)

        try:
            self._getPage(auth_url)
        except BugTrackerConnectError as e:
            raise BugTrackerAuthenticationError(self.baseurl, e.error)
Example #3
0
    def _authenticate(self):
        """Authenticate with the remote Bugzilla instance.

        The native Bugzilla API uses a standard (username, password)
        paradigm for authentication. If the username and password are
        correct, Bugzilla will send back a login cookie which we can use
        to re-authenticate with each subsequent method call.
        """
        try:
            self.xmlrpc_proxy.User.login(self.credentials)
        except xmlrpclib.Fault as fault:
            raise BugTrackerAuthenticationError(
                self.baseurl,
                "Fault %s: %s" % (fault.faultCode, fault.faultString))
Example #4
0
    def credentials(self):
        credentials_config = config['checkwatches.credentials']

        # Extract the hostname from the current base url using urlparse.
        hostname = urlparse(self.baseurl)[1]
        try:
            # XXX gmb 2009-08-19 bug=391131
            #     We shouldn't be using this here. Ideally we'd be able
            #     to get the credentials from the BugTracker object.
            #     If you find yourself adding credentials for, for
            #     example, www.password.username.pirateninjah4x0rz.org,
            #     think about fixing the above bug instead.
            username = credentials_config['%s.username' % hostname]
            password = credentials_config['%s.password' % hostname]
            return {'login': username, 'password': password}
        except KeyError:
            raise BugTrackerAuthenticationError(self.baseurl,
                                                "No credentials found.")