Class AzureSasCredential

java.lang.Object
com.azure.core.credential.AzureSasCredential

public final class AzureSasCredential extends Object
Represents a credential that uses a shared access signature to authenticate to an Azure Service.
  • Constructor Details

    • AzureSasCredential

      public AzureSasCredential(String signature)
      Creates a credential that authorizes request with the given shared access signature.

      The signature passed is assumed to be encoded. This constructor is effectively the same as calling new AzureSasCredential(signature, null)).

      Parameters:
      signature - The shared access signature used to authorize requests.
      Throws:
      NullPointerException - If signature is null.
      IllegalArgumentException - If signature is an empty string.
    • AzureSasCredential

      public AzureSasCredential(String signature, Function<String,String> signatureEncoder)
      Creates a credential that authorizes request within the given shared access signature.

      If signatureEncoder is non-null the signature, and all updated signatures, will be encoded using the function. signatureEncoder should be as idempotent as possible to reduce the chance of double encoding errors.

      Parameters:
      signature - The shared access signature used to authorize requests.
      signatureEncoder - An optional function which encodes the signature.
      Throws:
      NullPointerException - If signature is null.
      IllegalArgumentException - If signature is an empty string.
  • Method Details

    • getSignature

      public String getSignature()
      Retrieves the shared access signature associated to this credential.
      Returns:
      The shared access signature being used to authorize requests.
    • update

      public AzureSasCredential update(String signature)
      Rotates the shared access signature associated to this credential.
      Parameters:
      signature - The new shared access signature to be associated with this credential.
      Returns:
      The updated AzureSasCredential object.
      Throws:
      NullPointerException - If signature is null.
      IllegalArgumentException - If signature is an empty string.