diff options
Diffstat (limited to 'src/DotNetOpenId/Extensions/SimpleRegistration/ClaimsResponse.cs')
-rw-r--r-- | src/DotNetOpenId/Extensions/SimpleRegistration/ClaimsResponse.cs | 54 |
1 files changed, 49 insertions, 5 deletions
diff --git a/src/DotNetOpenId/Extensions/SimpleRegistration/ClaimsResponse.cs b/src/DotNetOpenId/Extensions/SimpleRegistration/ClaimsResponse.cs index 0203bce..5d31122 100644 --- a/src/DotNetOpenId/Extensions/SimpleRegistration/ClaimsResponse.cs +++ b/src/DotNetOpenId/Extensions/SimpleRegistration/ClaimsResponse.cs @@ -6,13 +6,12 @@ ********************************************************/
using System;
+using System.Collections.Generic;
using System.Globalization;
using System.Net.Mail;
-using DotNetOpenId.Extensions;
+using System.Text;
using System.Xml.Serialization;
using DotNetOpenId.RelyingParty;
-using DotNetOpenId.Provider;
-using System.Collections.Generic;
namespace DotNetOpenId.Extensions.SimpleRegistration
{
@@ -22,7 +21,7 @@ namespace DotNetOpenId.Extensions.SimpleRegistration /// authenticating user.
/// </summary>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2218:OverrideGetHashCodeOnOverridingEquals"), Serializable()]
- public sealed class ClaimsResponse : IExtensionResponse
+ public sealed class ClaimsResponse : IExtensionResponse, IClientScriptExtension
{
string typeUriToUse;
@@ -201,6 +200,52 @@ namespace DotNetOpenId.Extensions.SimpleRegistration #endregion
+ #region IClientScriptExtension Members
+
+ string createAddFieldJS(string propertyName, string value) {
+ return string.Format(CultureInfo.InvariantCulture, "{0}: '{1}',",
+ propertyName, Util.MakeSafeJavascriptValue(value));
+ }
+
+ string IClientScriptExtension.InitializeJavascriptData(IDictionary<string, string> sreg, IAuthenticationResponse response, string typeUri) {
+ StringBuilder builder = new StringBuilder();
+ builder.Append("{ ");
+
+ string nickname, email, fullName, dob, genderString, postalCode, country, language, timeZone;
+ if (sreg.TryGetValue(Constants.nickname, out nickname)) {
+ builder.Append(createAddFieldJS(Constants.nickname, nickname));
+ }
+ if (sreg.TryGetValue(Constants.email, out email)) {
+ builder.Append(createAddFieldJS(Constants.email, email));
+ }
+ if (sreg.TryGetValue(Constants.fullname, out fullName)) {
+ builder.Append(createAddFieldJS(Constants.fullname, fullName));
+ }
+ if (sreg.TryGetValue(Constants.dob, out dob)) {
+ builder.Append(createAddFieldJS(Constants.dob, dob));
+ }
+ if (sreg.TryGetValue(Constants.gender, out genderString)) {
+ builder.Append(createAddFieldJS(Constants.gender, genderString));
+ }
+ if (sreg.TryGetValue(Constants.postcode, out postalCode)) {
+ builder.Append(createAddFieldJS(Constants.postcode, postalCode));
+ }
+ if (sreg.TryGetValue(Constants.country, out country)) {
+ builder.Append(createAddFieldJS(Constants.country, country));
+ }
+ if (sreg.TryGetValue(Constants.language, out language)) {
+ builder.Append(createAddFieldJS(Constants.language, language));
+ }
+ if (sreg.TryGetValue(Constants.timezone, out timeZone)) {
+ builder.Append(createAddFieldJS(Constants.timezone, timeZone));
+ }
+
+ builder.Append("}");
+ return builder.ToString();
+ }
+
+ #endregion
+
/// <summary>
/// Tests equality of two <see cref="ClaimsResponse"/> objects.
/// </summary>
@@ -240,6 +285,5 @@ namespace DotNetOpenId.Extensions.SimpleRegistration if (one == null ^ other == null) return false;
return one.Equals(other);
}
-
}
}
\ No newline at end of file |