//----------------------------------------------------------------------- // // Copyright (c) Outercurve Foundation. All rights reserved. // //----------------------------------------------------------------------- namespace DotNetOpenAuth.OAuth2.Messages { using System; using System.Diagnostics.Contracts; using DotNetOpenAuth.Messaging; using DotNetOpenAuth.OAuth2.ChannelElements; /// /// The message sent by the Authorization Server to the Client via the user agent /// to indicate that user authorization was granted, carrying an authorization code and possibly an access token, /// and to return the user to the Client where they started their experience. /// internal class EndUserAuthorizationSuccessAuthCodeResponse : EndUserAuthorizationSuccessResponseBase, IAuthorizationCodeCarryingRequest { /// /// Initializes a new instance of the class. /// /// The URL to redirect to so the client receives the message. This may not be built into the request message if the client pre-registered the URL with the authorization server. /// The protocol version. internal EndUserAuthorizationSuccessAuthCodeResponse(Uri clientCallback, Version version) : base(clientCallback, version) { Requires.NotNull(version, "version"); Requires.NotNull(clientCallback, "clientCallback"); } /// /// Initializes a new instance of the class. /// /// The URL to redirect to so the client receives the message. This may not be built into the request message if the client pre-registered the URL with the authorization server. /// The authorization request from the user agent on behalf of the client. internal EndUserAuthorizationSuccessAuthCodeResponse(Uri clientCallback, EndUserAuthorizationRequest request) : base(clientCallback, request) { Requires.NotNull(clientCallback, "clientCallback"); Requires.NotNull(request, "request"); ((IMessageWithClientState)this).ClientState = request.ClientState; } #region IAuthorizationCodeCarryingRequest Members /// /// Gets or sets the authorization code. /// string IAuthorizationCodeCarryingRequest.Code { get { return this.AuthorizationCode; } set { this.AuthorizationCode = value; } } /// /// Gets or sets the authorization that the token describes. /// AuthorizationCode IAuthorizationCodeCarryingRequest.AuthorizationDescription { get; set; } /// /// Gets the authorization that the code describes. /// IAuthorizationDescription IAuthorizationCarryingRequest.AuthorizationDescription { get { return ((IAuthorizationCodeCarryingRequest)this).AuthorizationDescription; } } #endregion /// /// Gets or sets the authorization code. /// /// The authorization code. [MessagePart(Protocol.code, IsRequired = true)] internal string AuthorizationCode { get; set; } } }