diff options
Diffstat (limited to 'src')
12 files changed, 9 insertions, 269 deletions
diff --git a/src/DotNetOpenAuth/DotNetOpenAuth.csproj b/src/DotNetOpenAuth/DotNetOpenAuth.csproj index 9819396..84cbfcb 100644 --- a/src/DotNetOpenAuth/DotNetOpenAuth.csproj +++ b/src/DotNetOpenAuth/DotNetOpenAuth.csproj @@ -335,7 +335,6 @@ http://opensource.org/licenses/ms-pl.html <Compile Include="OAuth2\Messages\ClientCredentials\ClientCredentialsRequest.cs" /> <Compile Include="OAuth2\Messages\IAccessTokenSuccessResponse.cs" /> <Compile Include="OAuth2\Messages\IMessageWithClientState.cs" /> - <Compile Include="OAuth2\Messages\IOAuthDirectResponseFormat.cs" /> <Compile Include="OAuth2\Messages\RefreshAccessTokenRequest.cs" /> <Compile Include="OAuth2\Messages\Device\DeviceAccessTokenRequest.cs" /> <Compile Include="OAuth2\Messages\Device\DeviceRequest.cs" /> @@ -348,8 +347,6 @@ http://opensource.org/licenses/ms-pl.html <Compile Include="OAuth2\Messages\UserAgent\UserAgentSuccessResponse.cs" /> <Compile Include="OAuth2\Messages\UsernameAndPassword\UserNamePasswordCaptchaResponse.cs" /> <Compile Include="OAuth2\Messages\UsernameAndPassword\UserNamePasswordVerificationResponse.cs" /> - <Compile Include="OAuth2\Messages\ResponseFormat.cs" /> - <Compile Include="OAuth2\Messages\ResponseFormatEncoder.cs" /> <Compile Include="OAuth2\Messages\EndUserAuthorizationSuccessResponse.cs" /> <Compile Include="OAuth2\Messages\WebServer\WebServerRequest.cs" /> <Compile Include="OAuth2\ResourceServer.cs" /> diff --git a/src/DotNetOpenAuth/OAuth2/ChannelElements/OAuthWrapAuthorizationServerChannel.cs b/src/DotNetOpenAuth/OAuth2/ChannelElements/OAuthWrapAuthorizationServerChannel.cs index f837f93..ecc2cb3 100644 --- a/src/DotNetOpenAuth/OAuth2/ChannelElements/OAuthWrapAuthorizationServerChannel.cs +++ b/src/DotNetOpenAuth/OAuth2/ChannelElements/OAuthWrapAuthorizationServerChannel.cs @@ -128,29 +128,8 @@ namespace DotNetOpenAuth.OAuth2.ChannelElements { /// </remarks> protected override OutgoingWebResponse PrepareDirectResponse(IProtocolMessage response) { var webResponse = new OutgoingWebResponse(); - var fields = this.MessageDescriptions.GetAccessor(response); - - var directResponse = (IDirectResponseProtocolMessage)response; - var formatSpecifyingRequest = directResponse.OriginatingRequest as IOAuthDirectResponseFormat; - if (formatSpecifyingRequest != null) { - ResponseFormat format = formatSpecifyingRequest.Format; - switch (format) { - case ResponseFormat.Xml: - // NOTE: the spec is missing details on how to formulate this. - throw new NotImplementedException(); - case ResponseFormat.Form: - string form = MessagingUtilities.CreateQueryString(fields); - webResponse.SetResponse(form, HttpFormUrlEncodedContentType); - break; - case ResponseFormat.Json: - string json = this.SerializeAsJson(response); - webResponse.SetResponse(json, new ContentType(JsonEncoded)); - break; - default: - throw ErrorUtilities.ThrowInternal("Unrecognized value of ResponseFormat enum: " + format); - } - } - + string json = this.SerializeAsJson(response); + webResponse.SetResponse(json, new ContentType(JsonEncoded)); return webResponse; } diff --git a/src/DotNetOpenAuth/OAuth2/Messages/Assertion/AssertionRequest.cs b/src/DotNetOpenAuth/OAuth2/Messages/Assertion/AssertionRequest.cs index e3b000a..b986b14 100644 --- a/src/DotNetOpenAuth/OAuth2/Messages/Assertion/AssertionRequest.cs +++ b/src/DotNetOpenAuth/OAuth2/Messages/Assertion/AssertionRequest.cs @@ -15,7 +15,7 @@ namespace DotNetOpenAuth.OAuth2.Messages { /// <summary> /// A request from a Client to an Authorization Server with some assertion for an access token. /// </summary> - internal class AssertionRequest : MessageBase, IAccessTokenRequest, IOAuthDirectResponseFormat { + internal class AssertionRequest : MessageBase, IAccessTokenRequest { /// <summary> /// The type of message. /// </summary> @@ -66,14 +66,6 @@ namespace DotNetOpenAuth.OAuth2.Messages { public string SecretType { get; internal set; } /// <summary> - /// Gets the format the client is requesting the authorization server should deliver the request in. - /// </summary> - /// <value>The format.</value> - ResponseFormat IOAuthDirectResponseFormat.Format { - get { return this.Format.HasValue ? this.Format.Value : ResponseFormat.Json; } - } - - /// <summary> /// Gets or sets the format of the assertion as defined by the Authorization Server. /// </summary> /// <value>The assertion format.</value> @@ -88,13 +80,6 @@ namespace DotNetOpenAuth.OAuth2.Messages { internal string Assertion { get; set; } /// <summary> - /// Gets or sets the format the client is requesting the authorization server should deliver the request in. - /// </summary> - /// <value>The format.</value> - [MessagePart(Protocol.format, Encoder = typeof(ResponseFormatEncoder))] - private ResponseFormat? Format { get; set; } - - /// <summary> /// Checks the message state for conformity to the protocol specification /// and throws an exception if the message is invalid. /// </summary> diff --git a/src/DotNetOpenAuth/OAuth2/Messages/ClientCredentials/ClientCredentialsRequest.cs b/src/DotNetOpenAuth/OAuth2/Messages/ClientCredentials/ClientCredentialsRequest.cs index 3f5fc30..ced70a2 100644 --- a/src/DotNetOpenAuth/OAuth2/Messages/ClientCredentials/ClientCredentialsRequest.cs +++ b/src/DotNetOpenAuth/OAuth2/Messages/ClientCredentials/ClientCredentialsRequest.cs @@ -19,7 +19,7 @@ namespace DotNetOpenAuth.OAuth2.Messages { /// <remarks> /// This is somewhat analogous to 2-legged OAuth. /// </remarks> - internal class ClientCredentialsRequest : MessageBase, IAccessTokenRequest, IOAuthDirectResponseFormat { + internal class ClientCredentialsRequest : MessageBase, IAccessTokenRequest { /// <summary> /// Initializes a new instance of the <see cref="ClientCredentialsRequest"/> class. /// </summary> @@ -55,27 +55,12 @@ namespace DotNetOpenAuth.OAuth2.Messages { public string SecretType { get; set; } /// <summary> - /// Gets the format the client is requesting the authorization server should deliver the request in. - /// </summary> - /// <value>The format.</value> - ResponseFormat IOAuthDirectResponseFormat.Format { - get { return this.Format.HasValue ? this.Format.Value : ResponseFormat.Json; } - } - - /// <summary> /// Gets or sets an optional authorization scope as defined by the Authorization Server. /// </summary> [MessagePart(Protocol.scope, IsRequired = false, AllowEmpty = true)] internal string Scope { get; set; } /// <summary> - /// Gets or sets the format the client is requesting the authorization server should deliver the request in. - /// </summary> - /// <value>The format.</value> - [MessagePart(Protocol.format, Encoder = typeof(ResponseFormatEncoder))] - private ResponseFormat? Format { get; set; } - - /// <summary> /// Checks the message state for conformity to the protocol specification /// and throws an exception if the message is invalid. /// </summary> diff --git a/src/DotNetOpenAuth/OAuth2/Messages/Device/DeviceAccessTokenRequest.cs b/src/DotNetOpenAuth/OAuth2/Messages/Device/DeviceAccessTokenRequest.cs index 0e5dc06..8b45101 100644 --- a/src/DotNetOpenAuth/OAuth2/Messages/Device/DeviceAccessTokenRequest.cs +++ b/src/DotNetOpenAuth/OAuth2/Messages/Device/DeviceAccessTokenRequest.cs @@ -17,7 +17,7 @@ namespace DotNetOpenAuth.OAuth2.Messages { /// A message from the Client to the Authorization Server exchanging a /// verification code for refresh and access tokens. /// </summary> - internal class DeviceAccessTokenRequest : MessageBase, IAccessTokenRequest, IOAuthDirectResponseFormat { + internal class DeviceAccessTokenRequest : MessageBase, IAccessTokenRequest { /// <summary> /// A constant that identifies the flow this message belongs to. /// </summary> @@ -43,9 +43,6 @@ namespace DotNetOpenAuth.OAuth2.Messages { Contract.Requires<ArgumentNullException>(authorizationServer != null); Contract.Requires<ArgumentException>(authorizationServer.Version != null); Contract.Requires<ArgumentException>(authorizationServer.TokenEndpoint != null); - - // We prefer URL encoding of the data. - this.Format = ResponseFormat.Form; } /// <summary> @@ -74,14 +71,6 @@ namespace DotNetOpenAuth.OAuth2.Messages { public string SecretType { get; set; } /// <summary> - /// Gets the format the client is requesting the authorization server should deliver the request in. - /// </summary> - /// <value>The format.</value> - ResponseFormat IOAuthDirectResponseFormat.Format { - get { return this.Format.HasValue ? this.Format.Value : ResponseFormat.Json; } - } - - /// <summary> /// Gets or sets the verification code previously communicated to the Client /// in <see cref="DeviceResponse.VerificationCode"/>. /// </summary> @@ -90,13 +79,6 @@ namespace DotNetOpenAuth.OAuth2.Messages { internal string VerificationCode { get; set; } /// <summary> - /// Gets or sets the format the client is requesting the authorization server should deliver the request in. - /// </summary> - /// <value>The format.</value> - [MessagePart(Protocol.format, Encoder = typeof(ResponseFormatEncoder))] - private ResponseFormat? Format { get; set; } - - /// <summary> /// Checks the message state for conformity to the protocol specification /// and throws an exception if the message is invalid. /// </summary> diff --git a/src/DotNetOpenAuth/OAuth2/Messages/Device/DeviceRequest.cs b/src/DotNetOpenAuth/OAuth2/Messages/Device/DeviceRequest.cs index 568c194..ada8d56 100644 --- a/src/DotNetOpenAuth/OAuth2/Messages/Device/DeviceRequest.cs +++ b/src/DotNetOpenAuth/OAuth2/Messages/Device/DeviceRequest.cs @@ -16,7 +16,7 @@ namespace DotNetOpenAuth.OAuth2.Messages { /// A request from a rich app Client to an Authorization Server requested /// authorization to access user Protected Data. /// </summary> - internal class DeviceRequest : MessageBase, IOAuthDirectResponseFormat { + internal class DeviceRequest : MessageBase { /// <summary> /// A constant that identifies the type of message coming into the auth server. /// </summary> @@ -42,17 +42,6 @@ namespace DotNetOpenAuth.OAuth2.Messages { Contract.Requires<ArgumentNullException>(authorizationServer != null); Contract.Requires<ArgumentException>(authorizationServer.Version != null); Contract.Requires<ArgumentException>(authorizationServer.TokenEndpoint != null); - - // We prefer URL encoding of the data. - this.Format = ResponseFormat.Form; - } - - /// <summary> - /// Gets the format the client is requesting the authorization server should deliver the request in. - /// </summary> - /// <value>The format.</value> - ResponseFormat IOAuthDirectResponseFormat.Format { - get { return this.Format.HasValue ? this.Format.Value : ResponseFormat.Json; } } /// <summary> @@ -68,12 +57,5 @@ namespace DotNetOpenAuth.OAuth2.Messages { /// <value>The Authorization Server MAY define authorization scope values for the Client to include.</value> [MessagePart(Protocol.scope, IsRequired = false, AllowEmpty = true)] internal string Scope { get; set; } - - /// <summary> - /// Gets or sets the format the client is requesting the authorization server should deliver the request in. - /// </summary> - /// <value>The format.</value> - [MessagePart(Protocol.format, Encoder = typeof(ResponseFormatEncoder))] - private ResponseFormat? Format { get; set; } } } diff --git a/src/DotNetOpenAuth/OAuth2/Messages/IOAuthDirectResponseFormat.cs b/src/DotNetOpenAuth/OAuth2/Messages/IOAuthDirectResponseFormat.cs deleted file mode 100644 index 2b0d9a1..0000000 --- a/src/DotNetOpenAuth/OAuth2/Messages/IOAuthDirectResponseFormat.cs +++ /dev/null @@ -1,23 +0,0 @@ -//----------------------------------------------------------------------- -// <copyright file="IOAuthDirectResponseFormat.cs" company="Andrew Arnott"> -// Copyright (c) Andrew Arnott. All rights reserved. -// </copyright> -//----------------------------------------------------------------------- - -namespace DotNetOpenAuth.OAuth2.Messages { - using System; - using System.Collections.Generic; - using System.Linq; - using System.Text; - - /// <summary> - /// A message the includes a request for the format the response message should come in. - /// </summary> - internal interface IOAuthDirectResponseFormat { - /// <summary> - /// Gets the format the client is requesting the authorization server should deliver the request in. - /// </summary> - /// <value>The format.</value> - ResponseFormat Format { get; } - } -} diff --git a/src/DotNetOpenAuth/OAuth2/Messages/RefreshAccessTokenRequest.cs b/src/DotNetOpenAuth/OAuth2/Messages/RefreshAccessTokenRequest.cs index 746e287..a69636b 100644 --- a/src/DotNetOpenAuth/OAuth2/Messages/RefreshAccessTokenRequest.cs +++ b/src/DotNetOpenAuth/OAuth2/Messages/RefreshAccessTokenRequest.cs @@ -13,7 +13,7 @@ namespace DotNetOpenAuth.OAuth2.Messages { /// A request from the client to the token endpoint for a new access token /// in exchange for a refresh token that the client has previously obtained. /// </summary> - internal class RefreshAccessTokenRequest : MessageBase, IAccessTokenRequest, ITokenCarryingRequest, IOAuthDirectResponseFormat { + internal class RefreshAccessTokenRequest : MessageBase, IAccessTokenRequest, ITokenCarryingRequest { /// <summary> /// The type of message. /// </summary> @@ -27,8 +27,6 @@ namespace DotNetOpenAuth.OAuth2.Messages { /// <param name="version">The version.</param> internal RefreshAccessTokenRequest(Uri tokenEndpoint, Version version) : base(version, MessageTransport.Direct, tokenEndpoint) { - // We prefer URL encoding of the data. - this.Format = ResponseFormat.Form; } /// <summary> @@ -79,14 +77,6 @@ namespace DotNetOpenAuth.OAuth2.Messages { public string ClientSecret { get; set; } /// <summary> - /// Gets the format the client is requesting the authorization server should deliver the request in. - /// </summary> - /// <value>The format.</value> - ResponseFormat IOAuthDirectResponseFormat.Format { - get { return this.Format.HasValue ? this.Format.Value : ResponseFormat.Json; } - } - - /// <summary> /// Gets or sets the refresh token. /// </summary> /// <value>The refresh token.</value> @@ -95,12 +85,5 @@ namespace DotNetOpenAuth.OAuth2.Messages { /// </remarks> [MessagePart(Protocol.refresh_token, IsRequired = true, AllowEmpty = false)] internal string RefreshToken { get; set; } - - /// <summary> - /// Gets or sets the format the client is requesting the authorization server should deliver the request in. - /// </summary> - /// <value>The format.</value> - [MessagePart(Protocol.format, Encoder = typeof(ResponseFormatEncoder))] - private ResponseFormat? Format { get; set; } } } diff --git a/src/DotNetOpenAuth/OAuth2/Messages/ResponseFormat.cs b/src/DotNetOpenAuth/OAuth2/Messages/ResponseFormat.cs deleted file mode 100644 index 0ef36ed..0000000 --- a/src/DotNetOpenAuth/OAuth2/Messages/ResponseFormat.cs +++ /dev/null @@ -1,27 +0,0 @@ -//----------------------------------------------------------------------- -// <copyright file="ResponseFormat.cs" company="Andrew Arnott"> -// Copyright (c) Andrew Arnott. All rights reserved. -// </copyright> -//----------------------------------------------------------------------- - -namespace DotNetOpenAuth.OAuth2.Messages { - /// <summary> - /// The various formats a client can request a response to come in from an authorization server. - /// </summary> - public enum ResponseFormat { - /// <summary> - /// The response should be JSON encoded. - /// </summary> - Json, - - /// <summary> - /// The response should be XML encoded. - /// </summary> - Xml, - - /// <summary> - /// The response should be URL encoded. - /// </summary> - Form, - } -} diff --git a/src/DotNetOpenAuth/OAuth2/Messages/ResponseFormatEncoder.cs b/src/DotNetOpenAuth/OAuth2/Messages/ResponseFormatEncoder.cs deleted file mode 100644 index f84ecc1..0000000 --- a/src/DotNetOpenAuth/OAuth2/Messages/ResponseFormatEncoder.cs +++ /dev/null @@ -1,71 +0,0 @@ -//----------------------------------------------------------------------- -// <copyright file="ResponseFormatEncoder.cs" company="Andrew Arnott"> -// Copyright (c) Andrew Arnott. All rights reserved. -// </copyright> -//----------------------------------------------------------------------- - -namespace DotNetOpenAuth.OAuth2.Messages { - using System; - using System.Collections.Generic; - using System.Linq; - using System.Text; - using DotNetOpenAuth.Messaging; - using DotNetOpenAuth.Messaging.Reflection; - - /// <summary> - /// Provides encoding/decoding of the json/xml/form enum type. - /// </summary> - public class ResponseFormatEncoder : IMessagePartEncoder { - /// <summary> - /// Initializes a new instance of the <see cref="ResponseFormatEncoder"/> class. - /// </summary> - public ResponseFormatEncoder() { - } - - /// <summary> - /// Encodes the specified value. - /// </summary> - /// <param name="value">The value. Guaranteed to never be null.</param> - /// <returns> - /// The <paramref name="value"/> in string form, ready for message transport. - /// </returns> - public string Encode(object value) { - if (value == null) { - return null; - } - - var format = (ResponseFormat)value; - switch (format) { - case ResponseFormat.Xml: - return Protocol.ResponseFormats.Xml; - case ResponseFormat.Json: - return Protocol.ResponseFormats.Json; - case ResponseFormat.Form: - return Protocol.ResponseFormats.Form; - default: - throw new ArgumentOutOfRangeException("value"); - } - } - - /// <summary> - /// Decodes the specified value. - /// </summary> - /// <param name="value">The string value carried by the transport. Guaranteed to never be null, although it may be empty.</param> - /// <returns> - /// The deserialized form of the given string. - /// </returns> - /// <exception cref="FormatException">Thrown when the string value given cannot be decoded into the required object type.</exception> - public object Decode(string value) { - switch (value) { - case Protocol.ResponseFormats.Xml: - return ResponseFormat.Xml; - case Protocol.ResponseFormats.Json: - return ResponseFormat.Json; - case Protocol.ResponseFormats.Form: - return ResponseFormat.Form; - default: - throw new ArgumentOutOfRangeException("value"); - } - } - } -} diff --git a/src/DotNetOpenAuth/OAuth2/Messages/UsernameAndPassword/UserNamePasswordRequest.cs b/src/DotNetOpenAuth/OAuth2/Messages/UsernameAndPassword/UserNamePasswordRequest.cs index 98bb1d9..e8d1d92 100644 --- a/src/DotNetOpenAuth/OAuth2/Messages/UsernameAndPassword/UserNamePasswordRequest.cs +++ b/src/DotNetOpenAuth/OAuth2/Messages/UsernameAndPassword/UserNamePasswordRequest.cs @@ -21,7 +21,7 @@ namespace DotNetOpenAuth.OAuth2.Messages { /// After this request has been sent, the consumer application MUST discard /// the confidential user credentials and use the delegation code going forward. /// </remarks> - internal class UserNamePasswordRequest : MessageBase, IAccessTokenRequest, IOAuthDirectResponseFormat { + internal class UserNamePasswordRequest : MessageBase, IAccessTokenRequest { /// <summary> /// A constant that identifies the flow this request belongs to. /// </summary> @@ -47,9 +47,6 @@ namespace DotNetOpenAuth.OAuth2.Messages { Contract.Requires<ArgumentNullException>(authorizationServer != null); Contract.Requires<ArgumentException>(authorizationServer.Version != null); Contract.Requires<ArgumentException>(authorizationServer.TokenEndpoint != null); - - // We prefer URL encoding of the data. - this.Format = ResponseFormat.Form; } /// <summary> @@ -80,14 +77,6 @@ namespace DotNetOpenAuth.OAuth2.Messages { public string SecretType { get; set; } /// <summary> - /// Gets the format the client is requesting the authorization server should deliver the request in. - /// </summary> - /// <value>The format.</value> - ResponseFormat IOAuthDirectResponseFormat.Format { - get { return this.Format.HasValue ? this.Format.Value : ResponseFormat.Json; } - } - - /// <summary> /// Gets or sets the user's account username. /// </summary> /// <value>The username on the user's account.</value> @@ -123,13 +112,6 @@ namespace DotNetOpenAuth.OAuth2.Messages { internal string Scope { get; set; } /// <summary> - /// Gets or sets the format the client is requesting the authorization server should deliver the request in. - /// </summary> - /// <value>The format.</value> - [MessagePart(Protocol.format, Encoder = typeof(ResponseFormatEncoder))] - private ResponseFormat? Format { get; set; } - - /// <summary> /// Checks the message state for conformity to the protocol specification /// and throws an exception if the message is invalid. /// </summary> diff --git a/src/DotNetOpenAuth/OAuth2/Messages/WebServer/WebServerAccessTokenRequest.cs b/src/DotNetOpenAuth/OAuth2/Messages/WebServer/WebServerAccessTokenRequest.cs index 323d6de..e32d77b 100644 --- a/src/DotNetOpenAuth/OAuth2/Messages/WebServer/WebServerAccessTokenRequest.cs +++ b/src/DotNetOpenAuth/OAuth2/Messages/WebServer/WebServerAccessTokenRequest.cs @@ -18,7 +18,7 @@ namespace DotNetOpenAuth.OAuth2.Messages { /// <remarks> /// Used by the Web App (and Rich App?) profiles. /// </remarks> - internal class WebServerAccessTokenRequest : MessageBase, IAccessTokenRequest, ITokenCarryingRequest, IOAuthDirectResponseFormat { + internal class WebServerAccessTokenRequest : MessageBase, IAccessTokenRequest, ITokenCarryingRequest { /// <summary> /// The type of message. /// </summary> @@ -44,9 +44,6 @@ namespace DotNetOpenAuth.OAuth2.Messages { Contract.Requires<ArgumentNullException>(authorizationServer != null); Contract.Requires<ArgumentException>(authorizationServer.Version != null); Contract.Requires<ArgumentException>(authorizationServer.TokenEndpoint != null); - - // We prefer URL encoding of the data. - this.Format = ResponseFormat.Form; } /// <summary> @@ -98,10 +95,6 @@ namespace DotNetOpenAuth.OAuth2.Messages { [MessagePart(Protocol.secret_type, IsRequired = false, AllowEmpty = false)] public string SecretType { get; set; } - ResponseFormat IOAuthDirectResponseFormat.Format { - get { return this.Format.HasValue ? this.Format.Value : ResponseFormat.Json; } - } - /// <summary> /// Gets or sets the verification code previously communicated to the Client /// in <see cref="WebServerSuccessResponse.VerificationCode"/>. @@ -120,13 +113,6 @@ namespace DotNetOpenAuth.OAuth2.Messages { internal Uri Callback { get; set; } /// <summary> - /// Gets or sets the format the client is requesting the authorization server should deliver the request in. - /// </summary> - /// <value>The format.</value> - [MessagePart(Protocol.format, Encoder = typeof(ResponseFormatEncoder))] - private ResponseFormat? Format { get; set; } - - /// <summary> /// Checks the message state for conformity to the protocol specification /// and throws an exception if the message is invalid. /// </summary> |