@Override public StorageCredentials getCredentials() { return serviceClient.getCredentials(); }
/** * Returns the URI after applying the authentication transformation. * * @return A <code>java.net.URI</code> object that represents the URI after applying the authentication * transformation. * * @throws IllegalArgumentException * If an unexpected value is passed. * @throws StorageException * If a storage service error occurred. * @throws URISyntaxException * If the resource URI is invalid. */ private StorageUri getTransformedAddress() throws URISyntaxException, StorageException { return this.blobServiceClient.getCredentials().transformUri(this.storageUri); }
/** * Returns the URI after applying the authentication transformation. * * @return A <code>java.net.URI</code> object that represents the URI after applying the authentication * transformation. * * @throws IllegalArgumentException * If an unexpected value is passed. * @throws StorageException * If a storage service error occurred. * @throws URISyntaxException * If the resource URI is invalid. */ private StorageUri getTransformedAddress() throws URISyntaxException, StorageException { return this.blobServiceClient.getCredentials().transformUri(this.storageUri); }
/** * Returns the canonical name for shared access. * * @return the canonical name for shared access. */ private String getSharedAccessCanonicalName() { String accountName = this.getServiceClient().getCredentials().getAccountName(); String containerName = this.getName(); return String.format("/%s/%s/%s", SR.BLOB, accountName, containerName); }
/** * Returns the canonical name for shared access. * * @return the canonical name for shared access. */ private String getSharedAccessCanonicalName() { String accountName = this.getServiceClient().getCredentials().getAccountName(); String containerName = this.getName(); return String.format("/%s/%s/%s", SR.BLOB, accountName, containerName); }
/** * Returns the transformed URI for the resource if the given credentials require transformation. * * @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 {@link StorageUri} object that represents the transformed URI. * * @throws IllegalArgumentException * If the URI is not absolute. * @throws StorageException * If a storage service error occurred. * @throws URISyntaxException * If the resource URI is invalid. */ protected final StorageUri getTransformedAddress(final OperationContext opContext) throws URISyntaxException, StorageException { return this.blobServiceClient.getCredentials().transformUri(this.getStorageUri(), opContext); }
/** * Returns the transformed URI for the resource if the given credentials require transformation. * * @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 {@link StorageUri} object that represents the transformed URI. * * @throws IllegalArgumentException * If the URI is not absolute. * @throws StorageException * If a storage service error occurred. * @throws URISyntaxException * If the resource URI is invalid. */ protected final StorageUri getTransformedAddress(final OperationContext opContext) throws URISyntaxException, StorageException { return this.blobServiceClient.getCredentials().transformUri(this.getStorageUri(), opContext); }
private void checkCredentials(BlobServiceConfiguration cfg) { CloudBlob client = cfg.getAzureBlobClient(); StorageCredentials creds = client == null ? cfg.getCredentials() : client.getServiceClient().getCredentials(); if ((creds == null || creds instanceof StorageCredentialsAnonymous) && !cfg.isPublicForRead()) { throw new IllegalArgumentException("Credentials must be specified."); } } }
/** * 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()); }
@Override public HttpURLConnection buildRequest(CloudBlobClient client, CloudBlobContainer container, OperationContext context) throws Exception { StorageUri transformedblobUri = CloudBlobContainer.this.getServiceClient().getCredentials().transformUri(blobUri, context); return BlobRequest.getBlobProperties(transformedblobUri.getUri(this.getCurrentLocation()), options, context, accessCondition, snapshotID); }
/** * Returns the blob's container. * * @return A {@link CloudBlobContainer} object that represents the container of the blob. * @throws StorageException * If a storage service error occurred. * @throws URISyntaxException * If the resource URI is invalid. */ @Override public final CloudBlobContainer getContainer() throws StorageException, URISyntaxException { if (this.container == null) { final StorageUri containerURI = PathUtility.getContainerURI(this.getStorageUri(), this.blobServiceClient.isUsePathStyleUris()); this.container = new CloudBlobContainer(containerURI, this.blobServiceClient.getCredentials()); } return this.container; }
@Override public HttpURLConnection buildRequest(CloudBlobClient client, CloudBlobContainer container, OperationContext context) throws Exception { StorageUri transformedblobUri = CloudBlobContainer.this.getServiceClient().getCredentials().transformUri(blobUri, context); return BlobRequest.getBlobProperties(transformedblobUri.getUri(this.getCurrentLocation()), options, context, accessCondition, snapshotID); }
/** * Returns the blob's container. * * @return A {@link CloudBlobContainer} object that represents the container of the blob. * @throws StorageException * If a storage service error occurred. * @throws URISyntaxException * If the resource URI is invalid. */ @Override public final CloudBlobContainer getContainer() throws StorageException, URISyntaxException { if (this.container == null) { final StorageUri containerURI = PathUtility.getContainerURI(this.getStorageUri(), this.blobServiceClient.isUsePathStyleUris()); this.container = new CloudBlobContainer(containerURI, this.blobServiceClient.getCredentials()); } return this.container; }
@Override public HttpURLConnection buildRequest(CloudBlobClient client, Void parentObject, OperationContext context) throws Exception { listingContext.setMarker(segmentedRequest.getToken() != null ? segmentedRequest.getToken() .getNextMarker() : null); return BlobRequest.listContainers( client.getCredentials().transformUri(client.getStorageUri()).getUri(this.getCurrentLocation()), options, context, listingContext, detailsIncluded); }
@Override public HttpURLConnection buildRequest(CloudBlobClient client, Void parentObject, OperationContext context) throws Exception { listingContext.setMarker(segmentedRequest.getToken() != null ? segmentedRequest.getToken() .getNextMarker() : null); return BlobRequest.listContainers( client.getCredentials().transformUri(client.getStorageUri()).getUri(this.getCurrentLocation()), options, context, listingContext, detailsIncluded); }
public static CloudBlockBlob defiddler(CloudBlockBlob blob) throws URISyntaxException, StorageException { URI oldUri = blob.getUri(); URI newUri = defiddler(oldUri); if (newUri != oldUri) { CloudBlockBlob newBlob = new CloudBlockBlob(newUri, blob.getServiceClient().getCredentials()); newBlob.setSnapshotID(blob.snapshotID); return newBlob; } else { return blob; } }
public static CloudPageBlob defiddler(CloudPageBlob blob) throws URISyntaxException, StorageException { URI oldUri = blob.getUri(); URI newUri = defiddler(oldUri); if (newUri != oldUri) { CloudPageBlob newBlob = new CloudPageBlob(newUri, blob.getServiceClient().getCredentials()); newBlob.setSnapshotID(blob.snapshotID); return newBlob; } else { return blob; } }
public static CloudAppendBlob defiddler(CloudAppendBlob blob) throws URISyntaxException, StorageException { URI oldUri = blob.getUri(); URI newUri = defiddler(oldUri); if (newUri != oldUri) { CloudAppendBlob newBlob = new CloudAppendBlob(newUri, blob.getServiceClient().getCredentials()); newBlob.setSnapshotID(blob.snapshotID); return newBlob; } else { return blob; } }
@Test public void testBlobUriOnlyConstructors() throws URISyntaxException, StorageException, InvalidKeyException { URI blobURI = new URI(container.getUri().toString() + "/anonblob"); CloudBlockBlob blob = new CloudBlockBlob(blobURI); assertEquals("anonblob", blob.getName()); assertNotNull(blob.getServiceClient()); assertEquals(StorageCredentialsAnonymous.class, blob.getServiceClient().getCredentials().getClass()); blob = container.getBlockBlobReference("anonblob"); String sas = blob.generateSharedAccessSignature(null, "dummyPolicy"); blobURI = new URI(container.getUri().toString() + "/anonblob?" + sas); blob = new CloudBlockBlob(blobURI); assertEquals("anonblob", blob.getName()); assertNotNull(blob.getServiceClient()); assertEquals(StorageCredentialsSharedAccessSignature.class, blob.getServiceClient().getCredentials().getClass()); }