Adds bucket encryption configuration.
436675
def _put_bucket_encryption(self):
        """"""
        if self.s3props['encryption']['enabled']:
            encryption_config = {'Rules': [{}]}
            encryption_config = {
                'Rules': self.s3props['encryption']['encryption_rules']
            }
            LOG.debug(encryption_config)
            _response = self.s3client.put_bucket_encryption(Bucket=self.bucket,
                                                            ServerSideEncryptionConfiguration=encryption_config)
        else:
            _response = self.s3client.delete_bucket_encryption(Bucket=self.bucket)
        LOG.debug('Response setting up S3 encryption: %s', _response)
        LOG.info('S3 encryption configuration updated')
78196
public BucketNotificationConfiguration withNotificationConfiguration(
            Map<String, NotificationConfiguration> notificationConfiguration) {
        configurations.clear();
        configurations.putAll(notificationConfiguration);
        return this;
    }
573061
def encrypt_file(src, dest, csv_keys):
    """"""
    keys = massage_keys(csv_keys.split(','))
    cryptorito.encrypt(src, dest, keys)
231017
private void putObject(String bucketName, String objectName, Long size, Object data,
      Map<String, String> headerMap, ServerSideEncryption sse)
    throws InvalidBucketNameException, NoSuchAlgorithmException, IOException,
           InvalidKeyException, NoResponseException, XmlPullParserException, ErrorResponseException,
           InternalException,
           InvalidArgumentException, InsufficientDataException {
    boolean unknownSize = false;

    // Add content type if not already set
    if (headerMap.get("Content-Type") == null) {
      headerMap.put("Content-Type", "application/octet-stream");
    }

    if (size == null) {
      unknownSize = true;
      size = MAX_OBJECT_SIZE;
    }

    if (size <= MIN_MULTIPART_SIZE) {
      // Single put object.
      if (sse != null) {
        sse.marshal(headerMap);
      }
      putObject(bucketName, objectName, size.intValue(), data, null, 0, headerMap);
      return;
    }

    /* Multipart upload */
    int[] rv = calculateMultipartSize(size);
    int partSize = rv[0];
    int partCount = rv[1];
    int lastPartSize = rv[2];
    Part[] totalParts = new Part[partCount];

    // if sse is requested set the necessary headers before we begin the multipart session.
    if (sse != null) {
      sse.marshal(headerMap);
    }

    // initiate new multipart upload.
    String uploadId = initMultipartUpload(bucketName, objectName, headerMap);

    try {
      int expectedReadSize = partSize;
      for (int partNumber = 1; partNumber <= partCount; partNumber++) {
        if (partNumber == partCount) {
          expectedReadSize = lastPartSize;
        }

        // For unknown sized stream, check available size.
        int availableSize = 0;
        if (unknownSize) {
          // Check whether data is available one byte more than expectedReadSize.
          availableSize = getAvailableSize(data, expectedReadSize + 1);
          // If availableSize is less or equal to expectedReadSize, then we reached last part.
          if (availableSize <= expectedReadSize) {
            // If it is first part, do single put object.
            if (partNumber == 1) {
              putObject(bucketName, objectName, availableSize, data, null, 0, headerMap);
              return;
            }
            expectedReadSize = availableSize;
            partCount = partNumber;
          }
        }

        // In multi-part uploads, Set encryption headers in the case of SSE-C.
        Map<String, String> encryptionHeaders = new HashMap<>();
        if (sse != null && sse.getType() == ServerSideEncryption.Type.SSE_C) {
          sse.marshal(encryptionHeaders);
        }

        String etag = putObject(bucketName, objectName, expectedReadSize, data,
                                uploadId, partNumber, encryptionHeaders);
        totalParts[partNumber - 1] = new Part(partNumber, etag);
      }
      // All parts have been uploaded, complete the multipart upload.
      completeMultipart(bucketName, objectName, uploadId, totalParts);
    } catch (RuntimeException e) {
      throw e;
    } catch (Exception e) {
      abortMultipartUpload(bucketName, objectName, uploadId);
      throw e;
    }
  }
