<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def set_bucket_policy(self, bucket_name, policy):
 """ Set bucket policy of given bucket name. :param bucket_name: Bucket name. :param policy: Access policy/ies in string format. """

        is_valid_policy_type(policy)

        is_valid_bucket_name(bucket_name)

        headers = {
            'Content-Length': str(len(policy)),
            'Content-Md5': get_md5_base64digest(policy)
        }
        content_sha256_hex = get_sha256_hexdigest(policy)
        self._url_open("PUT",
                        bucket_name=bucket_name,
                        query={"policy": ""},
                        headers=headers,
                        body=policy,
                        content_sha256=content_sha256_hex)