StorageCredentialsHelper Class

  • java.lang.Object
    • com.microsoft.azure.storage.core.StorageCredentialsHelper

public class StorageCredentialsHelper

RESERVED FOR INTERNAL USE. A helper method for StorageCredentials.

Method Summary

Modifier and Type Method and Description
boolean canCredentialsGenerateClient(final StorageCredentials creds)

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.

boolean canCredentialsSignRequest(final StorageCredentials creds)

RESERVED, for internal use only. Gets a value indicating whether a request can be signed under the Shared Key authentication scheme using the specified credentials.

synchronized byte [] computeHmac256(final byte[] data, final byte[] key)
synchronized String computeHmac256(final StorageCredentials creds, final String value)

Computes a signature for the specified string using the HMAC-SHA256 algorithm.

String signBlobQueueAndFileRequest(final StorageCredentials creds, final java.net.HttpURLConnection request, final long contentLength, OperationContext opContext)

Signs a request using the specified operation context under either the Shared Key or Token authentication scheme.

While this method places the signature on the request, it also returns the signature it set. This is because java.net.HttpURLConnection does not let you read an authorization header once set, and batch needs to set this signature elsewhere. Non-batch-related functions can ignore this return value.

void signTableRequest(final StorageCredentials creds, final java.net.HttpURLConnection request, final long contentLength, OperationContext opContext)

Signs a request using the specified operation context under the Shared Key authentication scheme.

Method Details

canCredentialsGenerateClient

public static boolean canCredentialsGenerateClient(final StorageCredentials creds)

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.

Parameters:

creds

Returns:

true if a client can be generated with these credentials; otherwise, false

canCredentialsSignRequest

public static boolean canCredentialsSignRequest(final StorageCredentials creds)

RESERVED, for internal use only. Gets a value indicating whether a request can be signed under the Shared Key authentication scheme using the specified credentials.

Parameters:

creds

Returns:

true if a request can be signed with these credentials; otherwise, false

computeHmac256

public static synchronized byte [] computeHmac256(final byte[] data, final byte[] key)

Parameters:

data
key

computeHmac256

public static synchronized String computeHmac256(final StorageCredentials creds, final String value)

Computes a signature for the specified string using the HMAC-SHA256 algorithm.

Parameters:

creds
value - The UTF-8-encoded string to sign.

Returns:

A String that contains the HMAC-SHA256-encoded signature.

Throws:

InvalidKeyException - If the key is not a valid Base64-encoded string.

signBlobQueueAndFileRequest

public static String signBlobQueueAndFileRequest(final StorageCredentials creds, final java.net.HttpURLConnection request, final long contentLength, OperationContext opContext)

Signs a request using the specified operation context under either the Shared Key or Token authentication scheme.

While this method places the signature on the request, it also returns the signature it set. This is because java.net.HttpURLConnection does not let you read an authorization header once set, and batch needs to set this signature elsewhere. Non-batch-related functions can ignore this return value.

Parameters:

creds
request - An HttpURLConnection object that represents the request to sign.
contentLength - The length of the content written to the output stream. If unknown, specify -1.
opContext - An 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.

Returns:

The value of the authorization signature applied to the request.

Throws:

InvalidKeyException - If the given key is invalid.
StorageException - If a storage service error occurred.

signTableRequest

public static void signTableRequest(final StorageCredentials creds, final java.net.HttpURLConnection request, final long contentLength, OperationContext opContext)

Signs a request using the specified operation context under the Shared Key authentication scheme.

Parameters:

creds
request - An HttpURLConnection object that represents the request to sign.
contentLength - The length of the content written to the output stream. If unknown, specify -1.
opContext - An 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.

Throws:

InvalidKeyException - If the given key is invalid.
StorageException - If a storage service error occurred.

Applies to