Aracılığıyla paylaş


StorageSharedKeyCredential Class

  • java.lang.Object
    • com.azure.storage.common.StorageSharedKeyCredential

public final class StorageSharedKeyCredential

SharedKey credential policy that is put into a header to authorize requests.

Constructor Summary

Constructor Description
StorageSharedKeyCredential(String accountName, String accountKey)

Initializes a new instance of StorageSharedKeyCredential contains an account's name and its primary or secondary accountKey.

Method Summary

Modifier and Type Method and Description
String computeHmac256(String stringToSign)

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

static StorageSharedKeyCredential fromAzureNamedKeyCredential(AzureNamedKeyCredential azureNamedKeyCredential)

Creates a SharedKey credential from the passed AzureNamedKeyCredential.

static StorageSharedKeyCredential fromConnectionString(String connectionString)

Creates a SharedKey credential from the passed connection string.

String generateAuthorizationHeader(URL requestURL, String httpMethod, HttpHeaders headers, boolean logStringToSign)

Generates the SharedKey Authorization value from information in the request.

String generateAuthorizationHeader(URL requestURL, String httpMethod, Map<String,String> headers)

Generates the SharedKey Authorization value from information in the request.

String generateAuthorizationHeader(URL requestURL, String httpMethod, Map<String,String> headers, boolean logStringToSign)

Generates the SharedKey Authorization value from information in the request.

String getAccountName()

Gets the account name associated with the request.

static StorageSharedKeyCredential getSharedKeyCredentialFromPipeline(HttpPipeline httpPipeline)

Searches for a StorageSharedKeyCredential in the HttpPipeline.

Methods inherited from java.lang.Object

Constructor Details

StorageSharedKeyCredential

public StorageSharedKeyCredential(String accountName, String accountKey)

Initializes a new instance of StorageSharedKeyCredential contains an account's name and its primary or secondary accountKey.

Parameters:

accountName - The account name associated with the request.
accountKey - The account access key used to authenticate the request.

Method Details

computeHmac256

public String computeHmac256(String stringToSign)

Computes a signature for the specified string using the HMAC-SHA256 algorithm. Package-private because it is used to generate SAS signatures.

Parameters:

stringToSign - The UTF-8-encoded string to sign.

Returns:

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

fromAzureNamedKeyCredential

public static StorageSharedKeyCredential fromAzureNamedKeyCredential(AzureNamedKeyCredential azureNamedKeyCredential)

Creates a SharedKey credential from the passed AzureNamedKeyCredential.

Parameters:

azureNamedKeyCredential - AzureNamedKeyCredential used to build the SharedKey credential.

Returns:

a SharedKey credential converted from AzureNamedKeyCredential

fromConnectionString

public static StorageSharedKeyCredential fromConnectionString(String connectionString)

Creates a SharedKey credential from the passed connection string.

Code Samples

StorageSharedKeyCredential credential = StorageSharedKeyCredential.fromConnectionString(connectionString);

Parameters:

connectionString - Connection string used to build the SharedKey credential.

Returns:

a SharedKey credential if the connection string contains AccountName and AccountKey

generateAuthorizationHeader

public String generateAuthorizationHeader(URL requestURL, String httpMethod, HttpHeaders headers, boolean logStringToSign)

Generates the SharedKey Authorization value from information in the request.

Parameters:

requestURL - URL of the request
httpMethod - HTTP method being used
headers - Headers on the request
logStringToSign - Whether to log the string to sign

Returns:

the SharedKey authorization value

generateAuthorizationHeader

public String generateAuthorizationHeader(URL requestURL, String httpMethod, Map headers)

Generates the SharedKey Authorization value from information in the request.

Parameters:

requestURL - URL of the request
httpMethod - HTTP method being used
headers - Headers on the request

Returns:

the SharedKey authorization value

generateAuthorizationHeader

public String generateAuthorizationHeader(URL requestURL, String httpMethod, Map headers, boolean logStringToSign)

Generates the SharedKey Authorization value from information in the request.

Parameters:

requestURL - URL of the request
httpMethod - HTTP method being used
headers - Headers on the request
logStringToSign - Whether to log the string to sign

Returns:

the SharedKey authorization value

getAccountName

public String getAccountName()

Gets the account name associated with the request.

Returns:

The account name.

getSharedKeyCredentialFromPipeline

public static StorageSharedKeyCredential getSharedKeyCredentialFromPipeline(HttpPipeline httpPipeline)

Searches for a StorageSharedKeyCredential in the HttpPipeline.

Parameters:

httpPipeline - Pipeline being searched

Returns:

a StorageSharedKeyCredential if the pipeline contains one, otherwise null.

Applies to