Class AzureSasCredentialPolicy

java.lang.Object
com.azure.core.http.policy.AzureSasCredentialPolicy
All Implemented Interfaces:
HttpPipelinePolicy

public final class AzureSasCredentialPolicy extends Object implements HttpPipelinePolicy
The AzureSasCredentialPolicy class is an implementation of the HttpPipelinePolicy interface. This policy uses an AzureSasCredential to append a shared access signature (SAS) to the query string of a request.

This class is useful when you need to authorize requests with a SAS from Azure. It ensures that the requests are sent over HTTPS to prevent the SAS from being leaked.

Code sample:

In this example, an AzureSasCredentialPolicy is created with a SAS. The policy can then added to the pipeline. The requess sent by the pipeline will then include the SAS appended to its query string.

 AzureSasCredential credential = new AzureSasCredential("my_sas");
 AzureSasCredentialPolicy policy = new AzureSasCredentialPolicy(credential);
 
See Also:
  • Constructor Details

    • AzureSasCredentialPolicy

      public AzureSasCredentialPolicy(AzureSasCredential credential)
      Creates a policy that uses the passed AzureSasCredential to append sas to query string.

      Requests sent with this pipeline policy are required to use HTTPS. If the request isn't using HTTPS an exception will be thrown to prevent leaking the shared access signature.

      Parameters:
      credential - The AzureSasCredential containing the shared access signature to use.
      Throws:
      NullPointerException - If credential is null.
    • AzureSasCredentialPolicy

      public AzureSasCredentialPolicy(AzureSasCredential credential, boolean requireHttps)
      Creates a policy that uses the passed AzureSasCredential to append sas to query string.
      Parameters:
      credential - The AzureSasCredential containing the shared access signature to use.
      requireHttps - A flag indicating whether HTTPS is required.
      Throws:
      NullPointerException - If credential is null.
  • Method Details