summaryrefslogtreecommitdiffstats
path: root/src/DotNetOpenId/Extensions/AttributeExchangeFetchResponse.cs
diff options
context:
space:
mode:
authorAndrew Arnott <andrewarnott@gmail.com>2008-04-15 21:15:24 -0700
committerAndrew Arnott <andrewarnott@gmail.com>2008-04-15 22:23:48 -0700
commitea36fd5a24e311cfa399fd36f86b7ec55113cc8f (patch)
tree42bf3c147a7c7adc9da0cd87b5c2d299943647a7 /src/DotNetOpenId/Extensions/AttributeExchangeFetchResponse.cs
parentbedb0be63a15af113ce584b3e24f01a2b9daa1a1 (diff)
downloadDotNetOpenAuth-ea36fd5a24e311cfa399fd36f86b7ec55113cc8f.zip
DotNetOpenAuth-ea36fd5a24e311cfa399fd36f86b7ec55113cc8f.tar.gz
DotNetOpenAuth-ea36fd5a24e311cfa399fd36f86b7ec55113cc8f.tar.bz2
BREAKING CHANGE for SimpleRegistration extension, and other stuff.
* SimpleRegistration changed from struct to class. * SimpleRegistrationFieldValues.None and SimpleRegistrationRequestFields.None removed. * Semantic for extension classes that ReadFromRequest or ReadFromResponse and don't find any matching parameters changed from returning an empty struct to returning null. * Added framework for testing extensions. * Upgraded TestWeb project to .NET 3.5. * Built up bare framework for sending/receiving Attribute Exchange extension messages.
Diffstat (limited to 'src/DotNetOpenId/Extensions/AttributeExchangeFetchResponse.cs')
-rw-r--r--src/DotNetOpenId/Extensions/AttributeExchangeFetchResponse.cs37
1 files changed, 28 insertions, 9 deletions
diff --git a/src/DotNetOpenId/Extensions/AttributeExchangeFetchResponse.cs b/src/DotNetOpenId/Extensions/AttributeExchangeFetchResponse.cs
index 4e7dbc2..db72875 100644
--- a/src/DotNetOpenId/Extensions/AttributeExchangeFetchResponse.cs
+++ b/src/DotNetOpenId/Extensions/AttributeExchangeFetchResponse.cs
@@ -2,25 +2,44 @@
using System.Collections.Generic;
using System.Text;
using DotNetOpenId.RelyingParty;
+using System.Globalization;
namespace DotNetOpenId.Extensions {
/// <summary>
/// The Attribute Exchange Fetch message, response leg.
/// </summary>
- public struct AttributeExchangeFetchResponse {
- /// <summary>
- /// Adds the values of this struct to an authentication response being prepared
- /// by an OpenID Provider.
- /// </summary>
- public void AddToResponse(Provider.IAuthenticationRequest authenticationRequest) {
- throw new NotImplementedException();
- }
+ public class AttributeExchangeFetchResponse : IExtensionResponse {
+ readonly string Mode = "fetch_response";
+
/// <summary>
/// Reads a Provider's response for Attribute Exchange values and returns
/// an instance of this struct with the values.
/// </summary>
public static AttributeExchangeFetchResponse ReadFromResponse(IAuthenticationResponse response) {
- throw new NotImplementedException();
+ var obj = new AttributeExchangeFetchResponse();
+ return ((IExtensionResponse)obj).ReadFromResponse(response) ? obj : null;
+ }
+
+ #region IExtensionResponse Members
+ string IExtensionResponse.TypeUri { get { return Constants.ae.ns; } }
+
+ public void AddToResponse(Provider.IRequest authenticationRequest) {
+ var fields = new Dictionary<string, string> {
+ { "mode", Mode },
+ };
+ authenticationRequest.AddExtensionArguments(Constants.ae.ns, fields);
}
+
+ bool IExtensionResponse.ReadFromResponse(IAuthenticationResponse response) {
+ var fields = response.GetExtensionArguments(Constants.ae.ns);
+ if (fields == null) return false;
+ string mode;
+ fields.TryGetValue("mode", out mode);
+ if (mode != Mode) return false;
+
+ return true;
+ }
+
+ #endregion
}
}