Skip to content
This repository was archived by the owner on Jul 19, 2024. It is now read-only.

Commit 46a61b1

Browse files
authored
Merge pull request #513 from Azure/legacy-dev
Legacy dev
2 parents c07aeb2 + 66eec3a commit 46a61b1

File tree

11 files changed

+289
-24
lines changed

11 files changed

+289
-24
lines changed

ChangeLog.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
2019.12.02 Version 8.5.0
2+
* Support for HTTP proxy with Basic auth.
3+
* Support for HTTP proxy with Digest auth.
4+
* Added an option to SharedAccessHeaders that will allow the customer to preserve the raw value set on the object. Headers could previously be changed by an internal url decode that might modified the desired value.
5+
16
2019.08.05 Version 8.4.0
27
* Support for 2019-02-02 REST version. Please see our REST API documentation and blogs for information about the related added features.
38
* Added support for setting rehydrate priority for SetBlobTier and CopyBlob APIs.

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ To get the binaries of this library as distributed by Microsoft, ready for use w
3939
<dependency>
4040
<groupId>com.microsoft.azure</groupId>
4141
<artifactId>azure-storage</artifactId>
42-
<version>8.4.0</version>
42+
<version>8.5.0</version>
4343
</dependency>
4444
```
4545

@@ -101,7 +101,9 @@ public class BlobSample {
101101
// Upload an image file.
102102
CloudBlockBlob blob = container.getBlockBlobReference("image1.jpg");
103103
File sourceFile = new File("c:\\myimages\\image1.jpg");
104-
blob.upload(new FileInputStream(sourceFile), sourceFile.length());
104+
try (FileInputStream sourceStream = new FileInputStream(sourceFile)) {
105+
blob.upload(sourceStream, sourceFile.length());
106+
}
105107

106108
// Download the image file.
107109
File destinationFile = new File(sourceFile.getParentFile(), "image1Download.tmp");

microsoft-azure-storage-samples/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
<dependency>
2727
<groupId>com.microsoft.azure</groupId>
2828
<artifactId>azure-storage</artifactId>
29-
<version>8.4.0</version>
29+
<version>8.5.0</version>
3030
</dependency>
3131
<dependency>
3232
<groupId>com.microsoft.azure</groupId>

microsoft-azure-storage-samples/src/com/microsoft/azure/storage/logging/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
<dependency>
2727
<groupId>com.microsoft.azure</groupId>
2828
<artifactId>azure-storage</artifactId>
29-
<version>8.4.0</version>
29+
<version>8.5.0</version>
3030
</dependency>
3131
<dependency>
3232
<groupId>com.microsoft.azure</groupId>

microsoft-azure-storage-test/src/com/microsoft/azure/storage/blob/SasTests.java

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -459,6 +459,47 @@ public void eventOccurred(SendingRequestEvent eventArg) {
459459
sasBlob.download(new ByteArrayOutputStream(), null, null, context);
460460
}
461461

462+
@Test
463+
@Category(SlowTests.class)
464+
public void testBlobSaSWithSharedAccessBlobHeadersPreserveRaw() throws InvalidKeyException,
465+
IllegalArgumentException, StorageException, URISyntaxException, InterruptedException {
466+
SharedAccessBlobPolicy sp = createSharedAccessPolicy(EnumSet.of(SharedAccessBlobPermissions.READ,
467+
SharedAccessBlobPermissions.WRITE, SharedAccessBlobPermissions.LIST), 300);
468+
BlobContainerPermissions perms = new BlobContainerPermissions();
469+
470+
perms.getSharedAccessPolicies().put("readperm", sp);
471+
this.container.uploadPermissions(perms);
472+
Thread.sleep(30000);
473+
474+
SharedAccessBlobHeaders headers = new SharedAccessBlobHeaders(true);
475+
headers.setCacheControl("no%20cache");
476+
headers.setContentDisposition("inline; filename=\"My Image.jpg\"; filename*=UTF-8''My%20Image.jpg");
477+
headers.setContentEncoding("gzip%20");
478+
headers.setContentLanguage("da%20");
479+
headers.setContentType("text/html; charset=utf%208");
480+
481+
CloudBlockBlob sasBlob = new CloudBlockBlob(new URI(this.blob.getUri().toString() + "?"
482+
+ this.blob.generateSharedAccessSignature(null, headers, "readperm")));
483+
OperationContext context = new OperationContext();
484+
485+
context.getSendingRequestEventHandler().addListener(new StorageEvent<SendingRequestEvent>() {
486+
487+
@Override
488+
public void eventOccurred(SendingRequestEvent eventArg) {
489+
HttpURLConnection connection = (HttpURLConnection) eventArg.getConnectionObject();
490+
assertEquals("no%20cache", connection.getHeaderField(Constants.HeaderConstants.CACHE_CONTROL));
491+
assertEquals("inline; filename=\"My Image.jpg\"; filename*=UTF-8''My%20Image.jpg",
492+
connection.getHeaderField(Constants.HeaderConstants.CONTENT_DISPOSITION));
493+
assertEquals("gzip%20", connection.getHeaderField(Constants.HeaderConstants.CONTENT_ENCODING));
494+
assertEquals("da%20", connection.getHeaderField(Constants.HeaderConstants.CONTENT_LANGUAGE));
495+
assertEquals("text/html; charset=utf%208",
496+
connection.getHeaderField(Constants.HeaderConstants.CONTENT_TYPE));
497+
}
498+
});
499+
500+
sasBlob.download(new ByteArrayOutputStream(), null, null, context);
501+
}
502+
462503
@Test
463504
public void testAppendBlobCopyWithSasAndSnapshot()
464505
throws URISyntaxException, StorageException, InterruptedException, IOException, InvalidKeyException {

microsoft-azure-storage/src/com/microsoft/azure/storage/Constants.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -765,7 +765,7 @@ public static class HeaderConstants {
765765
/**
766766
* Specifies the value to use for UserAgent header.
767767
*/
768-
public static final String USER_AGENT_VERSION = "8.4.0";
768+
public static final String USER_AGENT_VERSION = "8.5.0";
769769

770770
/**
771771
* The default type for content-type and accept

microsoft-azure-storage/src/com/microsoft/azure/storage/OperationContext.java

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,31 @@ public final class OperationContext {
4545
*/
4646
private static Proxy proxyDefault;
4747

48+
/**
49+
* Represents a username to be used by default for a proxy when making a request.
50+
*/
51+
private static String proxyDefaultUsername = null;
52+
53+
/**
54+
* Represents a password to be used by default for a proxy when making a request.
55+
*/
56+
private static String proxyDefaultPassword = null;
57+
4858
/**
4959
* Represents a proxy to be used when making a request.
5060
*/
5161
private Proxy proxy;
5262

63+
/**
64+
* Represents a username for a proxy when making a request.
65+
*/
66+
private String proxyUsername = null;
67+
68+
/**
69+
* Represents a password for a proxy when making a request.
70+
*/
71+
private String proxyPassword = null;
72+
5373
/**
5474
* Represents the operation latency, in milliseconds, from the client's perspective. This may include any potential
5575
* retries.
@@ -241,6 +261,26 @@ public Proxy getProxy() {
241261
return this.proxy;
242262
}
243263

264+
/**
265+
* Gets a username for the authenticated proxy which will be used when making a request.
266+
* Default is <code>null</code>. To set a username use {@link #setProxyUsername(String)}
267+
*
268+
* @return A {@link String} to use when making a request.
269+
*/
270+
public String getProxyUsername() {
271+
return proxyUsername != null ? proxyUsername : getDefaultProxyUsername();
272+
}
273+
274+
/**
275+
* Gets the password for the authenticated proxy which will be used when making a request.
276+
* Default is <code>null</code>. To set a password to use {@link #setProxyPassword(String)}
277+
*
278+
* @return A {@link String} to use when making a request.
279+
*/
280+
public String getProxyPassword() {
281+
return proxyPassword != null ? proxyPassword : getDefaultProxyPassword();
282+
}
283+
244284
/**
245285
* Gets any additional headers for the request, for example, for proxy or logging information.
246286
*
@@ -446,6 +486,28 @@ public void setProxy(Proxy proxy) {
446486
this.proxy = proxy;
447487
}
448488

489+
/**
490+
* Sets a username for an authenticated proxy which will be used when making a request.
491+
* Default is <code>null</code>.
492+
*
493+
* @param username
494+
* A {@link java.lang.String} to use when making a request.
495+
*/
496+
public void setProxyUsername(final String username) {
497+
this.proxyUsername = username;
498+
}
499+
500+
/**
501+
* Sets a password for an authenticated proxy which will be used when making a request.
502+
* Default is <code>null</code>.
503+
*
504+
* @param password
505+
* A {@link java.lang.String} to use when making a request.
506+
*/
507+
public void setProxyPassword(final String password) {
508+
this.proxyPassword = password;
509+
}
510+
449511
/**
450512
* Sets any additional headers for the request, for example, for proxy or logging information.
451513
*
@@ -619,4 +681,46 @@ public static Proxy getDefaultProxy() {
619681
public static void setDefaultProxy(Proxy defaultProxy) {
620682
OperationContext.proxyDefault = defaultProxy;
621683
}
684+
685+
/**
686+
* Gets a default username for the authenticated proxy which will be used when making a request.
687+
* Default is <code>null</code>. To set a username use {@link #setDefaultProxyUsername(String)}
688+
*
689+
* @return A {@link String} to use when making a request.
690+
*/
691+
public static String getDefaultProxyUsername() {
692+
return OperationContext.proxyDefaultUsername;
693+
}
694+
695+
/**
696+
* Gets the default password for the authenticated proxy which will be used when making a request.
697+
* Default is <code>null</code>. To set a password to use {@link #setProxyPassword(String)}
698+
*
699+
* @return A {@link String} to use when making a request.
700+
*/
701+
public static String getDefaultProxyPassword() {
702+
return OperationContext.proxyDefaultPassword;
703+
}
704+
705+
/**
706+
* Sets a default username for an authenticated proxy which will be used when making a request.
707+
* Default is <code>null</code>.
708+
*
709+
* @param username
710+
* A {@link java.lang.String} to use when making a request.
711+
*/
712+
public static void setDefaultProxyUsername(final String username) {
713+
OperationContext.proxyDefaultUsername = username;
714+
}
715+
716+
/**
717+
* Sets a default password for an authenticated proxy which will be used when making a request.
718+
* Default is <code>null</code>.
719+
*
720+
* @param password
721+
* A {@link java.lang.String} to use when making a request.
722+
*/
723+
public static void setDefaultProxyPassword(final String password) {
724+
OperationContext.proxyDefaultPassword = password;
725+
}
622726
}

0 commit comments

Comments
 (0)