@@ -45,18 +45,19 @@ class CustomerSuppliedEncryptionKeysSamples {
4545 * @param storage A Storage object, ready for use
4646 * @param bucketName The name of the destination bucket
4747 * @param objectName The name of the destination object
48- * @param base64CSEKey An AES256 key, encoded as a base64 string.
49- * @param base64CSEKeyHash The SHA-256 hash of the above key, also encoded as a base64 string.
50- * @throws IOException if there was some error download from GCS.
48+ * @param base64CseKey An AES256 key, encoded as a base64 string.
49+ * @param base64CseKeyHash The SHA-256 hash of the above key, also encoded as a base64 string.
5150 *
5251 * @return An InputStream that contains the decrypted contents of the object.
52+ *
53+ * @throws IOException if there was some error download from GCS.
5354 */
5455 public static InputStream downloadObject (
5556 Storage storage ,
5657 String bucketName ,
5758 String objectName ,
58- String base64CSEKey ,
59- String base64CSEKeyHash )
59+ String base64CseKey ,
60+ String base64CseKeyHash )
6061 throws Exception {
6162 Storage .Objects .Get getObject = storage .objects ().get (bucketName , objectName );
6263
@@ -66,8 +67,8 @@ public static InputStream downloadObject(
6667 // Now set the CSEK headers
6768 final HttpHeaders httpHeaders = new HttpHeaders ();
6869 httpHeaders .set ("x-goog-encryption-algorithm" , "AES256" );
69- httpHeaders .set ("x-goog-encryption-key" , base64CSEKey );
70- httpHeaders .set ("x-goog-encryption-key-sha256" , base64CSEKeyHash );
70+ httpHeaders .set ("x-goog-encryption-key" , base64CseKey );
71+ httpHeaders .set ("x-goog-encryption-key-sha256" , base64CseKeyHash );
7172
7273 getObject .setRequestHeaders (httpHeaders );
7374
@@ -89,17 +90,17 @@ public static InputStream downloadObject(
8990 * @param bucketName The name of the destination bucket
9091 * @param objectName The name of the destination object
9192 * @param data An InputStream containing the contents of the object to upload
92- * @param base64CSEKey An AES256 key, encoded as a base64 string.
93- * @param base64CSEKeyHash The SHA-256 hash of the above key, also encoded as a base64 string.
93+ * @param base64CseKey An AES256 key, encoded as a base64 string.
94+ * @param base64CseKeyHash The SHA-256 hash of the above key, also encoded as a base64 string.
9495 * @throws IOException if there was some error uploading to GCS.
9596 */
9697 public static void uploadObject (
9798 Storage storage ,
9899 String bucketName ,
99100 String objectName ,
100101 InputStream data ,
101- String base64CSEKey ,
102- String base64CSEKeyHash )
102+ String base64CseKey ,
103+ String base64CseKeyHash )
103104 throws IOException {
104105 InputStreamContent mediaContent = new InputStreamContent ("text/plain" , data );
105106 Storage .Objects .Insert insertObject =
@@ -112,8 +113,8 @@ public static void uploadObject(
112113 // Now set the CSEK headers
113114 final HttpHeaders httpHeaders = new HttpHeaders ();
114115 httpHeaders .set ("x-goog-encryption-algorithm" , "AES256" );
115- httpHeaders .set ("x-goog-encryption-key" , base64CSEKey );
116- httpHeaders .set ("x-goog-encryption-key-sha256" , base64CSEKeyHash );
116+ httpHeaders .set ("x-goog-encryption-key" , base64CseKey );
117+ httpHeaders .set ("x-goog-encryption-key-sha256" , base64CseKeyHash );
117118
118119 insertObject .setRequestHeaders (httpHeaders );
119120
@@ -192,18 +193,18 @@ public static void main(String[] args) throws Exception {
192193 System .exit (1 );
193194 }
194195 String bucketName = args [0 ];
195-
196+
196197 Storage storage = StorageFactory .getService ();
197198 InputStream dataToUpload = new StorageUtils .ArbitrarilyLargeInputStream (10000000 );
198199
199200 System .out .format ("Uploading object gs://%s/%s using CSEK.\n " , bucketName , OBJECT_NAME );
200201 uploadObject (storage , bucketName , OBJECT_NAME , dataToUpload , CSEK_KEY , CSEK_KEY_HASH );
201-
202+
202203 System .out .format ("Downloading object gs://%s/%s using CSEK.\n " , bucketName , OBJECT_NAME );
203204 InputStream objectData =
204205 downloadObject (storage , bucketName , OBJECT_NAME , CSEK_KEY , CSEK_KEY_HASH );
205206 StorageUtils .readStream (objectData );
206-
207+
207208 System .out .println ("Rotating object to use a different CSEK." );
208209 rotateKey (storage , bucketName , OBJECT_NAME , CSEK_KEY , CSEK_KEY_HASH ,
209210 ANOTHER_CESK_KEY , ANOTHER_CSEK_KEY_HASH );
0 commit comments