@@ -1303,37 +1303,37 @@ public void testSignUrlWithOptions() throws NoSuchAlgorithmException, InvalidKey
1303
1303
1304
1304
@ Test
1305
1305
public void testSignUrlForBlobWithSpecialChars () throws NoSuchAlgorithmException ,
1306
- InvalidKeyException , SignatureException , UnsupportedEncodingException {
1306
+ InvalidKeyException , SignatureException , UnsupportedEncodingException {
1307
1307
// List of chars under test were taken from
1308
1308
// https://en.wikipedia.org/wiki/Percent-encoding#Percent-encoding_reserved_characters
1309
1309
char [] specialChars =
1310
1310
new char []{'!' ,'#' ,'$' ,'&' ,'\'' ,'(' ,')' ,'*' ,'+' ,',' ,':' ,';' ,'=' ,'?' ,'@' ,'[' ,']' };
1311
1311
EasyMock .replay (storageRpcMock );
1312
1312
ServiceAccountAuthCredentials authCredentials =
1313
- ServiceAccountAuthCredentials .createFor (ACCOUNT , privateKey );
1313
+ ServiceAccountAuthCredentials .createFor (ACCOUNT , privateKey );
1314
1314
storage = options .toBuilder ().authCredentials (authCredentials ).build ().service ();
1315
1315
1316
1316
for (char specialChar : specialChars ) {
1317
1317
String blobName = "/a" + specialChar + "b" ;
1318
1318
URL url =
1319
- storage .signUrl (BlobInfo .builder (BUCKET_NAME1 , blobName ).build (), 14 , TimeUnit .DAYS );
1319
+ storage .signUrl (BlobInfo .builder (BUCKET_NAME1 , blobName ).build (), 14 , TimeUnit .DAYS );
1320
1320
String escapedBlobName = UrlEscapers .urlPathSegmentEscaper ().escape (blobName );
1321
1321
String stringUrl = url .toString ();
1322
1322
String expectedUrl = new StringBuilder ("https://storage.googleapis.com/" ).append (BUCKET_NAME1 )
1323
- .append (escapedBlobName ).append ("?GoogleAccessId=" ).append (ACCOUNT ).append ("&Expires=" )
1324
- .append (42L + 1209600 ).append ("&Signature=" ).toString ();
1323
+ .append (escapedBlobName ).append ("?GoogleAccessId=" ).append (ACCOUNT ).append ("&Expires=" )
1324
+ .append (42L + 1209600 ).append ("&Signature=" ).toString ();
1325
1325
assertTrue (stringUrl .startsWith (expectedUrl ));
1326
1326
String signature = stringUrl .substring (expectedUrl .length ());
1327
1327
1328
1328
StringBuilder signedMessageBuilder = new StringBuilder ();
1329
1329
signedMessageBuilder .append (HttpMethod .GET ).append ("\n \n \n " ).append (42L + 1209600 )
1330
- .append ("\n /" ).append (BUCKET_NAME1 ).append (escapedBlobName );
1330
+ .append ("\n /" ).append (BUCKET_NAME1 ).append (escapedBlobName );
1331
1331
1332
1332
Signature signer = Signature .getInstance ("SHA256withRSA" );
1333
1333
signer .initVerify (publicKey );
1334
1334
signer .update (signedMessageBuilder .toString ().getBytes (UTF_8 ));
1335
1335
assertTrue (signer .verify (BaseEncoding .base64 ().decode (
1336
- URLDecoder .decode (signature , UTF_8 .name ()))));
1336
+ URLDecoder .decode (signature , UTF_8 .name ()))));
1337
1337
}
1338
1338
}
1339
1339
0 commit comments