991539
def _add_secret_hash(self, parameters, key):
        
        if self.client_secret is not None:
            secret_hash = AWSSRP.get_secret_hash(self.username, self.client_id,
                                                 self.client_secret)
            parameters[key] = secret_hash
59482
public void setBucket(Bucket<Data> bucket) throws BucketContainerException, InterruptedException {
        buckets[bucket.getBucketId()] = bucket;
    }
588159
public void configToLogInfo() {
        logger.info("----- MEMEORY USAGE -----");
        logger.info("BUCKET_MEMORY = {}", BUCKET_MEMORY);
        logger.info("MEMORY_CHUNK = {}", MEMORY_CHUNK);
        logger.info("MAX_MEMORY_PER_BUCKET = {}", MAX_MEMORY_PER_BUCKET);
        logger.info("CHUNKSIZE = {}", SYNC_CHUNK_SIZE);

        logger.info("----- HeaderIndexFile -----");
        logger.info("INITIAL_FILE_SIZE = {}", INITIAL_FILE_SIZE);
        logger.info("INITIAL_INCREMENT_SIZE = {}", INITIAL_INCREMENT_SIZE);
        logger.info("CHUNK_SIZE = {}", FILE_CHUNK_SIZE);
    }
396714
def ensure_cfn_bucket(self):
        """"""
        if self.bucket_name:
            ensure_s3_bucket(self.s3_conn,
                             self.bucket_name,
                             self.bucket_region)
1059219
def optional_actions(encrypt, path, compress_file, **kwargs):
    '''
    
    '''
    yes = ('y', 'Y')
    file_to_upload = normalize_path(path) + compress_file[1]
    if encrypt in yes:
        encrypt_file(compress_file[1], compress_file[0])
        file_to_upload = compress_file[0]

    if kwargs.get('s3') in yes:
        factory_uploader('S3', name_backup=file_to_upload,
                         bucket_name=AWS_BUCKET_NAME, action='upload')

    if kwargs.get('glacier') in yes:
        factory_uploader('Glacier', name_backup=file_to_upload,
                         vault_name=AWS_VAULT_NAME,
                         path=os.path.join(os.path.expanduser('~'),
                                           '.zoort.db'),
                         action='upload')
    if kwargs.get('dropbox') in yes:
        factory_uploader('Dropbox', name_backup=file_to_upload,
                         action='upload')
    if kwargs.get('swift') in yes:
        factory_uploader('Swift', name_backup=file_to_upload,
                         action='upload')
1109788
public <T> void setRiakBucketName(T obj, BinaryValue bucketName)
    {
        if (riakBucketNameSetter != null)
        {
            if (riakBucketNameSetter.getParameterTypes()[0].isArray())
            {
                setMethodValue(riakBucketNameSetter, obj, bucketName.unsafeGetValue());
            }
            else
            {
                setMethodValue(riakBucketNameSetter, obj, bucketName.toString());
            }
        }
        else if (riakBucketNameField != null)
        {
            if (riakBucketNameField.getType().equals(String.class))
            {
                setFieldValue(riakBucketNameField, obj, bucketName.toString());
            }
            else
            {
                setFieldValue(riakBucketNameField, obj, bucketName.unsafeGetValue());
            }
        }
    }
152921
@Override
  public void addEncryptionMetadata(StorageObjectMetadata meta,
                                    MatDesc matDesc,
                                    byte[] ivData,
                                    byte[] encKeK,
                                    long contentLength)
  {
    meta.addUserMetadata(getMatdescKey(),
                         matDesc.toString());
    meta.addUserMetadata(AMZ_KEY,
                         Base64.encodeAsString(encKeK));
    meta.addUserMetadata(AMZ_IV,
                         Base64.encodeAsString(ivData));
    meta.setContentLength(contentLength);
  }
