//----------------------------------------------------------------------- // // Copyright (c) Outercurve Foundation. All rights reserved. // //----------------------------------------------------------------------- namespace DotNetOpenAuth.OAuth2 { using System; using System.Collections.Generic; using System.Linq; using System.Text; /// /// A default implementation of the interface. /// public class ClientDescription : IClientDescription { /// /// A delegate that determines whether the callback is allowed. /// private readonly Func isCallbackAllowed; /// /// Initializes a new instance of the class. /// /// The secret. /// The default callback. /// Type of the client. /// A delegate that determines whether the callback is allowed. public ClientDescription(string secret, Uri defaultCallback, ClientType clientType, Func isCallbackAllowed = null) { this.Secret = secret; this.DefaultCallback = defaultCallback; this.ClientType = clientType; this.isCallbackAllowed = isCallbackAllowed; } /// /// Gets the client secret. /// public string Secret { get; private set; } /// /// Gets the callback to use when an individual authorization request /// does not include an explicit callback URI. /// /// /// An absolute URL; or null if none is registered. /// public Uri DefaultCallback { get; private set; } /// /// Gets the type of the client. /// public ClientType ClientType { get; private set; } /// /// Determines whether a callback URI included in a client's authorization request /// is among those allowed callbacks for the registered client. /// /// The absolute URI the client has requested the authorization result be received at. /// /// true if the callback URL is allowable for this client; otherwise, false. /// public bool IsCallbackAllowed(Uri callback) { if (this.isCallbackAllowed != null) { return this.isCallbackAllowed(callback); } return EqualityComparer.Default.Equals(this.DefaultCallback, callback); } } }