Class AuthAzureSAS

java.lang.Object
com.chilkatsoft.chilkat2.ChilkatObject
com.chilkatsoft.chilkat2.AuthAzureSAS
All Implemented Interfaces:
AutoCloseable

public class AuthAzureSAS extends ChilkatObject
<section class="authazuresas-summary">

Create Azure Shared Access Signature tokens for signed Azure Storage requests.

Chilkat.AuthAzureSAS creates Azure Shared Access Signature authentication tokens. It defines the SAS string-to-sign, supplies the Azure Storage account access key used to compute the signature, and controls which parameters are included in the generated SAS token query string. The resulting token can be used with Chilkat.Rest, Chilkat.Http, or other request-building code that needs time-limited, permission-scoped access to Azure Storage resources.

SAS token generation

Generate a signed query-string token that authorizes limited access to an Azure Storage resource.

String-to-sign control

Provide the exact Azure SAS string-to-sign required for the storage service and resource being accessed.

Account key signing

Use the Azure Storage account access key to compute the signature placed in the generated SAS token.

Token parameters

Add signed SAS parameters such as permissions, expiry, resource type, API version, protocol, or IP restrictions.

Non-token parameters

Add query parameters that should accompany the request but should not be included as part of the SAS token itself.

REST integration

Use the generated SAS query string with Azure Storage requests built using Chilkat.Rest or other Chilkat HTTP workflows.

Common pattern: Create an AuthAzureSAS object, set the Azure Storage AccessKey, provide the required StringToSign, add SAS token parameters with SetTokenParam, add any extra query parameters with SetNonTokenParam, then call GenerateToken. Use AuthAzureSAS when you need a SAS query token; use Chilkat.AuthAzureStorage when you need Shared Key authorization headers instead.

For an extended overview, see AuthAzureSAS Class Overview.

</section>

Instances hold a native Chilkat object: close them with ChilkatObject.close() (try-with-resources) when done; an unclosed instance is freed when it becomes unreachable.

See Also:
Online reference
  • Constructor Details

    • AuthAzureSAS

      public AuthAzureSAS()
      Creates a new AuthAzureSAS object.
  • Method Details

    • getAccessKey

      public String getAccessKey()
      This is the signing key (access key) that must be kept private. It is a base64 string such as abdTvCZFFoWUyre6erlNN+IOb9qhXgDsyhrxmZvpmxqFDwpl9oD0X9Fy0hIQa6L5UohznRLmkCtUYySO4Y2eaw==
      Returns:
      the value of the AccessKey property
    • setAccessKey

      public void setAccessKey​(String value)
      Sets the AccessKey property; see getAccessKey().
      Parameters:
      value - the new value (not null)
    • getStringToSign

      public String getStringToSign()
      Defines the format of the string to sign.

      The format is specified as a comma-separated list of names. For example:

      signedpermissions,signedstart,signedexpiry,canonicalizedresource,signedidentifier,signedIP,signedProtocol,signedversion,rscc,rscd,rsce,rscl,rsct

      This will result in an actual string-to-sign that is composed of the values for each name separated by newline (LF) chars. For example:

      signedpermissions + \n +  
       signedstart + \n +  
       signedexpiry + \n +  
       canonicalizedresource + \n +  
       signedidentifier + \n +  
       signedIP + \n +  
       signedProtocol + \n +  
       signedversion + \n +  
       rscc + \n +  
       rscd + \n +  
       rsce + \n +  
       rscl + \n +  
       rsct
      Returns:
      the value of the StringToSign property
    • setStringToSign

      public void setStringToSign​(String value)
      Sets the StringToSign property; see getStringToSign().
      Parameters:
      value - the new value (not null)
    • clear

      public void clear()
      Clears all params set by the methods SetNonTokenParam and SetTokenParam.
    • generateToken

      public String generateToken()
      Generates and returns the SAS token based on the defined getStringToSign() and params.
      Returns:
      the result (never null)
      Throws:
      ChilkatException - if the operation fails; ChilkatException.getLastErrorText() says why
    • setNonTokenParam

      public void setNonTokenParam​(String name, String value)
      Adds a non-token parameter name/value. This is a value that is included in the string to sign, but is NOT included in the token query params.
      Parameters:
      name - the name argument (not null)
      value - the value argument (not null)
      Throws:
      ChilkatException - if the operation fails; ChilkatException.getLastErrorText() says why
    • setTokenParam

      public void setTokenParam​(String name, String authParamName, String value)
      Adds a token parameter name/value. This is a value that is included in the string to sign, and is also included in the token query params.
      Parameters:
      name - the name argument (not null)
      authParamName - the authParamName argument (not null)
      value - the value argument (not null)
      Throws:
      ChilkatException - if the operation fails; ChilkatException.getLastErrorText() says why