diff options
author | Andrew Arnott <andrewarnott@gmail.com> | 2008-04-15 21:15:24 -0700 |
---|---|---|
committer | Andrew Arnott <andrewarnott@gmail.com> | 2008-04-15 22:23:48 -0700 |
commit | ea36fd5a24e311cfa399fd36f86b7ec55113cc8f (patch) | |
tree | 42bf3c147a7c7adc9da0cd87b5c2d299943647a7 /src/DotNetOpenId/Extensions/AttributeExchangeStoreResponse.cs | |
parent | bedb0be63a15af113ce584b3e24f01a2b9daa1a1 (diff) | |
download | DotNetOpenAuth-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/AttributeExchangeStoreResponse.cs')
-rw-r--r-- | src/DotNetOpenId/Extensions/AttributeExchangeStoreResponse.cs | 37 |
1 files changed, 28 insertions, 9 deletions
diff --git a/src/DotNetOpenId/Extensions/AttributeExchangeStoreResponse.cs b/src/DotNetOpenId/Extensions/AttributeExchangeStoreResponse.cs index b28d2be..dbdbabd 100644 --- a/src/DotNetOpenId/Extensions/AttributeExchangeStoreResponse.cs +++ b/src/DotNetOpenId/Extensions/AttributeExchangeStoreResponse.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 Store message, response leg.
/// </summary>
- public struct AttributeExchangeStoreResponse {
- /// <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 AttributeExchangeStoreResponse : IExtensionResponse {
+ readonly string Mode = "store_response";
+
/// <summary>
/// Reads a Provider's response for Attribute Exchange values and returns
/// an instance of this struct with the values.
/// </summary>
public static AttributeExchangeStoreResponse ReadFromResponse(IAuthenticationResponse response) {
- throw new NotImplementedException();
+ var obj = new AttributeExchangeStoreResponse();
+ 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
}
}
|