summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAndrew Arnott <andrewarnott@gmail.com>2010-06-05 21:50:32 -0700
committerAndrew Arnott <andrewarnott@gmail.com>2010-06-05 21:50:32 -0700
commit44b7be237574be25deb0815a423552d495a60efb (patch)
tree5b2f0a3f3da2be8511ec071c21276fa6cd08d485 /src
parent5771ee17eff3adf0a7968484ff089de739e6cafd (diff)
downloadDotNetOpenAuth-44b7be237574be25deb0815a423552d495a60efb.zip
DotNetOpenAuth-44b7be237574be25deb0815a423552d495a60efb.tar.gz
DotNetOpenAuth-44b7be237574be25deb0815a423552d495a60efb.tar.bz2
Updated the rest of the flows except for Device.
Diffstat (limited to 'src')
-rw-r--r--src/DotNetOpenAuth.Test/OAuthWrap/MessageFactoryTests.cs20
-rw-r--r--src/DotNetOpenAuth/DotNetOpenAuth.csproj1
-rw-r--r--src/DotNetOpenAuth/OAuthWrap/ChannelElements/OAuthWrapAuthorizationServerChannel.cs1
-rw-r--r--src/DotNetOpenAuth/OAuthWrap/Messages/Assertion/AssertionRequest.cs34
-rw-r--r--src/DotNetOpenAuth/OAuthWrap/Messages/Assertion/AssertionSuccessResponse.cs40
-rw-r--r--src/DotNetOpenAuth/OAuthWrap/Messages/UsernameAndPassword/UserNamePasswordVerificationResponse.cs2
-rw-r--r--src/DotNetOpenAuth/OAuthWrap/Protocol.cs17
7 files changed, 41 insertions, 74 deletions
diff --git a/src/DotNetOpenAuth.Test/OAuthWrap/MessageFactoryTests.cs b/src/DotNetOpenAuth.Test/OAuthWrap/MessageFactoryTests.cs
index 830c489..9b937c1 100644
--- a/src/DotNetOpenAuth.Test/OAuthWrap/MessageFactoryTests.cs
+++ b/src/DotNetOpenAuth.Test/OAuthWrap/MessageFactoryTests.cs
@@ -129,8 +129,7 @@ namespace DotNetOpenAuth.Test.OAuthWrap {
public void UserNamePasswordRequest() {
var fields = new Dictionary<string, string> {
{ Protocol.client_id, "abc" },
- { Protocol.wrap_username, "abc" },
- { Protocol.wrap_password, "abc" },
+ { Protocol.client_secret, "abc" },
};
IDirectedProtocolMessage request = this.messageFactory.GetNewRequestMessage(this.recipient, fields);
Assert.IsInstanceOf(typeof(UserNamePasswordRequest), request);
@@ -151,7 +150,7 @@ namespace DotNetOpenAuth.Test.OAuthWrap {
public void UserNamePasswordVerificationResponse() {
// HTTP 400 Bad Request
var fields = new Dictionary<string, string> {
- { Protocol.wrap_verification_url, "abc" },
+ { Protocol.code, "abc" },
};
var request = new UserNamePasswordRequest(this.recipient.Location, Protocol.Default.Version);
Assert.IsInstanceOf(
@@ -253,8 +252,8 @@ namespace DotNetOpenAuth.Test.OAuthWrap {
[TestCase]
public void ClientCredentialsRequest() {
var fields = new Dictionary<string, string> {
- { Protocol.wrap_name, "abc" },
- { Protocol.wrap_password, "abc" },
+ { Protocol.client_id, "abc" },
+ { Protocol.client_secret, "abc" },
};
IDirectedProtocolMessage request = this.messageFactory.GetNewRequestMessage(this.recipient, fields);
Assert.IsInstanceOf(typeof(ClientCredentialsRequest), request);
@@ -274,17 +273,6 @@ namespace DotNetOpenAuth.Test.OAuthWrap {
Assert.IsInstanceOf(typeof(AssertionRequest), request);
}
- [TestCase]
- public void AssertionSuccessResponse() {
- var fields = new Dictionary<string, string> {
- { Protocol.access_token, "abc" },
- };
- var request = new AssertionRequest(this.recipient.Location, Protocol.Default.Version);
- Assert.IsInstanceOf(
- typeof(AssertionSuccessResponse),
- this.messageFactory.GetNewResponseMessage(request, fields));
- }
-
#endregion
}
}
diff --git a/src/DotNetOpenAuth/DotNetOpenAuth.csproj b/src/DotNetOpenAuth/DotNetOpenAuth.csproj
index 40c196a..52472ff 100644
--- a/src/DotNetOpenAuth/DotNetOpenAuth.csproj
+++ b/src/DotNetOpenAuth/DotNetOpenAuth.csproj
@@ -331,7 +331,6 @@ http://opensource.org/licenses/ms-pl.html
<Compile Include="OAuthWrap\Messages\AccessProtectedResourceRequest.cs" />
<Compile Include="OAuthWrap\Messages\Assertion\AssertionRequest.cs" />
<Compile Include="OAuthWrap\Messages\ClientCredentials\ClientCredentialsRequest.cs" />
- <Compile Include="OAuthWrap\Messages\Assertion\AssertionSuccessResponse.cs" />
<Compile Include="OAuthWrap\Messages\IAccessTokenSuccessResponse.cs" />
<Compile Include="OAuthWrap\Messages\IMessageWithClientState.cs" />
<Compile Include="OAuthWrap\Messages\IOAuthDirectResponseFormat.cs" />
diff --git a/src/DotNetOpenAuth/OAuthWrap/ChannelElements/OAuthWrapAuthorizationServerChannel.cs b/src/DotNetOpenAuth/OAuthWrap/ChannelElements/OAuthWrapAuthorizationServerChannel.cs
index 252a44b..3ba7bac 100644
--- a/src/DotNetOpenAuth/OAuthWrap/ChannelElements/OAuthWrapAuthorizationServerChannel.cs
+++ b/src/DotNetOpenAuth/OAuthWrap/ChannelElements/OAuthWrapAuthorizationServerChannel.cs
@@ -31,7 +31,6 @@ namespace DotNetOpenAuth.OAuthWrap.ChannelElements {
typeof(Messages.AccessTokenFailedResponse),
typeof(Messages.UnauthorizedResponse),
typeof(Messages.AssertionRequest),
- typeof(Messages.AssertionSuccessResponse),
typeof(Messages.ClientCredentialsRequest),
typeof(Messages.RichAppRequest),
typeof(Messages.RichAppResponse),
diff --git a/src/DotNetOpenAuth/OAuthWrap/Messages/Assertion/AssertionRequest.cs b/src/DotNetOpenAuth/OAuthWrap/Messages/Assertion/AssertionRequest.cs
index 1024a3f..40d25bc 100644
--- a/src/DotNetOpenAuth/OAuthWrap/Messages/Assertion/AssertionRequest.cs
+++ b/src/DotNetOpenAuth/OAuthWrap/Messages/Assertion/AssertionRequest.cs
@@ -10,11 +10,13 @@ namespace DotNetOpenAuth.OAuthWrap.Messages {
using System.Linq;
using System.Text;
using DotNetOpenAuth.Messaging;
+ using DotNetOpenAuth.OAuthWrap.ChannelElements;
+ using DotNetOpenAuth.OAuthWrap.Messages.WebServer;
/// <summary>
/// A request from a Client to an Authorization Server with some assertion for an access token.
/// </summary>
- internal class AssertionRequest : MessageBase {
+ internal class AssertionRequest : MessageBase, IAccessTokenRequest, IOAuthDirectResponseFormat {
/// <summary>
/// The type of message.
/// </summary>
@@ -32,10 +34,27 @@ namespace DotNetOpenAuth.OAuthWrap.Messages {
}
/// <summary>
+ /// Gets or sets the identifier by which this client is known to the Authorization Server.
+ /// </summary>
+ /// <value>The client identifier.</value>
+ [MessagePart(Protocol.client_id, IsRequired = true, AllowEmpty = false)]
+ public string ClientIdentifier { get; set; }
+
+ /// <summary>
+ /// Gets or sets the client secret.
+ /// </summary>
+ /// <value>The client secret.</value>
+ /// <remarks>
+ /// REQUIRED if the client identifier has a matching secret. The client secret as described in Section 3.4 (Client Credentials).
+ /// </remarks>
+ [MessagePart(Protocol.client_secret, IsRequired = false, AllowEmpty = true)]
+ public string ClientSecret { get; set; }
+
+ /// <summary>
/// Gets or sets the format of the assertion as defined by the Authorization Server.
/// </summary>
/// <value>The assertion format.</value>
- [MessagePart(Protocol.format, IsRequired = true, AllowEmpty = false)]
+ [MessagePart(Protocol.assertion_format, IsRequired = true, AllowEmpty = false)]
internal string AssertionFormat { get; set; }
/// <summary>
@@ -49,7 +68,7 @@ namespace DotNetOpenAuth.OAuthWrap.Messages {
/// 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; }
+ public string Scope { get; internal set; }
/// <summary>
/// Gets or sets the type of the secret.
@@ -59,7 +78,14 @@ namespace DotNetOpenAuth.OAuthWrap.Messages {
/// OPTIONAL. The access token secret type as described by Section 5.3 (Cryptographic Tokens Requests). If omitted, the authorization server will issue a bearer token (an access token without a matching secret) as described by Section 5.2 (Bearer Token Requests).
/// </remarks>
[MessagePart(Protocol.secret_type, IsRequired = false, AllowEmpty = false)]
- internal string SecretType { get; set; }
+ public string SecretType { get; internal set; }
+
+ ResponseFormat IOAuthDirectResponseFormat.Format {
+ get { return this.Format.HasValue ? this.Format.Value : ResponseFormat.Json; }
+ }
+
+ [MessagePart(Protocol.format, Encoder = typeof(ResponseFormatEncoder))]
+ private ResponseFormat? Format { get; set; }
/// <summary>
/// Checks the message state for conformity to the protocol specification
diff --git a/src/DotNetOpenAuth/OAuthWrap/Messages/Assertion/AssertionSuccessResponse.cs b/src/DotNetOpenAuth/OAuthWrap/Messages/Assertion/AssertionSuccessResponse.cs
deleted file mode 100644
index 2dc6ca7..0000000
--- a/src/DotNetOpenAuth/OAuthWrap/Messages/Assertion/AssertionSuccessResponse.cs
+++ /dev/null
@@ -1,40 +0,0 @@
-//-----------------------------------------------------------------------
-// <copyright file="AssertionSuccessResponse.cs" company="Andrew Arnott">
-// Copyright (c) Andrew Arnott. All rights reserved.
-// </copyright>
-//-----------------------------------------------------------------------
-
-namespace DotNetOpenAuth.OAuthWrap.Messages {
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using DotNetOpenAuth.Messaging;
-
- /// <summary>
- /// A response from the Authorization Server to the Client containing an access code.
- /// </summary>
- internal class AssertionSuccessResponse : MessageBase {
- /// <summary>
- /// Initializes a new instance of the <see cref="AssertionSuccessResponse"/> class.
- /// </summary>
- /// <param name="request">The request.</param>
- internal AssertionSuccessResponse(ClientCredentialsRequest request)
- : base(request) {
- }
-
- /// <summary>
- /// Gets or sets the access token.
- /// </summary>
- /// <value>The access token.</value>
- [MessagePart(Protocol.access_token, IsRequired = true, AllowEmpty = false)]
- internal string AccessToken { get; set; }
-
- /// <summary>
- /// Gets or sets the lifetime of the access token.
- /// </summary>
- /// <value>The lifetime.</value>
- [MessagePart(Protocol.expires_in, IsRequired = false, Encoder = typeof(TimespanSecondsEncoder))]
- internal TimeSpan? Lifetime { get; set; }
- }
-}
diff --git a/src/DotNetOpenAuth/OAuthWrap/Messages/UsernameAndPassword/UserNamePasswordVerificationResponse.cs b/src/DotNetOpenAuth/OAuthWrap/Messages/UsernameAndPassword/UserNamePasswordVerificationResponse.cs
index 9b4602c..e24a200 100644
--- a/src/DotNetOpenAuth/OAuthWrap/Messages/UsernameAndPassword/UserNamePasswordVerificationResponse.cs
+++ b/src/DotNetOpenAuth/OAuthWrap/Messages/UsernameAndPassword/UserNamePasswordVerificationResponse.cs
@@ -49,7 +49,7 @@ namespace DotNetOpenAuth.OAuthWrap.Messages {
/// to complete some step to defeat automated attacks.
/// </summary>
/// <value>The verification URL.</value>
- [MessagePart(Protocol.wrap_verification_url, IsRequired = true, AllowEmpty = false)]
+ [MessagePart(Protocol.code, IsRequired = true, AllowEmpty = false)]
internal Uri VerificationUrl { get; set; }
}
}
diff --git a/src/DotNetOpenAuth/OAuthWrap/Protocol.cs b/src/DotNetOpenAuth/OAuthWrap/Protocol.cs
index 5249875..d42e4e2 100644
--- a/src/DotNetOpenAuth/OAuthWrap/Protocol.cs
+++ b/src/DotNetOpenAuth/OAuthWrap/Protocol.cs
@@ -89,7 +89,7 @@ namespace DotNetOpenAuth.OAuthWrap {
internal const string client_secret = "client_secret";
/// <summary>
- /// The "wrap_verification_code" string.
+ /// The "code" string.
/// </summary>
internal const string code = "code";
@@ -109,11 +109,6 @@ namespace DotNetOpenAuth.OAuthWrap {
internal const string interval = "interval";
/// <summary>
- /// The "wrap_verification_url" string.
- /// </summary>
- internal const string wrap_verification_url = "wrap_verification_url";
-
- /// <summary>
/// The "error" string.
/// </summary>
internal const string error = "error";
@@ -154,11 +149,6 @@ namespace DotNetOpenAuth.OAuthWrap {
internal const string password = "password";
/// <summary>
- /// The "wrap_name" string.
- /// </summary>
- internal const string wrap_name = "wrap_name";
-
- /// <summary>
/// The "format" string.
/// </summary>
internal const string format = "format";
@@ -169,6 +159,11 @@ namespace DotNetOpenAuth.OAuthWrap {
internal const string assertion = "assertion";
/// <summary>
+ /// The "assertion_format" string.
+ /// </summary>
+ internal const string assertion_format = "assertion_format";
+
+ /// <summary>
/// The "wrap_SAML" string.
/// </summary>
internal const string wrap_saml = "wrap_SAML";