/**
  * Returns a JSONObject representation of the instruction object.
  *
  * @deprecated no longer used and will be removed in the future
  */
 @Deprecated
 private static JSONObject convertInstructionToJSONObject(EncryptionInstruction instruction) {
   JSONObject instructionJSON = new JSONObject();
   try {
     JSONObject materialsDescriptionJSON = new JSONObject(instruction.getMaterialsDescription());
     instructionJSON.put(Headers.MATERIALS_DESCRIPTION, materialsDescriptionJSON.toString());
     instructionJSON.put(
         Headers.CRYPTO_KEY, Base64.encodeAsString(instruction.getEncryptedSymmetricKey()));
     byte[] iv = instruction.getSymmetricCipher().getIV();
     instructionJSON.put(Headers.CRYPTO_IV, Base64.encodeAsString(iv));
   } catch (JSONException e) {
   } // Keys are never null, so JSONException will never be thrown.
   return instructionJSON;
 }
  /**
   * Update the request's ObjectMetadata with the necessary information for decrypting the object
   *
   * @param request Non-null PUT request encrypted using the given instruction
   * @param instruction Non-null instruction used to encrypt the data in this PUT request.
   * @deprecated no longer used and will be removed in the future
   */
  @Deprecated
  public static void updateMetadataWithEncryptionInstruction(
      PutObjectRequest request, EncryptionInstruction instruction) {
    byte[] keyBytesToStoreInMetadata = instruction.getEncryptedSymmetricKey();
    Cipher symmetricCipher = instruction.getSymmetricCipher();
    Map<String, String> materialsDescription = instruction.getMaterialsDescription();

    ObjectMetadata metadata = request.getMetadata();
    if (metadata == null) metadata = new ObjectMetadata();

    if (request.getFile() != null) {
      Mimetypes mimetypes = Mimetypes.getInstance();
      metadata.setContentType(mimetypes.getMimetype(request.getFile()));
    }

    updateMetadata(metadata, keyBytesToStoreInMetadata, symmetricCipher, materialsDescription);
    request.setMetadata(metadata);
  }