//----------------------------------------------------------------------- // // Copyright (c) Outercurve Foundation. All rights reserved. // //----------------------------------------------------------------------- namespace DotNetOpenAuth.OAuth2.Messages { using System; using System.Collections.Generic; using System.Linq; using System.Text; using DotNetOpenAuth.Messaging; using DotNetOpenAuth.OAuth2.ChannelElements; /// /// A request for an access token for a client application that has its /// own (non-user affiliated) client name and password. /// /// /// This is somewhat analogous to 2-legged OAuth. /// internal class AccessTokenClientCredentialsRequest : ScopedAccessTokenRequest, IAuthorizationCarryingRequest, IAuthorizationDescription { /// /// Initializes a new instance of the class. /// /// The authorization server. /// The version. internal AccessTokenClientCredentialsRequest(Uri tokenEndpoint, Version version) : base(tokenEndpoint, version) { this.HttpMethods = HttpDeliveryMethods.PostRequest; } #region IAuthorizationCarryingRequest members /// /// Gets the authorization that the code or token describes. /// IAuthorizationDescription IAuthorizationCarryingRequest.AuthorizationDescription { get { return this.CredentialsValidated ? this : null; } } #endregion #region IAuthorizationDescription Members /// /// Gets the date this authorization was established or the token was issued. /// /// A date/time expressed in UTC. DateTime IAuthorizationDescription.UtcIssued { get { return DateTime.UtcNow; } } /// /// Gets the name on the account whose data on the resource server is accessible using this authorization. /// string IAuthorizationDescription.User { get { return null; } } /// /// Gets the scope of operations the client is allowed to invoke. /// HashSet IAuthorizationDescription.Scope { get { return this.Scope; } } #endregion /// /// Gets the type of the grant. /// /// The type of the grant. internal override GrantType GrantType { get { return Messages.GrantType.ClientCredentials; } } /// /// Gets or sets a value indicating whether the resource owner's credentials have been validated at the authorization server. /// internal bool CredentialsValidated { get; set; } } }