def requestAvatarId(self, credentials):
        key = Key.fromString(credentials.blob)
        fingerprint = key.fingerprint().replace(':', '')
        self.meta.fingerprint = fingerprint
        if (credentials.username == 'git'):
            # Todo, maybe verify the key with a process protocol call
            # (drush or http)
            def success():
                return credentials.username
            d = defer.maybeDeferred(success)
            d.addCallback(self.verify, credentials, key)
            return d
        else:
            """ If a user specified a non-git username, check that the user's key matches their username

            so that we can request a password if it does not."""
            service = Service(AuthProtocol('drupalorg-ssh-user-key'))
            service.request_bool({"username":credentials.username},
                                 {"fingerprint":fingerprint})
            def auth_callback(result):
                if result:
                    return credentials.username
                else:
                    return Failure(UnauthorizedLogin(credentials.username))
            service.addCallback(auth_callback)
            service.addCallback(self.verify, credentials, key)
            return service.deferred
    def requestAvatarId(self, credentials):
        key = Key.fromString(credentials.blob)
        fingerprint = key.fingerprint().replace(':', '')
        self.meta.fingerprint = fingerprint
        if (credentials.username == 'git'):
            # Todo, maybe verify the key with a process protocol call
            # (drush or http)
            def success():
                return credentials.username

            d = defer.maybeDeferred(success)
            d.addCallback(self.verify, credentials, key)
            return d
        else:
            """ If a user specified a non-git username, check that the user's key matches their username

            so that we can request a password if it does not."""
            service = Service(AuthProtocol('drupalorg-ssh-user-key'))
            service.request_bool({"username": credentials.username},
                                 {"fingerprint": fingerprint})

            def auth_callback(result):
                if result:
                    return credentials.username
                else:
                    return Failure(UnauthorizedLogin(credentials.username))

            service.addCallback(auth_callback)
            service.addCallback(self.verify, credentials, key)
            return service.deferred
 def fetchHash(credentials):
     service = Service(AuthProtocol('drupalorg-vcs-auth-fetch-user-hash'))
     service.request_json({"username":credentials.username})
     def auth_callback(result):
         if result:
             self.meta.password = DrupalHash(result, credentials.password).get_hash()
             return checkAuth(credentials)
     service.addCallback(auth_callback)
     return service.deferred
 def checkAuth(credentials):
     service = Service(AuthProtocol('drupalorg-vcs-auth-check-user-pass'))
     service.request_bool({"username":credentials.username},
                          {"password":self.meta.password})
     def auth_callback(result):
         if result:
             return credentials.username
         else:
             return Failure(UnauthorizedLogin(credentials.username))
     service.addCallback(auth_callback)
     return service.deferred
 def identify(self,credentials):
     passwd = hashlib.md5(credentials.password).hexdigest()
     service = Service(AuthProtocol('drupalorg-vcs-auth-check-user-pass'))
     service.request_bool({"username":credentials.username},
                         {"password":passwd})
     def auth_callback(result):
         if result:
             return credentials.username
         else:
             return Failure(UnauthorizedLogin(credentials.username))
     service.addCallback(auth_callback)
     return service.deferred
    def requestAvatarId(self, credentials):
        self.meta.password = hashlib.md5(credentials.password).hexdigest()
        service = Service(AuthProtocol('drupalorg-vcs-auth-check-user-pass'))
        service.request_bool({"username": credentials.username},
                             {"password": self.meta.password})

        def auth_callback(result):
            if result:
                return credentials.username
            else:
                return Failure(UnauthorizedLogin(credentials.username))

        service.addCallback(auth_callback)
        return service.deferred