/** * Returns the canonical name for shared access. * * @return A <code>String</code> containing the canonical name for shared access. */ private String getSharedAccessCanonicalName() { String accountName = this.getServiceClient().getCredentials().getAccountName(); String tableNameLowerCase = this.getName().toLowerCase(Locale.ENGLISH); return String.format("/%s/%s/%s", SR.TABLE, accountName, tableNameLowerCase); }
/** * Returns the canonical name for shared access. * * @return A <code>String</code> containing the canonical name for shared access. */ private String getSharedAccessCanonicalName() { String accountName = this.getServiceClient().getCredentials().getAccountName(); String tableNameLowerCase = this.getName().toLowerCase(Locale.ENGLISH); return String.format("/%s/%s/%s", SR.TABLE, accountName, tableNameLowerCase); }
protected final StorageUri getTransformedEndPoint(final OperationContext opContext) throws URISyntaxException, StorageException { return this.getCredentials().transformUri(this.getStorageUri(), opContext); }
protected final StorageUri getTransformedEndPoint(final OperationContext opContext) throws URISyntaxException, StorageException { return this.getCredentials().transformUri(this.getStorageUri(), opContext); }
throws InvalidKeyException, StorageException { if (!StorageCredentialsHelper.canCredentialsSignRequest(this.tableServiceClient.getCredentials())) { throw new IllegalArgumentException(SR.CANNOT_CREATE_SAS_WITHOUT_ACCOUNT_KEY);
throws InvalidKeyException, StorageException { if (!StorageCredentialsHelper.canCredentialsSignRequest(this.tableServiceClient.getCredentials())) { throw new IllegalArgumentException(SR.CANNOT_CREATE_SAS_WITHOUT_ACCOUNT_KEY);
private static void testIsUsePathStyleUri(StorageCredentials creds, String tableEndpoint, boolean usePathStyleUris) throws URISyntaxException, InvalidKeyException, StorageException { CloudTableClient tableClient = new CloudTableClient(new URI(tableEndpoint), creds); assertEquals(usePathStyleUris, tableClient.isUsePathStyleUris()); CloudTable table = tableClient.getTableReference("mytable"); assertEquals(tableEndpoint + "/mytable", table.getUri().toString()); String sasToken = table.generateSharedAccessSignature(null, "fakeIdentifier", null, null, null, null); tableClient = new CloudTableClient(new URI(tableEndpoint), new StorageCredentialsSharedAccessSignature(sasToken)); assertEquals(usePathStyleUris, tableClient.isUsePathStyleUris()); table = new CloudTable(table.getUri(), tableClient.getCredentials()); assertEquals(tableEndpoint + "/mytable", table.getUri().toString()); }
@Test public void testTableTypesWithStorageUri() throws URISyntaxException, StorageException { CloudTableClient tableClient = TestHelper.createCloudTableClient(); StorageUri endpoint = new StorageUri(new URI("http://" + ACCOUNT_NAME + TABLE_SERVICE + ENDPOINT_SUFFIX), new URI("http://" + ACCOUNT_NAME + SECONDARY_SUFFIX + TABLE_SERVICE + ENDPOINT_SUFFIX)); CloudTableClient client = new CloudTableClient(endpoint, tableClient.getCredentials()); assertEquals(endpoint, client.getStorageUri()); assertEquals(endpoint.getPrimaryUri(), client.getEndpoint()); StorageUri tableUri = new StorageUri(new URI(endpoint.getPrimaryUri() + "/table"), new URI( endpoint.getSecondaryUri() + "/table")); CloudTable table = client.getTableReference("table"); assertEquals(tableUri, table.getStorageUri()); assertEquals(tableUri.getPrimaryUri(), table.getUri()); assertEquals(endpoint, table.getServiceClient().getStorageUri()); table = new CloudTable(tableUri, client.getCredentials()); assertEquals(tableUri, table.getStorageUri()); assertEquals(tableUri.getPrimaryUri(), table.getUri()); assertEquals(endpoint, table.getServiceClient().getStorageUri()); } }
"javatables_batch_9", "9"))); assertEquals(StorageCredentialsSharedAccessSignature.class.toString(), tableFromUri.getServiceClient() .getCredentials().getClass().toString()); .getCredentials().getClass().toString());
sasUri = sasClient.getCredentials().transformUri(sasUri); final CloudTable sasTable = new CloudTable(sasUri);
@Test public void testCloudStorageAccountClientMethods() throws URISyntaxException { StorageCredentialsAccountAndKey cred = new StorageCredentialsAccountAndKey(ACCOUNT_NAME, ACCOUNT_KEY); CloudStorageAccount account = new CloudStorageAccount(cred, false); CloudBlobClient blob = account.createCloudBlobClient(); CloudQueueClient queue = account.createCloudQueueClient(); CloudTableClient table = account.createCloudTableClient(); CloudFileClient file = account.createCloudFileClient(); // check endpoints assertEquals("Blob endpoint doesn't match account", account.getBlobEndpoint(), blob.getEndpoint()); assertEquals("Queue endpoint doesn't match account", account.getQueueEndpoint(), queue.getEndpoint()); assertEquals("Table endpoint doesn't match account", account.getTableEndpoint(), table.getEndpoint()); assertEquals("File endpoint doesn't match account", account.getFileEndpoint(), file.getEndpoint()); // check storage uris assertEquals("Blob endpoint doesn't match account", account.getBlobStorageUri(), blob.getStorageUri()); assertEquals("Queue endpoint doesn't match account", account.getQueueStorageUri(), queue.getStorageUri()); assertEquals("Table endpoint doesn't match account", account.getTableStorageUri(), table.getStorageUri()); assertEquals("File endpoint doesn't match account", account.getFileStorageUri(), file.getStorageUri()); // check creds assertEquals("Blob creds don't match account", account.getCredentials(), blob.getCredentials()); assertEquals("Queue creds don't match account", account.getCredentials(), queue.getCredentials()); assertEquals("Table creds don't match account", account.getCredentials(), table.getCredentials()); assertEquals("File creds don't match account", account.getCredentials(), file.getCredentials()); }