//----------------------------------------------------------------------- // // 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, IAuthorizationCarryingRequest { /// /// 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 IAuthorizationCarryingRequest Members /// /// Gets or sets the verification code or refresh/access token. /// /// The code or token. string IAuthorizationCarryingRequest.CodeOrToken { get { return this.AuthorizationCode; } set { this.AuthorizationCode = value; } } /// /// Gets the type of the code or token. /// /// The type of the code or token. CodeOrTokenType IAuthorizationCarryingRequest.CodeOrTokenType { get { return CodeOrTokenType.AuthorizationCode; } } /// /// Gets or sets the authorization that the token describes. /// IAuthorizationDescription IAuthorizationCarryingRequest.AuthorizationDescription { get; set; } #endregion /// /// Gets or sets the authorization code. /// /// The authorization code. [MessagePart(Protocol.code, IsRequired = true)] internal string AuthorizationCode { get; set; } } }