//----------------------------------------------------------------------- // // Copyright (c) Outercurve Foundation. All rights reserved. // //----------------------------------------------------------------------- namespace DotNetOpenAuth.OAuth2.Messages { using System; using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; using System.Security.Cryptography; using DotNetOpenAuth.Messaging; using DotNetOpenAuth.OAuth2.ChannelElements; using Validation; /// /// The message sent by the Authorization Server to the Client via the user agent /// to indicate that user authorization was granted, and to return the user /// to the Client where they started their experience. /// public abstract class EndUserAuthorizationSuccessResponseBase : MessageBase, IMessageWithClientState { /// /// 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 EndUserAuthorizationSuccessResponseBase(Uri clientCallback, Version version) : base(version, MessageTransport.Indirect, clientCallback) { Requires.NotNull(version, "version"); Requires.NotNull(clientCallback, "clientCallback"); this.Scope = new HashSet(OAuthUtilities.ScopeStringComparer); } /// /// 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 EndUserAuthorizationSuccessResponseBase(Uri clientCallback, EndUserAuthorizationRequest request) : base(request, clientCallback) { Requires.NotNull(clientCallback, "clientCallback"); Requires.NotNull(request, "request"); ((IMessageWithClientState)this).ClientState = request.ClientState; this.Scope = new HashSet(OAuthUtilities.ScopeStringComparer); this.Scope.ResetContents(request.Scope); } /// /// Gets or sets some state as provided by the client in the authorization request. /// /// An opaque value defined by the client. /// /// REQUIRED if the Client sent the value in the . /// [MessagePart(Protocol.state, IsRequired = false)] string IMessageWithClientState.ClientState { get; set; } /// /// Gets or sets the scope of the if one is given; otherwise the scope of the authorization code. /// /// The scope. [SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly", Justification = "By design")] public ICollection Scope { get; protected set; } /// /// Gets or sets the authorizing user's account name. /// internal string AuthorizingUsername { get; set; } } }