summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew Arnott <andrewarnott@gmail.com>2011-07-11 06:52:30 -0700
committerAndrew Arnott <andrewarnott@gmail.com>2011-07-11 06:52:30 -0700
commitda851e98f33f76e2937ac193f3f529c088b9425a (patch)
tree25dac91167e313916973616cf975e990a63ede2a
parentea9d0bb76e032b35ab290f10bd2267c2bdc768c9 (diff)
downloadDotNetOpenAuth-da851e98f33f76e2937ac193f3f529c088b9425a.zip
DotNetOpenAuth-da851e98f33f76e2937ac193f3f529c088b9425a.tar.gz
DotNetOpenAuth-da851e98f33f76e2937ac193f3f529c088b9425a.tar.bz2
Functionality and one sample is fixed up enough to permit an OpenID login to complete successfully.
-rw-r--r--samples/OpenIdRelyingPartyWebForms/Default.aspx2
-rw-r--r--src/DotNetOpenAuth.Messaging/Messaging/Reflection/MessagePart.cs14
-rw-r--r--src/DotNetOpenAuth.OpenId/OpenId/Identifier.cs13
-rw-r--r--src/DotNetOpenAuth.OpenId/OpenId/Realm.cs12
4 files changed, 28 insertions, 13 deletions
diff --git a/samples/OpenIdRelyingPartyWebForms/Default.aspx b/samples/OpenIdRelyingPartyWebForms/Default.aspx
index 602d5ed..3119fae 100644
--- a/samples/OpenIdRelyingPartyWebForms/Default.aspx
+++ b/samples/OpenIdRelyingPartyWebForms/Default.aspx
@@ -1,6 +1,6 @@
<%@ Page Language="C#" AutoEventWireup="true" MasterPageFile="~/Site.Master" %>
-<%@ Register Assembly="DotNetOpenAuth" Namespace="DotNetOpenAuth" TagPrefix="openid" %>
+<%@ Register Assembly="DotNetOpenAuth.OpenId" Namespace="DotNetOpenAuth" TagPrefix="openid" %>
<asp:Content runat="server" ContentPlaceHolderID="head">
<openid:XrdsPublisher ID="XrdsPublisher1" runat="server" XrdsUrl="~/xrds.aspx" />
</asp:Content>
diff --git a/src/DotNetOpenAuth.Messaging/Messaging/Reflection/MessagePart.cs b/src/DotNetOpenAuth.Messaging/Messaging/Reflection/MessagePart.cs
index e0e48fe..80ceefd 100644
--- a/src/DotNetOpenAuth.Messaging/Messaging/Reflection/MessagePart.cs
+++ b/src/DotNetOpenAuth.Messaging/Messaging/Reflection/MessagePart.cs
@@ -73,11 +73,7 @@ namespace DotNetOpenAuth.Messaging.Reflection {
Contract.Assume(str != null);
return bool.Parse(str);
};
- ////Func<string, Identifier> safeIdentifier = str => {
- //// Contract.Assume(str != null);
- //// ErrorUtilities.VerifyFormat(str.Length > 0, MessagingStrings.NonEmptyStringExpected);
- //// return Identifier.Parse(str, true);
- ////};
+
Func<byte[], string> safeFromByteArray = bytes => {
Contract.Assume(bytes != null);
return Convert.ToBase64String(bytes);
@@ -86,16 +82,10 @@ namespace DotNetOpenAuth.Messaging.Reflection {
Contract.Assume(str != null);
return Convert.FromBase64String(str);
};
- ////Func<string, Realm> safeRealm = str => {
- //// Contract.Assume(str != null);
- //// return new Realm(str);
- ////};
Map<Uri>(uri => uri.AbsoluteUri, uri => uri.OriginalString, safeUri);
Map<DateTime>(dt => XmlConvert.ToString(dt, XmlDateTimeSerializationMode.Utc), null, str => XmlConvert.ToDateTime(str, XmlDateTimeSerializationMode.Utc));
Map<TimeSpan>(ts => ts.ToString(), null, str => TimeSpan.Parse(str));
Map<byte[]>(safeFromByteArray, null, safeToByteArray);
- ////Map<Realm>(realm => realm.ToString(), realm => realm.OriginalString, safeRealm);
- ////Map<Identifier>(id => id.SerializedString, id => id.OriginalString, safeIdentifier);
Map<bool>(value => value.ToString().ToLowerInvariant(), null, safeBool);
Map<CultureInfo>(c => c.Name, null, str => new CultureInfo(str));
Map<CultureInfo[]>(cs => string.Join(",", cs.Select(c => c.Name).ToArray()), null, str => str.Split(',').Select(s => new CultureInfo(s)).ToArray());
@@ -316,7 +306,7 @@ namespace DotNetOpenAuth.Messaging.Reflection {
/// <param name="toOriginalString">The mapping function that converts some custom value to its original (non-normalized) string. May be null if the same as the <paramref name="toString"/> function.</param>
/// <param name="toValue">The function to convert a string to the custom type.</param>
[SuppressMessage("Microsoft.Globalization", "CA1303:Do not pass literals as localized parameters", MessageId = "System.Diagnostics.Contracts.__ContractsRuntime.Requires<System.ArgumentNullException>(System.Boolean,System.String,System.String)", Justification = "Code contracts"), SuppressMessage("Microsoft.Naming", "CA2204:Literals should be spelled correctly", MessageId = "toString", Justification = "Code contracts"), SuppressMessage("Microsoft.Naming", "CA2204:Literals should be spelled correctly", MessageId = "toValue", Justification = "Code contracts")]
- private static void Map<T>(Func<T, string> toString, Func<T, string> toOriginalString, Func<string, T> toValue) {
+ internal static void Map<T>(Func<T, string> toString, Func<T, string> toOriginalString, Func<string, T> toValue) {
Contract.Requires<ArgumentNullException>(toString != null);
Contract.Requires<ArgumentNullException>(toValue != null);
diff --git a/src/DotNetOpenAuth.OpenId/OpenId/Identifier.cs b/src/DotNetOpenAuth.OpenId/OpenId/Identifier.cs
index 305976a..2d919ea 100644
--- a/src/DotNetOpenAuth.OpenId/OpenId/Identifier.cs
+++ b/src/DotNetOpenAuth.OpenId/OpenId/Identifier.cs
@@ -12,6 +12,7 @@ namespace DotNetOpenAuth.OpenId {
using System.Diagnostics.Contracts;
using DotNetOpenAuth.Messaging;
using DotNetOpenAuth.OpenId.RelyingParty;
+ using DotNetOpenAuth.Messaging.Reflection;
/// <summary>
/// An Identifier is either a "http" or "https" URI, or an XRI.
@@ -22,6 +23,18 @@ namespace DotNetOpenAuth.OpenId {
[ContractClass(typeof(IdentifierContract))]
public abstract class Identifier {
/// <summary>
+ /// Initializes the <see cref="Identifier"/> class.
+ /// </summary>
+ static Identifier() {
+ Func<string, Identifier> safeIdentifier = str => {
+ Contract.Assume(str != null);
+ ErrorUtilities.VerifyFormat(str.Length > 0, MessagingStrings.NonEmptyStringExpected);
+ return Identifier.Parse(str, true);
+ };
+ MessagePart.Map<Identifier>(id => id.SerializedString, id => id.OriginalString, safeIdentifier);
+ }
+
+ /// <summary>
/// Initializes a new instance of the <see cref="Identifier"/> class.
/// </summary>
/// <param name="originalString">The original string before any normalization.</param>
diff --git a/src/DotNetOpenAuth.OpenId/OpenId/Realm.cs b/src/DotNetOpenAuth.OpenId/OpenId/Realm.cs
index 98e3598..0b4205b 100644
--- a/src/DotNetOpenAuth.OpenId/OpenId/Realm.cs
+++ b/src/DotNetOpenAuth.OpenId/OpenId/Realm.cs
@@ -18,6 +18,7 @@ namespace DotNetOpenAuth.OpenId {
using DotNetOpenAuth.Messaging;
using DotNetOpenAuth.Xrds;
using DotNetOpenAuth.Yadis;
+ using DotNetOpenAuth.Messaging.Reflection;
/// <summary>
/// A trust root to validate requests and match return URLs against.
@@ -58,6 +59,17 @@ namespace DotNetOpenAuth.OpenId {
private Uri uri;
/// <summary>
+ /// Initializes the <see cref="Realm"/> class.
+ /// </summary>
+ static Realm() {
+ Func<string, Realm> safeRealm = str => {
+ Contract.Assume(str != null);
+ return new Realm(str);
+ };
+ MessagePart.Map<Realm>(realm => realm.ToString(), realm => realm.OriginalString, safeRealm);
+ }
+
+ /// <summary>
/// Initializes a new instance of the <see cref="Realm"/> class.
/// </summary>
/// <param name="realmUrl">The realm URL to use in the new instance.</param>