Ejemplo n.º 1
0
 /// <summary>
 /// Closes the <see cref="HybridConnectionListener"/> using the provided timeout.
 /// </summary>
 /// <param name="timeout">A timeout to observe.</param>
 public async Task CloseAsync(TimeSpan timeout)
 {
     TimeoutHelper.ThrowIfNegativeArgument(timeout);
     using (var cts = new CancellationTokenSource(timeout))
     {
         await this.CloseAsync(cts.Token).ConfigureAwait(false);
     }
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Gets a <see cref="SecurityToken"/> for the given audience and duration.
        /// </summary>
        /// <param name="audience">The target audience for the security token.</param>
        /// <param name="validFor">How long the generated token should be valid for.</param>
        /// <returns>A Task returning the newly created SecurityToken.</returns>
        public Task <SecurityToken> GetTokenAsync(string audience, TimeSpan validFor)
        {
            if (string.IsNullOrEmpty(audience))
            {
                throw RelayEventSource.Log.ArgumentNull(nameof(audience), this);
            }

            TimeoutHelper.ThrowIfNegativeArgument(validFor, nameof(validFor));
            audience = NormalizeAudience(audience);
            return(this.OnGetTokenAsync(audience, validFor));
        }