URI sasUri = PathUtility.addToQuery(resourceUri, this.token); return PathUtility.addToQuery(sasUri, apiVersion);
URI sasUri = PathUtility.addToQuery(resourceUri, this.token); return PathUtility.addToQuery(sasUri, apiVersion);
/** * Returns the blob's URI for both the primary and secondary locations, including query string information if the blob is a snapshot. * * @return A {@link StorageUri} object containing the blob's URIs for both the primary and secondary locations, * including snapshot query information if the blob is a snapshot. * * @throws StorageException * If a storage service error occurred. * @throws URISyntaxException * If the resource URI is invalid. */ public final StorageUri getSnapshotQualifiedStorageUri() throws URISyntaxException, StorageException { if (this.isSnapshot()) { return PathUtility.addToQuery(this.getStorageUri(), String.format("snapshot=%s", this.snapshotID)); } return this.getStorageUri(); }
/** * Returns the absolute URI to the blob, including query string information if the blob is a snapshot. * * @return A <code>java.net.URI</code> object specifying the absolute URI to the blob, * including snapshot query information if the blob is a snapshot. * * @throws StorageException * If a storage service error occurred. * @throws URISyntaxException * If the resource URI is invalid. */ public final URI getSnapshotQualifiedUri() throws URISyntaxException, StorageException { if (this.isSnapshot()) { return PathUtility.addToQuery(this.getUri(), String.format("snapshot=%s", this.snapshotID)); } return this.getUri(); }
/** * Returns the absolute URI to the blob, including query string information if the blob is a snapshot. * * @return A <code>java.net.URI</code> object specifying the absolute URI to the blob, * including snapshot query information if the blob is a snapshot. * * @throws StorageException * If a storage service error occurred. * @throws URISyntaxException * If the resource URI is invalid. */ public final URI getSnapshotQualifiedUri() throws URISyntaxException, StorageException { if (this.isSnapshot()) { return PathUtility.addToQuery(this.getUri(), String.format("snapshot=%s", this.snapshotID)); } return this.getUri(); }
/** * Returns the blob's URI for both the primary and secondary locations, including query string information if the blob is a snapshot. * * @return A {@link StorageUri} object containing the blob's URIs for both the primary and secondary locations, * including snapshot query information if the blob is a snapshot. * * @throws StorageException * If a storage service error occurred. * @throws URISyntaxException * If the resource URI is invalid. */ public final StorageUri getSnapshotQualifiedStorageUri() throws URISyntaxException, StorageException { if (this.isSnapshot()) { return PathUtility.addToQuery(this.getStorageUri(), String.format("snapshot=%s", this.snapshotID)); } return this.getStorageUri(); }
/** * Returns the snapshot or shared access signature qualified URI for this blob. * * @deprecated use {@link #getSnapshotQualifiedUri()} instead. * * @return A <code>java.net.URI</code> object that represents the snapshot or shared access signature. * * @throws StorageException * If a storage service error occurred. * @throws URISyntaxException * If the resource URI is invalid. */ @Deprecated public final URI getQualifiedUri() throws URISyntaxException, StorageException { if (this.isSnapshot()) { return PathUtility.addToQuery(this.getUri(), String.format("snapshot=%s", this.snapshotID)); } return this.blobServiceClient.getCredentials().transformUri(this.getUri()); }
/** * Returns the snapshot or shared access signature qualified URI for this blob. * * @deprecated use {@link #getSnapshotQualifiedUri()} instead. * * @return A <code>java.net.URI</code> object that represents the snapshot or shared access signature. * * @throws StorageException * If a storage service error occurred. * @throws URISyntaxException * If the resource URI is invalid. */ @Deprecated public final URI getQualifiedUri() throws URISyntaxException, StorageException { if (this.isSnapshot()) { return PathUtility.addToQuery(this.getUri(), String.format("snapshot=%s", this.snapshotID)); } return this.blobServiceClient.getCredentials().transformUri(this.getUri()); }
/** * Returns the snapshot or shared access signature qualified URI for this share. * * @return A <code>java.net.URI</code> object that represents the snapshot or shared access signature. * * @throws StorageException * If a storage service error occurred. * @throws URISyntaxException * If the resource URI is invalid. */ public final URI getQualifiedUri() throws URISyntaxException, StorageException { if (this.isSnapshot()) { return PathUtility.addToQuery(this.getUri(), String.format("sharesnapshot=%s", this.snapshotID)); } return this.fileServiceClient.getCredentials().transformUri(this.getUri()); }
/** * Returns the snapshot or shared access signature qualified URI for this share. * * @return A <code>java.net.URI</code> object that represents the snapshot or shared access signature. * * @throws StorageException * If a storage service error occurred. * @throws URISyntaxException * If the resource URI is invalid. */ public final URI getQualifiedUri() throws URISyntaxException, StorageException { if (this.isSnapshot()) { return PathUtility.addToQuery(this.getUri(), String.format("sharesnapshot=%s", this.snapshotID)); } return this.fileServiceClient.getCredentials().transformUri(this.getUri()); }
/** * Returns the snapshot and/or shared access signature qualified URI for this blob. * * @deprecated use {@link #getSnapshotQualifiedStorageUri()} instead. * * @return A {@link StorageUri} object that represents the snapshot or shared access signature. * * @throws StorageException * If a storage service error occurred. * @throws URISyntaxException * If the resource URI is invalid. */ @Deprecated public final StorageUri getQualifiedStorageUri() throws URISyntaxException, StorageException { if (this.isSnapshot()) { StorageUri snapshotQualifiedUri = PathUtility.addToQuery(this.getStorageUri(), String.format("snapshot=%s", this.snapshotID)); return this.blobServiceClient.getCredentials().transformUri(snapshotQualifiedUri); } return this.blobServiceClient.getCredentials().transformUri(this.getStorageUri()); }
/** * Returns the snapshot and/or shared access signature qualified URI for this blob. * * @deprecated use {@link #getSnapshotQualifiedStorageUri()} instead. * * @return A {@link StorageUri} object that represents the snapshot or shared access signature. * * @throws StorageException * If a storage service error occurred. * @throws URISyntaxException * If the resource URI is invalid. */ @Deprecated public final StorageUri getQualifiedStorageUri() throws URISyntaxException, StorageException { if (this.isSnapshot()) { StorageUri snapshotQualifiedUri = PathUtility.addToQuery(this.getStorageUri(), String.format("snapshot=%s", this.snapshotID)); return this.blobServiceClient.getCredentials().transformUri(snapshotQualifiedUri); } return this.blobServiceClient.getCredentials().transformUri(this.getStorageUri()); }
CloudFileShare sasShare = new CloudFileShare(PathUtility.addToQuery(this.share.getUri(), sasToken2));
CloudBlobContainer readListContainer = new CloudBlobContainer(PathUtility.addToQuery(this.container.getUri(), containerReadListSas)); CloudBlobContainer containerFromUri = new CloudBlobContainer(PathUtility.addToQuery( readListContainer.getStorageUri(), this.container.generateSharedAccessSignature(null, "readlist"))); assertEquals(StorageCredentialsSharedAccessSignature.class.toString(), containerFromUri.getServiceClient()
CloudBlobContainer sasContainer = new CloudBlobContainer(PathUtility.addToQuery(this.container.getUri(), sasToken2));
new CloudFileShare(PathUtility.addToQuery(this.share.getUri(), shareReadListSas)); CloudFileShare shareFromUri = new CloudFileShare(PathUtility.addToQuery( readListShare.getStorageUri(), this.share.generateSharedAccessSignature(null, "readlist"))); assertEquals(StorageCredentialsSharedAccessSignature.class.toString(),
@Test public void testFileSAS() throws InvalidKeyException, IllegalArgumentException, StorageException, URISyntaxException, InterruptedException { SharedAccessFilePolicy policy = createSharedAccessPolicy( EnumSet.of(SharedAccessFilePermissions.READ, SharedAccessFilePermissions.LIST), 300); FileSharePermissions perms = new FileSharePermissions(); perms.getSharedAccessPolicies().put("readperm", policy); this.share.uploadPermissions(perms); Thread.sleep(30000); CloudFile sasFile = new CloudFile( new URI(this.file.getUri().toString() + "?" + this.file.generateSharedAccessSignature(null, "readperm"))); sasFile.download(new ByteArrayOutputStream()); // do not give the client and check that the new file's client has the correct permissions CloudFile fileFromUri = new CloudFile(PathUtility.addToQuery(this.file.getStorageUri(), this.file.generateSharedAccessSignature(null, "readperm"))); assertEquals(StorageCredentialsSharedAccessSignature.class.toString(), fileFromUri.getServiceClient().getCredentials().getClass().toString()); // create credentials from sas StorageCredentials creds = new StorageCredentialsSharedAccessSignature( this.file.generateSharedAccessSignature(policy, null, null)); CloudFileClient client = new CloudFileClient(sasFile.getServiceClient().getStorageUri(), creds); CloudFile fileFromClient = client.getShareReference(this.file.getShare().getName()).getRootDirectoryReference() .getFileReference(this.file.getName()); assertEquals(StorageCredentialsSharedAccessSignature.class.toString(), fileFromClient.getServiceClient().getCredentials().getClass().toString()); assertEquals(client, fileFromClient.getServiceClient()); }
@Test @Category(SlowTests.class) public void testBlobSaS() throws InvalidKeyException, IllegalArgumentException, StorageException, URISyntaxException, InterruptedException { SharedAccessBlobPolicy sp = createSharedAccessPolicy( EnumSet.of(SharedAccessBlobPermissions.READ, SharedAccessBlobPermissions.LIST), 3600); BlobContainerPermissions perms = new BlobContainerPermissions(); perms.getSharedAccessPolicies().put("readperm", sp); this.container.uploadPermissions(perms); Thread.sleep(30000); CloudBlockBlob sasBlob = new CloudBlockBlob(new URI(this.blob.getUri().toString() + "?" + this.blob.generateSharedAccessSignature(null, "readperm"))); sasBlob.download(new ByteArrayOutputStream()); // do not give the client and check that the new blob's client has the correct perms CloudBlob blobFromUri = new CloudBlockBlob(PathUtility.addToQuery(this.blob.getStorageUri(), this.blob.generateSharedAccessSignature(null, "readperm"))); assertEquals(StorageCredentialsSharedAccessSignature.class.toString(), blobFromUri.getServiceClient() .getCredentials().getClass().toString()); // create credentials from sas StorageCredentials creds = new StorageCredentialsSharedAccessSignature( this.blob.generateSharedAccessSignature(null, "readperm")); CloudBlobClient bClient = new CloudBlobClient(sasBlob.getServiceClient().getStorageUri(), creds); CloudBlockBlob blobFromClient = bClient.getContainerReference(this.blob.getContainer().getName()) .getBlockBlobReference(this.blob.getName()); assertEquals(StorageCredentialsSharedAccessSignature.class.toString(), blobFromClient.getServiceClient() .getCredentials().getClass().toString()); assertEquals(bClient, blobFromClient.getServiceClient()); }
Thread.sleep(30000); CloudQueue identifierSasQueue = new CloudQueue(PathUtility.addToQuery(this.queue.getUri(), this.queue.generateSharedAccessSignature(null, identifier))); identifierSasQueue.deleteMessage(message1); CloudQueue policySasQueue = new CloudQueue(PathUtility.addToQuery(this.queue.getUri(), this.queue.generateSharedAccessSignature(policy1, null))); policySasQueue.exists(); CloudQueue queueFromUri = new CloudQueue(PathUtility.addToQuery(this.queue.getStorageUri(), this.queue.generateSharedAccessSignature(null, "readperm"))); assertEquals(StorageCredentialsSharedAccessSignature.class.toString(), queueFromUri.getServiceClient() queueClient.getDefaultRequestOptions().setRetryPolicyFactory(new RetryNoRetry()); queueFromUri = new CloudQueue(PathUtility.addToQuery(this.queue.getStorageUri(), this.queue.generateSharedAccessSignature(null, "readperm"))); assertEquals(StorageCredentialsSharedAccessSignature.class.toString(), queueFromUri.getServiceClient()
"javatables_batch_1", "04"); StorageCredentialsSharedAccessSignature sasCreds = new StorageCredentialsSharedAccessSignature(sasString); CloudTable directTable = new CloudTable(PathUtility.addToQuery(table.getUri(), sasString)); CloudTable transformedTable = new CloudTable(sasCreds.transformUri(table.getUri()));