public final class StorageSharedKeyCredential extends Object
| Constructor and Description |
|---|
StorageSharedKeyCredential(String accountName,
String accountKey)
Initializes a new instance of StorageSharedKeyCredential contains an account's name and its primary or secondary
accountKey.
|
| Modifier and Type | Method and Description |
|---|---|
String |
computeHmac256(String stringToSign)
Computes a signature for the specified string using the HMAC-SHA256 algorithm.
|
static StorageSharedKeyCredential |
fromConnectionString(String connectionString)
Creates a SharedKey credential from the passed connection string.
|
String |
generateAuthorizationHeader(URL requestURL,
String httpMethod,
Map<String,String> headers)
Generates the SharedKey Authorization value from information in the request.
|
String |
getAccountName()
Gets the account name associated with the request.
|
static StorageSharedKeyCredential |
getSharedKeyCredentialFromPipeline(com.azure.core.http.HttpPipeline httpPipeline)
Searches for a
StorageSharedKeyCredential in the passed HttpPipeline. |
public StorageSharedKeyCredential(String accountName, String accountKey)
accountName - The account name associated with the request.accountKey - The account access key used to authenticate the request.public static StorageSharedKeyCredential fromConnectionString(String connectionString)
Code Samples
StorageSharedKeyCredentialcredential =StorageSharedKeyCredential.fromConnectionString(connectionString);
connectionString - Connection string used to build the SharedKey credential.IllegalArgumentException - If connectionString doesn't have AccountName or AccountKey.public String getAccountName()
public String generateAuthorizationHeader(URL requestURL, String httpMethod, Map<String,String> headers)
requestURL - URL of the requesthttpMethod - HTTP method being usedheaders - Headers on the requestpublic String computeHmac256(String stringToSign)
stringToSign - The UTF-8-encoded string to sign.String that contains the HMAC-SHA256-encoded signature.RuntimeException - If the HMAC-SHA256 algorithm isn't support, if the key isn't a valid Base64 encoded
string, or the UTF-8 charset isn't supported.public static StorageSharedKeyCredential getSharedKeyCredentialFromPipeline(com.azure.core.http.HttpPipeline httpPipeline)
StorageSharedKeyCredential in the passed HttpPipeline.httpPipeline - Pipeline being searchedCopyright © 2020 Microsoft Corporation. All rights reserved.