905317
private function ensureBucketExists()
    {
        if ($this->ensureBucket) {
            return;
        }

        if (isset($this->options['region'])) {
            $this->service->set_region($this->options['region']);
        }

        if ($this->service->if_bucket_exists($this->bucket)) {
            $this->ensureBucket = true;

            return;
        }

        if (!$this->options['create']) {
            throw new \RuntimeException(sprintf(
                'The configured bucket "%s" does not exist.',
                $this->bucket
            ));
        }

        $response = $this->service->create_bucket(
            $this->bucket,
            $this->options['region']
        );

        if (!$response->isOK()) {
            throw new \RuntimeException(sprintf(
                'Failed to create the configured bucket "%s".',
                $this->bucket
            ));
        }

        $this->ensureBucket = true;
    }
17793
def ensure_crypto_config(partition):
    

    if 'crypto-configuration' not in partition.properties or \
            partition.properties['crypto-configuration'] is None:
        partition.properties['crypto-configuration'] = {}
    crypto_config = partition.properties['crypto-configuration']

    if 'crypto-adapter-uris' not in crypto_config or \
            crypto_config['crypto-adapter-uris'] is None:
        crypto_config['crypto-adapter-uris'] = []
    adapter_uris = crypto_config['crypto-adapter-uris']

    if 'crypto-domain-configurations' not in crypto_config or \
            crypto_config['crypto-domain-configurations'] is None:
        crypto_config['crypto-domain-configurations'] = []
    domain_configs = crypto_config['crypto-domain-configurations']

    return adapter_uris, domain_configs
730923
def extend_settings(self, data_id, files, secrets):
        """"""
        process = Data.objects.get(pk=data_id).process
        if process.requirements.get('resources', {}).get('secrets', False):
            raise PermissionDenied(
                "Process which requires access to secrets cannot be run using the local executor"
            )

        return super().extend_settings(data_id, files, secrets)
1002622
async def set_bucket(self, *,
                         chat: typing.Union[str, int, None] = None,
                         user: typing.Union[str, int, None] = None,
                         bucket: typing.Dict = None):
        
        raise NotImplementedError
978061
private void upsertBucketConfig(final BucketConfig newConfig) {
        ClusterConfig cluster = currentConfig;
        BucketConfig oldConfig = cluster.bucketConfig(newConfig.name());

        if (newConfig.rev() > 0 && oldConfig != null && newConfig.rev() <= oldConfig.rev()) {
            LOGGER.trace("Not applying new configuration, older or same rev ID.");
            return;
        }

        // If the current password of the config is empty and an old config exists
        // make sure to transfer the password over to the new config. Otherwise it
        // is possible that authentication errors because of a null password arise.
        // See JVMCBC-185
        if (newConfig.password() == null && oldConfig != null) {
            newConfig.password(oldConfig.password());
        }

        //copy the username as well
        if (oldConfig != null) {
            newConfig.username(oldConfig.username());
        }

        // this is the first config, decide on external networking
        if (oldConfig == null) {
            externalNetwork = determineNetworkResolution(newConfig, environment.networkResolution(), seedHosts);
            LOGGER.info("Selected network configuration: {}", externalNetwork != null ? externalNetwork : "default");
        }

        if (externalNetwork != null) {
            newConfig.useAlternateNetwork(externalNetwork);
        }

        cluster.setBucketConfig(newConfig.name(), newConfig);
        LOGGER.debug("Applying new configuration {}", newConfig);

        currentConfig = cluster;

        boolean tainted = newConfig.tainted();
        for (Refresher refresher : refreshers.values()) {
            if (tainted) {
                refresher.markTainted(newConfig);
            } else {
                refresher.markUntainted(newConfig);
            }
        }

        configObservable.onNext(currentConfig);
    }
302811
def add_config():
    

    genius_key = input('Enter Genius key : ')
    bing_key = input('Enter Bing key : ')

    CONFIG['keys']['bing_key'] = bing_key
    CONFIG['keys']['genius_key'] = genius_key

    with open(config_path, 'w') as configfile:
        CONFIG.write(configfile)