/** * Transforms a resource URI into a shared access signature URI, by appending a shared access token and using the * specified operation context. * * @param resourceUri * A <code>StorageUri</code> object that represents the resource URI to be transformed. * @param opContext * An {@link OperationContext} object that represents the context for the current operation. This object * is used to track requests to the storage service, and to provide additional runtime information about * the operation. * * @return A <code>StorageUri</code> object that represents the signature, including the resource URI and the * shared access token. * * @throws StorageException * If a storage service error occurred. * @throws URISyntaxException * If the resource URI is not properly formatted. */ @Override public StorageUri transformUri(StorageUri resourceUri, OperationContext opContext) throws URISyntaxException, StorageException { return new StorageUri(this.transformUri(resourceUri.getPrimaryUri(), opContext), this.transformUri( resourceUri.getSecondaryUri(), opContext)); } }
/** * Transforms a resource URI into a shared access signature URI, by appending a shared access token and using the * specified operation context. * * @param resourceUri * A <code>StorageUri</code> object that represents the resource URI to be transformed. * @param opContext * An {@link OperationContext} object that represents the context for the current operation. This object * is used to track requests to the storage service, and to provide additional runtime information about * the operation. * * @return A <code>StorageUri</code> object that represents the signature, including the resource URI and the * shared access token. * * @throws StorageException * If a storage service error occurred. * @throws URISyntaxException * If the resource URI is not properly formatted. */ @Override public StorageUri transformUri(StorageUri resourceUri, OperationContext opContext) throws URISyntaxException, StorageException { return new StorageUri(this.transformUri(resourceUri.getPrimaryUri(), opContext), this.transformUri( resourceUri.getSecondaryUri(), opContext)); } }
@Test public void testStorageCredentialsSAS() throws URISyntaxException, StorageException { String token = "?sig=1&sp=abcde&api-version=" + Constants.HeaderConstants.TARGET_STORAGE_VERSION; StorageCredentialsSharedAccessSignature cred = new StorageCredentialsSharedAccessSignature(token); assertNull(cred.getAccountName()); URI testUri = new URI("http://test/abc" + token); TestHelper.assertURIsEqual(testUri, cred.transformUri(testUri), true); testUri = new URI("http://test/abc?query=a&query2=b"); URI expectedUri = new URI("http://test/abc?sig=1&query=a&sp=abcde&query2=b&api-version=" + Constants.HeaderConstants.TARGET_STORAGE_VERSION); TestHelper.assertURIsEqual(expectedUri, cred.transformUri(testUri), true); }
copySource = new CloudBlockBlob(credentials.transformUri(source.getUri())); copyDestination = new CloudBlockBlob(credentials.transformUri(destination.getUri()));
destination.startCopy(new CloudFile(credentials.transformUri(source.getUri())));
String copyId = destination.startCopy(blobType.newInstance(credentials.transformUri(source.getUri()))); FileTestHelper.waitForCopy(destination); destination.downloadAttributes();
FileTestHelper.defiddler(new CloudFile(credentials.transformUri(source.getUri())))); BlobTestHelper.waitForCopy(destination); destination.downloadAttributes();
copySource = new CloudFile(credentials.transformUri(source.getUri()));
StorageCredentialsSharedAccessSignature sasCreds = new StorageCredentialsSharedAccessSignature(sasString); CloudTable directTable = new CloudTable(PathUtility.addToQuery(table.getUri(), sasString)); CloudTable transformedTable = new CloudTable(sasCreds.transformUri(table.getUri()));
String copyId = destination.startCopy(new CloudFile(credentials.transformUri(source.getUri()))); BlobTestHelper.waitForCopy(destination); destination.downloadAttributes();