/** * Creates a new Queue service client. * * @return A client object that uses the Queue service endpoint. */ public CloudQueueClient createCloudQueueClient() { if (this.getQueueStorageUri() == null) { throw new IllegalArgumentException(SR.QUEUE_ENDPOINT_NOT_CONFIGURED); } if (this.credentials == null) { throw new IllegalArgumentException(SR.MISSING_CREDENTIALS); } if (!StorageCredentialsHelper.canCredentialsGenerateClient(this.credentials)) { throw new IllegalArgumentException(SR.CREDENTIALS_CANNOT_SIGN_REQUEST); } return new CloudQueueClient(this.getQueueStorageUri(), this.getCredentials()); }
/** * RESERVED, for internal use only. Gets a value indicating whether a * client can be generated under the Shared Key or Shared Access Signature * authentication schemes using the specified credentials. * @return <Code>true</Code> if a client can be generated with these * credentials; otherwise, <Code>false</Code> */ public static boolean canCredentialsGenerateClient(final StorageCredentials creds) { return canCredentialsSignRequest(creds) || creds.getClass().equals(StorageCredentialsSharedAccessSignature.class); }
public static final void signBlobQueueAndFileRequest(HttpURLConnection request, ServiceClient client, long contentLength, OperationContext context) throws InvalidKeyException, StorageException { StorageCredentialsHelper.signBlobQueueAndFileRequest(client.getCredentials(), request, contentLength, context); }
final String computedBase64Signature = StorageCredentialsHelper.computeHmac256(creds, stringToSign);
public static final void signTableRequest(HttpURLConnection request, ServiceClient client, long contentLength, OperationContext context) throws InvalidKeyException, StorageException { StorageCredentialsHelper.signTableRequest(client.getCredentials(), request, contentLength, context); }
/** * Get the signature hash embedded inside the Shared Access Signature. * * @param stringToSign * The string to decode and hash * @param creds * Reference to the {@link StorageCredentials}. * * @return The signature hash embedded inside the Shared Access Signature. * * @throws InvalidKeyException * @throws StorageException */ private static String generateSharedAccessSignatureHashHelper(String stringToSign, final StorageCredentials creds) throws StorageException, InvalidKeyException { Utility.assertNotNull("credentials", creds); Logger.trace(null, LogConstants.SIGNING, stringToSign); stringToSign = Utility.safeDecode(stringToSign); return StorageCredentialsHelper.computeHmac256(creds, stringToSign); }
public static final void signTableRequest(HttpURLConnection request, ServiceClient client, long contentLength, OperationContext context) throws InvalidKeyException, StorageException { StorageCredentialsHelper.signTableRequest(client.getCredentials(), request, contentLength, context); }
/** * RESERVED, for internal use only. Gets a value indicating whether a * client can be generated under the Shared Key or Shared Access Signature * authentication schemes using the specified credentials. * @return <Code>true</Code> if a client can be generated with these * credentials; otherwise, <Code>false</Code> */ public static boolean canCredentialsGenerateClient(final StorageCredentials creds) { return canCredentialsSignRequest(creds) || creds.getClass().equals(StorageCredentialsSharedAccessSignature.class) || creds.getClass().equals(StorageCredentialsToken.class); }
/** * Creates a new Queue service client. * * @return A client object that uses the Queue service endpoint. */ public CloudQueueClient createCloudQueueClient() { if (this.getQueueStorageUri() == null) { throw new IllegalArgumentException(SR.QUEUE_ENDPOINT_NOT_CONFIGURED); } if (this.credentials == null) { throw new IllegalArgumentException(SR.MISSING_CREDENTIALS); } if (!StorageCredentialsHelper.canCredentialsGenerateClient(this.credentials)) { throw new IllegalArgumentException(SR.CREDENTIALS_CANNOT_SIGN_REQUEST); } return new CloudQueueClient(this.getQueueStorageUri(), this.getCredentials()); }
final String computedBase64Signature = StorageCredentialsHelper.computeHmac256(creds, stringToSign);
public static final void signBlobQueueAndFileRequest(HttpURLConnection request, ServiceClient client, long contentLength, OperationContext context) throws InvalidKeyException, StorageException { StorageCredentialsHelper.signBlobQueueAndFileRequest(client.getCredentials(), request, contentLength, context); }
/** * Returns a shared access signature for the account. * * @param policy * A {@link SharedAccessAccountPolicy} specifying the access policy for the shared access signature. * * @return The query string returned includes the leading question mark. * @throws StorageException * If a storage service error occurred. * @throws InvalidKeyException * If the key is invalid. */ public String generateSharedAccessSignature(SharedAccessAccountPolicy policy) throws InvalidKeyException, StorageException { if (!StorageCredentialsHelper.canCredentialsSignRequest(this.getCredentials())) { throw new IllegalArgumentException(SR.CANNOT_CREATE_SAS_WITHOUT_ACCOUNT_KEY); } final String sig = SharedAccessSignatureHelper.generateSharedAccessSignatureHashForAccount( this.credentials.getAccountName(), policy, this.getCredentials()); final UriQueryBuilder sasBuilder = SharedAccessSignatureHelper.generateSharedAccessSignatureForAccount(policy, sig); return sasBuilder.toString(); }
/** * Creates a new File service client. * * @return A {@link CloudFileClient} that represents the cloud File client. * */ public CloudFileClient createCloudFileClient() { if (this.getFileStorageUri() == null) { throw new IllegalArgumentException(SR.FILE_ENDPOINT_NOT_CONFIGURED); } if (this.credentials == null) { throw new IllegalArgumentException(SR.MISSING_CREDENTIALS); } if (!StorageCredentialsHelper.canCredentialsGenerateClient(this.credentials)) { throw new IllegalArgumentException(SR.CREDENTIALS_CANNOT_SIGN_REQUEST); } return new CloudFileClient(this.getFileStorageUri(), this.getCredentials()); }
final String computedBase64Signature = StorageCredentialsHelper.computeHmac256(creds, stringToSign);
throws InvalidKeyException, StorageException { if (!StorageCredentialsHelper.canCredentialsSignRequest(this.queueServiceClient.getCredentials())) { final String errorMessage = SR.CANNOT_CREATE_SAS_WITHOUT_ACCOUNT_KEY; throw new IllegalArgumentException(errorMessage);
/** * Creates a new Table service client. * * @return A client object that uses the Table service endpoint. */ public CloudTableClient createCloudTableClient() { if (this.getTableStorageUri() == null) { throw new IllegalArgumentException(SR.TABLE_ENDPOINT_NOT_CONFIGURED); } if (this.credentials == null) { throw new IllegalArgumentException(SR.MISSING_CREDENTIALS); } if (!StorageCredentialsHelper.canCredentialsGenerateClient(this.credentials)) { throw new IllegalArgumentException(SR.CREDENTIALS_CANNOT_SIGN_REQUEST); } return new CloudTableClient(this.getTableStorageUri(), this.getCredentials()); }
final String computedBase64Signature = StorageCredentialsHelper.computeHmac256(creds, stringToSign);
throws InvalidKeyException, StorageException { if (!StorageCredentialsHelper.canCredentialsSignRequest(this.fileServiceClient.getCredentials())) { final String errorMessage = SR.CANNOT_CREATE_SAS_WITHOUT_ACCOUNT_KEY; throw new IllegalArgumentException(errorMessage);
/** * Creates a new File service client. * * @return A {@link CloudFileClient} that represents the cloud File client. * */ public CloudFileClient createCloudFileClient() { if (this.getFileStorageUri() == null) { throw new IllegalArgumentException(SR.FILE_ENDPOINT_NOT_CONFIGURED); } if (this.credentials == null) { throw new IllegalArgumentException(SR.MISSING_CREDENTIALS); } if (!StorageCredentialsHelper.canCredentialsGenerateClient(this.credentials)) { throw new IllegalArgumentException(SR.CREDENTIALS_CANNOT_SIGN_REQUEST); } return new CloudFileClient(this.getFileStorageUri(), this.getCredentials()); }
/** * Get the signature hash embedded inside the Shared Access Signature. * * @param stringToSign * The string to decode and hash * @param creds * Reference to the {@link StorageCredentials.}. * * @return The signature hash embedded inside the Shared Access Signature. * * @throws InvalidKeyException * @throws StorageException */ private static String generateSharedAccessSignatureHashHelper(String stringToSign, final StorageCredentials creds) throws StorageException, InvalidKeyException { Utility.assertNotNull("credentials", creds); Logger.debug(null, LogConstants.SIGNING, stringToSign); stringToSign = Utility.safeDecode(stringToSign); final String signature = StorageCredentialsHelper.computeHmac256(creds, stringToSign); Logger.verbose(null, LogConstants.SIGNING, stringToSign); return signature; }