summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew Arnott <andrewarnott@gmail.com>2010-02-08 07:50:17 -0800
committerAndrew Arnott <andrewarnott@gmail.com>2010-02-08 07:50:17 -0800
commitab6e22c64b6867736a334f29ec47bd6723747a54 (patch)
tree3db5541ed897933fd93bf3867f83e6aae35d9e9b
parent20a17753b6941e3e0d37152c2b5012e1bc2d16cf (diff)
downloadDotNetOpenAuth-ab6e22c64b6867736a334f29ec47bd6723747a54.zip
DotNetOpenAuth-ab6e22c64b6867736a334f29ec47bd6723747a54.tar.gz
DotNetOpenAuth-ab6e22c64b6867736a334f29ec47bd6723747a54.tar.bz2
Updated the AuthorizationServerDescription (and Protocol) classes to fit the spec.
-rw-r--r--src/DotNetOpenAuth/OAuthWrap/AuthorizationServerDescription.cs41
-rw-r--r--src/DotNetOpenAuth/OAuthWrap/Protocol.cs61
2 files changed, 82 insertions, 20 deletions
diff --git a/src/DotNetOpenAuth/OAuthWrap/AuthorizationServerDescription.cs b/src/DotNetOpenAuth/OAuthWrap/AuthorizationServerDescription.cs
index 7549fd0..5e7c361 100644
--- a/src/DotNetOpenAuth/OAuthWrap/AuthorizationServerDescription.cs
+++ b/src/DotNetOpenAuth/OAuthWrap/AuthorizationServerDescription.cs
@@ -18,28 +18,47 @@ namespace DotNetOpenAuth.OAuthWrap {
/// Initializes a new instance of the <see cref="AuthorizationServerDescription"/> class.
/// </summary>
public AuthorizationServerDescription() {
- this.Version = Protocol.DefaultVersion;
+ this.ProtocolVersion = Protocol.Default.ProtocolVersion;
}
/// <summary>
- /// Initializes a new instance of the <see cref="AuthorizationServerDescription"/> class.
+ /// Gets or sets the Authorization Server URL at which an Access Token is requested by the Client.
+ /// A refresh token may also be returned to the Client.
/// </summary>
- /// <param name="endpointUrl">The endpoint URL of the Authorization Server.</param>
- public AuthorizationServerDescription(Uri endpointUrl)
- : this() {
- this.EndpointUrl = endpointUrl;
- }
+ /// <value>An HTTPS URL.</value>
+ /// <remarks>
+ /// Messages sent to this URL must always be sent by the POST HTTP method.
+ /// </remarks>
+ public Uri AccessTokenEndpoint { get; set; }
+
+ /// <summary>
+ /// Gets or sets the Authorization Server URL at which a Refresh Token is presented in exchange
+ /// for a new Access Token.
+ /// </summary>
+ /// <value>An HTTPS URL.</value>
+ /// <remarks>
+ /// Messages sent to this URL must always be sent by the POST HTTP method.
+ /// </remarks>
+ public Uri RefreshTokenEndpoint { get; set; }
/// <summary>
- /// Gets or sets the endpoint URL of the Authorization Server.
+ /// Gets or sets the Authorization Server URL where the Client (re)directs the User
+ /// to make an authorization request.
/// </summary>
- /// <value>The endpoint URL.</value>
- public Uri EndpointUrl { get; set; }
+ /// <value>An HTTP or HTTPS URL.</value>
+ public Uri UserAuthorizationEndpoint { get; set; }
+
+ /// <summary>
+ /// Gets or sets the OAuth WRAP version supported by the Authorization Server.
+ /// </summary>
+ public ProtocolVersion ProtocolVersion { get; set; }
/// <summary>
/// Gets or sets the version of the OAuth WRAP protocol to use with this Authorization Server.
/// </summary>
/// <value>The version.</value>
- public Version Version { get; set; }
+ internal Version Version {
+ get { return Protocol.Lookup(this.ProtocolVersion).Version; }
+ }
}
}
diff --git a/src/DotNetOpenAuth/OAuthWrap/Protocol.cs b/src/DotNetOpenAuth/OAuthWrap/Protocol.cs
index fc2131b..aa8c19b 100644
--- a/src/DotNetOpenAuth/OAuthWrap/Protocol.cs
+++ b/src/DotNetOpenAuth/OAuthWrap/Protocol.cs
@@ -7,21 +7,22 @@
namespace DotNetOpenAuth.OAuthWrap {
using System;
+ using System.Collections.Generic;
/// <summary>
- /// Protocol constants for OAuth WRAP.
+ /// An enumeration of the OAuth WRAP protocol versions supported by this library.
/// </summary>
- internal class Protocol {
+ public enum ProtocolVersion {
/// <summary>
- /// The default (latest) version of the OAuth WRAP protocol.
+ /// The OAuth WRAP 1.0 specification.
/// </summary>
- internal static readonly Version DefaultVersion = V10;
-
- /// <summary>
- /// The initial (1.0) version of OAuth WRAP.
- /// </summary>
- internal static readonly Version V10 = new Version(1, 0);
+ V10,
+ }
+ /// <summary>
+ /// Protocol constants for OAuth WRAP.
+ /// </summary>
+ internal class Protocol {
/// <summary>
/// The HTTP authorization scheme "WRAP";
/// </summary>
@@ -136,5 +137,47 @@ namespace DotNetOpenAuth.OAuthWrap {
/// The "user_denied" string.
/// </summary>
internal const string user_denied = "user_denied";
+
+ /// <summary>
+ /// Gets the <see cref="Protocol"/> instance with values initialized for V1.0 of the protocol.
+ /// </summary>
+ internal static readonly Protocol V10 = new Protocol {
+ Version = new Version(1, 0),
+ ProtocolVersion = ProtocolVersion.V10,
+ };
+
+ /// <summary>
+ /// A list of all supported OAuth versions, in order starting from newest version.
+ /// </summary>
+ internal static readonly List<Protocol> AllVersions = new List<Protocol>() { V10 };
+
+ /// <summary>
+ /// The default (or most recent) supported version of the OpenID protocol.
+ /// </summary>
+ internal static readonly Protocol Default = AllVersions[0];
+
+ /// <summary>
+ /// Gets or sets the OAuth WRAP version represented by this instance.
+ /// </summary>
+ /// <value>The version.</value>
+ internal Version Version { get; private set; }
+
+ /// <summary>
+ /// Gets or sets the OAuth WRAP version represented by this instance.
+ /// </summary>
+ /// <value>The protocol version.</value>
+ internal ProtocolVersion ProtocolVersion { get; private set; }
+
+ /// <summary>
+ /// Gets the OAuth Protocol instance to use for the given version.
+ /// </summary>
+ /// <param name="version">The OAuth version to get.</param>
+ /// <returns>A matching <see cref="Protocol"/> instance.</returns>
+ public static Protocol Lookup(ProtocolVersion version) {
+ switch (version) {
+ case ProtocolVersion.V10: return Protocol.V10;
+ default: throw new ArgumentOutOfRangeException("version");
+ }
+ }
}
}