def get_counter(self, bucket, key, **options):
        if not bucket.bucket_type.is_default():
            raise NotImplementedError("Counters are not " "supported with bucket-types, " "use datatypes instead.")

        if not self.counters():
            raise NotImplementedError("Counters are not " "supported on %s" % self.server_version.vstring)

        url = self.counters_path(bucket.name, key, **options)
        status, headers, body = self._request("GET", url)

        self.check_http_code(status, [200, 404])
        if status == 200:
            return str_to_long(body.strip())
        elif status == 404:
            return None
Ejemplo n.º 2
0
    def _check_revoked_cert(self, ssl_socket):
        """
        Checks whether the server certificate on the passed socket has been
        revoked by checking the CRL.

        :param ssl_socket: the SSL/TLS socket
        :rtype: bool
        :raises SecurityError: when the certificate has been revoked
        """
        if not self._has_credential('crl'):
            return True

        servcert = ssl_socket.get_peer_certificate()
        servserial = servcert.get_serial_number()
        for rev in self.crl.get_revoked():
            if servserial == str_to_long(rev.get_serial(), 16):
                raise SecurityError("Server certificate has been revoked")
Ejemplo n.º 3
0
        def _check_revoked_cert(self, ssl_socket):
            """
            Checks whether the server certificate on the passed socket has been
            revoked by checking the CRL.

            :param ssl_socket: the SSL/TLS socket
            :rtype: bool
            :raises SecurityError: when the certificate has been revoked
            """
            if not self._has_credential('crl'):
                return True

            servcert = ssl_socket.get_peer_certificate()
            servserial = servcert.get_serial_number()
            for rev in self.crl.get_revoked():
                if servserial == str_to_long(rev.get_serial(), 16):
                    raise SecurityError("Server certificate has been revoked")
    def update_counter(self, bucket, key, amount, **options):
        if not bucket.bucket_type.is_default():
            raise NotImplementedError("Counters are not " "supported with bucket-types, " "use datatypes instead.")

        if not self.counters():
            raise NotImplementedError("Counters are not " "supported on %s" % self.server_version.vstring)

        return_value = "returnvalue" in options and options["returnvalue"]
        headers = {"Content-Type": "text/plain"}
        url = self.counters_path(bucket.name, key, **options)
        status, headers, body = self._request("POST", url, headers, str(amount))
        if return_value and status == 200:
            return str_to_long(body.strip())
        elif status == 204:
            return True
        else:
            self.check_http_code(status, [200, 204])
    def get_counter(self, bucket, key, **options):
        if not bucket.bucket_type.is_default():
            raise NotImplementedError("Counters are not "
                                      "supported with bucket-types, "
                                      "use datatypes instead.")

        if not self.counters():
            raise NotImplementedError("Counters are not "
                                      "supported on %s" %
                                      self.server_version.vstring)

        url = self.counters_path(bucket.name, key, **options)
        status, headers, body = self._request('GET', url)

        self.check_http_code(status, [200, 404])
        if status == 200:
            return str_to_long(body.strip())
        elif status == 404:
            return None
    def update_counter(self, bucket, key, amount, **options):
        if not bucket.bucket_type.is_default():
            raise NotImplementedError("Counters are not "
                                      "supported with bucket-types, "
                                      "use datatypes instead.")

        if not self.counters():
            raise NotImplementedError("Counters are not "
                                      "supported on %s" %
                                      self.server_version.vstring)

        return_value = 'returnvalue' in options and options['returnvalue']
        headers = {'Content-Type': 'text/plain'}
        url = self.counters_path(bucket.name, key, **options)
        status, headers, body = self._request('POST', url, headers,
                                              str(amount))
        if return_value and status == 200:
            return str_to_long(body.strip())
        elif status == 204:
            return True
        else:
            self.check_http_code(status, [200, 204])