public final class StorageKey extends Object
| Constructor and Description |
|---|
StorageKey(byte[] key)
Creates an instance of the
StorageKey class. |
| Modifier and Type | Method and Description |
|---|---|
static String |
computeMacSha256(StorageKey storageKey,
String stringToSign)
Computes a signature for the specified string using the HMAC-SHA256 algorithm.
|
static String |
computeMacSha512(StorageKey storageKey,
String stringToSign)
Computes a signature for the specified string using the HMAC-SHA512 algorithm.
|
String |
getBase64EncodedKey()
Returns the Base64-encoded key.
|
byte[] |
getKey()
Returns the key.
|
void |
setKey(byte[] key)
Sets the key to be used, using the specified byte array as the key.
|
void |
setKey(String key)
Sets the key to be used, using the specified
String as the key. |
public StorageKey(byte[] key)
StorageKey class.key - An array of bytes that represent the storage key.public static String computeMacSha256(StorageKey storageKey, String stringToSign) throws InvalidKeyException
storageKey - A StorageKey object that represents the storage key to use.stringToSign - The UTF-8-encoded string to sign.String that contains the HMAC-SHA256-encoded signature.IllegalArgumentException - If the string to sign is not a valid Base64-encoded string.InvalidKeyException - If the key is not a valid storage key.public static String computeMacSha512(StorageKey storageKey, String stringToSign) throws InvalidKeyException
storageKey - A StorageKey object that represents the storage key to use.stringToSign - The UTF-8-encoded string to sign.String that contains the HMAC-SHA512-encoded signature.IllegalArgumentException - If the string to sign is not a valid Base64-encoded string.InvalidKeyException - If the key is not a valid storage key.public String getBase64EncodedKey()
String that represents the Base64-encoded key.public byte[] getKey()
public void setKey(byte[] key)
key - A byte array that represents the key being assigned.public void setKey(String key)
String as the key.
This method is provided to support key rotation. This method is not thread-safe.key - A String that represents the key being assigned./**
* Copyright Microsoft Corporation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/