Table of Contents

Class SharedAccessSignatureTokenProvider

Namespace
Microsoft.ServiceBus
Assembly
Microsoft.ServiceBus.dll

Represents the shared access signature associated with the token provider.

public class SharedAccessSignatureTokenProvider : TokenProvider
Inheritance
SharedAccessSignatureTokenProvider
Derived
Inherited Members

Constructors

SharedAccessSignatureTokenProvider(string, string, Func<string, byte[]>, TimeSpan, TokenScope)

protected SharedAccessSignatureTokenProvider(string keyName, string sharedAccessKey, Func<string, byte[]> customKeyEncoder, TimeSpan tokenTimeToLive, TokenScope tokenScope)

Parameters

keyName string
sharedAccessKey string
customKeyEncoder Func<string, byte[]>
tokenTimeToLive TimeSpan
tokenScope TokenScope

Fields

EpochTime

The epoch time.

public static readonly DateTime EpochTime

Field Value

DateTime

Properties

StripQueryParameters

Gets whether the token provider strips query parameters.

protected override bool StripQueryParameters { get; }

Property Value

bool

true if the token provider strips query parameters; otherwise, false.

Methods

BuildKey(string, string)

Generates a key for the token provider.

protected override TokenProvider.Key BuildKey(string appliesTo, string action)

Parameters

appliesTo string

The URI which the access token applies to.

action string

The request action.

Returns

TokenProvider.Key

A generated key for the token provider.

BuildSignature(string)

protected virtual string BuildSignature(string targetUri)

Parameters

targetUri string

Returns

string

GetPublisherSharedAccessSignature(Uri, string, string, string, string, TimeSpan)

public static string GetPublisherSharedAccessSignature(Uri endpoint, string entityPath, string publisher, string keyName, string key, TimeSpan tokenTimeToLive)

Parameters

endpoint Uri
entityPath string
publisher string
keyName string
key string
tokenTimeToLive TimeSpan

Returns

string

Remarks

This method assumes UTF8 encoding is being used.

GetSharedAccessSignature(string, string, string, TimeSpan)

Returns the shared access signature associated with the specified key name, SAS key, resource, and token time-to-live.

public static string GetSharedAccessSignature(string keyName, string sharedAccessKey, string resource, TimeSpan tokenTimeToLive)

Parameters

keyName string

The key name.

sharedAccessKey string

The SAS key name.

resource string

The resource.

tokenTimeToLive TimeSpan

The TTL value for the token.

Returns

string

Returns string.

OnBeginGetToken(string, string, TimeSpan, AsyncCallback, object)

Executes upon calling the BeginGetToken method.

protected override IAsyncResult OnBeginGetToken(string appliesTo, string action, TimeSpan timeout, AsyncCallback callback, object state)

Parameters

appliesTo string

The URI which the access token applies to.

action string

The request action.

timeout TimeSpan

The time span that specifies the timeout value for the message that gets the security token.

callback AsyncCallback

An AsyncCallback delegate that references the method to invoke when the operation is complete.

state object

A user-defined object that contains state information about the asynchronous operation.

Returns

IAsyncResult

The result of the operation.

OnBeginGetWebToken(string, string, TimeSpan, AsyncCallback, object)

Executes upon calling the BeginGetWebToken method.

protected override IAsyncResult OnBeginGetWebToken(string appliesTo, string action, TimeSpan timeout, AsyncCallback callback, object state)

Parameters

appliesTo string

The URI which the access token applies to.

action string

The request action.

timeout TimeSpan

The time span that specifies the timeout value for the message that gets the security token.

callback AsyncCallback

An AsyncCallback delegate that references the method to invoke when the operation is complete.

state object

A user-defined object that contains state information about the asynchronous operation.

Returns

IAsyncResult

The result of the operation.

OnEndGetToken(IAsyncResult, out DateTime)

Executes upon calling the EndGetToken method.

protected override SecurityToken OnEndGetToken(IAsyncResult result, out DateTime cacheUntil)

Parameters

result IAsyncResult

An IAsyncResult object that references the asynchronous operation to get a token.

cacheUntil DateTime

When this method returns, contains the expiration date and time of the token information in the cache.

Returns

SecurityToken

The System.IdentityModel.Tokens.SecurityToken object.

OnEndGetWebToken(IAsyncResult, out DateTime)

Executes upon calling the EndGetWebToken method.

protected override string OnEndGetWebToken(IAsyncResult result, out DateTime cacheUntil)

Parameters

result IAsyncResult

An IAsyncResult object that references the asynchronous operation to get a web token.

cacheUntil DateTime

When this method returns, contains the expiration date and time of the token information in the cache.

Returns

string

The String that represents the web token.