TsgcWSPClient_AMQP1Methods › CreateAzureCbsSasToken

CreateAzureCbsSasToken Method

Builds an Azure Service Bus SAS token from the given SAS key and pushes it via CBS to authorise the specified entity.

Syntax

function CreateAzureCbsSasToken(const aName, aNameSpace, aEntityName, aKeyName, aKeyValue: string; const aExpiration: Integer = 3600; aTimeout: Integer = 10000; aRaiseIfError: Boolean = False): Boolean;

Parameters

NameTypeDescription
aNameconst stringIdentifier of the $cbs link previously attached with CreateCBSLink.
aNameSpaceconst stringService Bus namespace host, e.g. contoso.servicebus.windows.net (no sb:// prefix).
aEntityNameconst stringEntity path the token should authorise (queue, topic or Event Hub name); may be blank to authorise the whole namespace.
aKeyNameconst stringName of the Shared Access Policy used to sign the token (for example RootManageSharedAccessKey).
aKeyValueconst stringPrimary or secondary SAS key value (base64) associated with aKeyName.
aExpirationconst IntegerToken lifetime in seconds. Also used as the expiration application-property pushed to $cbs. Default 3600.
aTimeoutIntegerMilliseconds to wait for the $cbs put-token reply. Default 10000.
aRaiseIfErrorBooleanWhen True the method raises an exception if $cbs does not answer with status-code 200; when False the failure is reported only via the Boolean return.

Return Value

True when $cbs accepted the generated SAS token (status-code 200), False when it was rejected or the call timed out. (Boolean)

Remarks

Convenience wrapper around PutCBSToken: the method builds the canonical Azure Service Bus SAS signature (URL-encoded audience sb://NameSpace/EntityName, expiration as unix-timestamp, HMAC-SHA256 of audience + "\n" + expiry signed with the SAS key, base64-encoded) and sends it to the $cbs node with token-type servicebus.windows.net:sastoken. Call this once per entity immediately after the Open/Begin/Attach handshake and before creating working sender/receiver links to that entity; re-invoke before the token expires to rotate credentials.

Example


oAMQP1.CreateCBSLink('cbs_1', 'session_1');
oAMQP1.CreateAzureCbsSasToken('cbs_1',
  'contoso.servicebus.windows.net',
  'orders',
  'RootManageSharedAccessKey',
  'AbCdEf1234567890/Shared=',
  3600, 10000, True);

Back to Methods