summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAndrew Arnott <andrewarnott@gmail.com>2010-03-11 19:43:30 -0800
committerAndrew Arnott <andrewarnott@gmail.com>2010-03-11 19:43:30 -0800
commit70591c5219bbd8d3b3e5ecacccb0bfb588f219bf (patch)
treefc1ed5e2345de3d8a804c213768db39f852eeab1 /src
parent3e59a1a11629e5c994b90d404bbe7150be8d10b7 (diff)
downloadDotNetOpenAuth-70591c5219bbd8d3b3e5ecacccb0bfb588f219bf.zip
DotNetOpenAuth-70591c5219bbd8d3b3e5ecacccb0bfb588f219bf.tar.gz
DotNetOpenAuth-70591c5219bbd8d3b3e5ecacccb0bfb588f219bf.tar.bz2
StyleCop fixes.
Diffstat (limited to 'src')
-rw-r--r--src/DotNetOpenAuth/Mvc/OpenIdAjaxOptions.cs27
-rw-r--r--src/DotNetOpenAuth/Mvc/OpenIdHelper.cs131
-rw-r--r--src/DotNetOpenAuth/OpenId/RelyingParty/OpenIdRelyingPartyAjaxControlBase.cs10
-rw-r--r--src/DotNetOpenAuth/OpenId/RelyingParty/OpenIdSelector.cs4
4 files changed, 146 insertions, 26 deletions
diff --git a/src/DotNetOpenAuth/Mvc/OpenIdAjaxOptions.cs b/src/DotNetOpenAuth/Mvc/OpenIdAjaxOptions.cs
index 505165c..a412ef2 100644
--- a/src/DotNetOpenAuth/Mvc/OpenIdAjaxOptions.cs
+++ b/src/DotNetOpenAuth/Mvc/OpenIdAjaxOptions.cs
@@ -1,5 +1,5 @@
//-----------------------------------------------------------------------
-// <copyright file="OpenIdSelectorOptions.cs" company="Andrew Arnott">
+// <copyright file="OpenIdAjaxOptions.cs" company="Andrew Arnott">
// Copyright (c) Andrew Arnott. All rights reserved.
// </copyright>
//-----------------------------------------------------------------------
@@ -10,20 +10,45 @@ namespace DotNetOpenAuth.Mvc {
using System.Linq;
using System.Text;
+ /// <summary>
+ /// A set of customizations available for the scripts sent to the browser in AJAX OpenID scenarios.
+ /// </summary>
public class OpenIdAjaxOptions {
+ /// <summary>
+ /// Initializes a new instance of the <see cref="OpenIdAjaxOptions"/> class.
+ /// </summary>
public OpenIdAjaxOptions() {
this.AssertionHiddenFieldId = "openid_openidAuthData";
this.ReturnUrlHiddenFieldId = "ReturnUrl";
}
+ /// <summary>
+ /// Gets or sets the ID of the hidden field that should carry the positive assertion
+ /// until it is posted to the RP.
+ /// </summary>
public string AssertionHiddenFieldId { get; set; }
+ /// <summary>
+ /// Gets or sets the ID of the hidden field that should be set with the parent window/frame's URL
+ /// prior to posting the form with the positive assertion. Useful for jQuery popup dialogs.
+ /// </summary>
public string ReturnUrlHiddenFieldId { get; set; }
+ /// <summary>
+ /// Gets or sets the index of the form in the document.forms array on the browser that should
+ /// be submitted when the user is ready to send the positive assertion to the RP.
+ /// </summary>
public int FormIndex { get; set; }
+ /// <summary>
+ /// Gets or sets a value indicating whether to print diagnostic trace messages in the browser.
+ /// </summary>
public bool ShowDiagnosticTrace { get; set; }
+ /// <summary>
+ /// Gets or sets a value indicating whether to show all the "hidden" iframes that facilitate
+ /// asynchronous authentication of the user for diagnostic purposes.
+ /// </summary>
public bool ShowDiagnosticIFrame { get; set; }
}
}
diff --git a/src/DotNetOpenAuth/Mvc/OpenIdHelper.cs b/src/DotNetOpenAuth/Mvc/OpenIdHelper.cs
index effd635..cc03a49 100644
--- a/src/DotNetOpenAuth/Mvc/OpenIdHelper.cs
+++ b/src/DotNetOpenAuth/Mvc/OpenIdHelper.cs
@@ -21,11 +21,31 @@ namespace DotNetOpenAuth.Mvc {
using DotNetOpenAuth.OpenId;
using DotNetOpenAuth.OpenId.RelyingParty;
+ /// <summary>
+ /// Methods that generate HTML or Javascript for hosting AJAX OpenID "controls" on
+ /// ASP.NET MVC web sites.
+ /// </summary>
public static class OpenIdHelper {
+ /// <summary>
+ /// Emits a series of script import tags and some inline script to support the AJAX OpenID Selector.
+ /// </summary>
+ /// <param name="html">The <see cref="HtmlHelper"/> on the view.</param>
+ /// <param name="page">The page being rendered.</param>
+ /// <returns>HTML that should be sent directly to the browser.</returns>
public static string OpenIdSelectorScripts(this HtmlHelper html, Page page) {
return OpenIdSelectorScripts(html, page, null, null);
}
-
+
+ /// <summary>
+ /// Emits a series of script import tags and some inline script to support the AJAX OpenID Selector.
+ /// </summary>
+ /// <param name="html">The <see cref="HtmlHelper"/> on the view.</param>
+ /// <param name="page">The page being rendered.</param>
+ /// <param name="selectorOptions">An optional instance of an <see cref="OpenIdSelector"/> control, whose properties have been customized to express how this MVC control should be rendered.</param>
+ /// <param name="additionalOptions">An optional set of additional script customizations.</param>
+ /// <returns>
+ /// HTML that should be sent directly to the browser.
+ /// </returns>
public static string OpenIdSelectorScripts(this HtmlHelper html, Page page, OpenIdSelector selectorOptions, OpenIdAjaxOptions additionalOptions) {
Contract.Requires<ArgumentNullException>(html != null);
Contract.Requires<ArgumentNullException>(page != null);
@@ -42,21 +62,23 @@ namespace DotNetOpenAuth.Mvc {
StringWriter result = new StringWriter();
if (additionalOptions.ShowDiagnosticIFrame || additionalOptions.ShowDiagnosticTrace) {
+ string scriptFormat = @"window.openid_visible_iframe = {0}; // causes the hidden iframe to show up
+window.openid_trace = {1}; // causes lots of messages";
result.WriteScriptBlock(string.Format(
CultureInfo.InvariantCulture,
-@"window.openid_visible_iframe = {0}; // causes the hidden iframe to show up
-window.openid_trace = {1}; // causes lots of messages",
+ scriptFormat,
additionalOptions.ShowDiagnosticIFrame ? "true" : "false",
additionalOptions.ShowDiagnosticTrace ? "true" : "false"));
}
- result.WriteScriptTags(page, new[] {
- OpenIdRelyingPartyControlBase.EmbeddedJavascriptResource,
- OpenIdRelyingPartyAjaxControlBase.EmbeddedAjaxJavascriptResource,
- OpenId.RelyingParty.OpenIdAjaxTextBox.EmbeddedScriptResourceName,
- });
+ var scriptResources = new[] {
+ OpenIdRelyingPartyControlBase.EmbeddedJavascriptResource,
+ OpenIdRelyingPartyAjaxControlBase.EmbeddedAjaxJavascriptResource,
+ OpenId.RelyingParty.OpenIdAjaxTextBox.EmbeddedScriptResourceName,
+ };
+ result.WriteScriptTags(page, scriptResources);
if (selectorOptions.DownloadYahooUILibrary) {
- result.WriteScriptTags(new[] { "https://ajax.googleapis.com/ajax/libs/yui/2.8.0r4/build/yuiloader/yuiloader-min.js" });
+ result.WriteScriptTags(new[] { "https://ajax.googleapis.com/ajax/libs/yui/2.8.0r4/build/yuiloader/yuiloader-min.js" });
}
var blockBuilder = new StringWriter();
@@ -86,7 +108,7 @@ window.openid_trace = {1}; // causes lots of messages",
assertionLifetimeInMilliseconds.ToString(CultureInfo.InvariantCulture));
string discoverUrl = VirtualPathUtility.AppendTrailingSlash(HttpContext.Current.Request.ApplicationPath) + html.RouteCollection["OpenIdDiscover"].GetVirtualPath(html.ViewContext.RequestContext, new RouteValueDictionary(new { identifier = "xxx" })).VirtualPath;
- blockBuilder.WriteLine(@" {0} = function (argument, resultFunction, errorCallback) {{
+ string blockFormat = @" {0} = function (argument, resultFunction, errorCallback) {{
jQuery.ajax({{
async: true,
dataType: 'text',
@@ -94,29 +116,32 @@ window.openid_trace = {1}; // causes lots of messages",
success: function (result) {{ resultFunction(result, argument); }},
url: '{1}'.replace('xxx', encodeURIComponent(argument))
}});
- }};",
- OpenIdRelyingPartyAjaxControlBase.CallbackJSFunctionAsync,
- discoverUrl);
+ }};";
+ blockBuilder.WriteLine(blockFormat, OpenIdRelyingPartyAjaxControlBase.CallbackJSFunctionAsync, discoverUrl);
- blockBuilder.WriteLine(@" window.postLoginAssertion = function (positiveAssertion) {{
+ blockFormat = @" window.postLoginAssertion = function (positiveAssertion) {{
$('#{0}')[0].setAttribute('value', positiveAssertion);
if ($('#{1}')[0] && !$('#{1}')[0].value) {{ // popups have no ReturnUrl predefined, but full page LogOn does.
$('#{1}')[0].setAttribute('value', window.parent.location.href);
}}
document.forms[{2}].submit();
- }};",
+ }};";
+ blockBuilder.WriteLine(
+ blockFormat,
additionalOptions.AssertionHiddenFieldId,
additionalOptions.ReturnUrlHiddenFieldId,
additionalOptions.FormIndex);
- blockBuilder.WriteLine(@" $(function () {{
+ blockFormat = @" $(function () {{
var box = document.getElementsByName('openid_identifier')[0];
initAjaxOpenId(box, {0}, {1}, {2}, {3}, {4}, {5},
null, // js function to invoke on receiving a positive assertion
{6}, {7}, {8}, {9}, {10}, {11}, {12}, {13}, {14}, {15}, {16}, {17},
false, // auto postback
null); // PostBackEventReference (unused in MVC)
- }});",
+ }});";
+ blockBuilder.WriteLine(
+ blockFormat,
MessagingUtilities.GetSafeJavascriptValue(page.ClientScript.GetWebResourceUrl(typeof(OpenIdRelyingPartyControlBase), OpenIdTextBox.EmbeddedLogoResourceName)),
MessagingUtilities.GetSafeJavascriptValue(page.ClientScript.GetWebResourceUrl(typeof(OpenIdRelyingPartyControlBase), OpenId.RelyingParty.OpenIdAjaxTextBox.EmbeddedSpinnerResourceName)),
MessagingUtilities.GetSafeJavascriptValue(page.ClientScript.GetWebResourceUrl(typeof(OpenIdRelyingPartyControlBase), OpenId.RelyingParty.OpenIdAjaxTextBox.EmbeddedLoginSuccessResourceName)),
@@ -141,16 +166,36 @@ window.openid_trace = {1}; // causes lots of messages",
return result.ToString();
}
+ /// <summary>
+ /// Emits the HTML to render an OpenID Provider button as a part of the overall OpenID Selector UI.
+ /// </summary>
+ /// <param name="html">The <see cref="HtmlHelper"/> on the view.</param>
+ /// <param name="page">The page being rendered.</param>
+ /// <param name="providerIdentifier">The OP Identifier.</param>
+ /// <param name="imageUrl">The URL of the image to display on the button.</param>
+ /// <returns>
+ /// HTML that should be sent directly to the browser.
+ /// </returns>
public static string OpenIdSelectorOPButton(this HtmlHelper html, Page page, Identifier providerIdentifier, string imageUrl) {
Contract.Requires<ArgumentNullException>(html != null);
Contract.Requires<ArgumentNullException>(page != null);
Contract.Requires<ArgumentNullException>(providerIdentifier != null);
Contract.Requires<ArgumentException>(!string.IsNullOrEmpty(imageUrl));
Contract.Ensures(Contract.Result<string>() != null);
-
+
return OpenIdSelectorButton(html, page, providerIdentifier, "OPButton", imageUrl);
}
+ /// <summary>
+ /// Emits the HTML to render a generic OpenID button as a part of the overall OpenID Selector UI,
+ /// allowing the user to enter their own OpenID.
+ /// </summary>
+ /// <param name="html">The <see cref="HtmlHelper"/> on the view.</param>
+ /// <param name="page">The page being rendered.</param>
+ /// <param name="imageUrl">The URL of the image to display on the button.</param>
+ /// <returns>
+ /// HTML that should be sent directly to the browser.
+ /// </returns>
public static string OpenIdSelectorOpenIdButton(this HtmlHelper html, Page page, string imageUrl) {
Contract.Requires<ArgumentNullException>(html != null);
Contract.Requires<ArgumentNullException>(page != null);
@@ -160,6 +205,15 @@ window.openid_trace = {1}; // causes lots of messages",
return OpenIdSelectorButton(html, page, "OpenIDButton", "OpenIDButton", imageUrl);
}
+ /// <summary>
+ /// Emits the HTML to render the entire OpenID Selector UI.
+ /// </summary>
+ /// <param name="html">The <see cref="HtmlHelper"/> on the view.</param>
+ /// <param name="page">The page being rendered.</param>
+ /// <param name="buttons">The buttons to include on the selector.</param>
+ /// <returns>
+ /// HTML that should be sent directly to the browser.
+ /// </returns>
public static string OpenIdSelector(this HtmlHelper html, Page page, params SelectorButton[] buttons) {
Contract.Requires<ArgumentNullException>(html != null);
Contract.Requires<ArgumentNullException>(page != null);
@@ -197,6 +251,14 @@ window.openid_trace = {1}; // causes lots of messages",
return writer.ToString();
}
+ /// <summary>
+ /// Emits the HTML to render the <see cref="OpenIdAjaxTextBox"/> control as a part of the overall
+ /// OpenID Selector UI.
+ /// </summary>
+ /// <param name="html">The <see cref="HtmlHelper"/> on the view.</param>
+ /// <returns>
+ /// HTML that should be sent directly to the browser.
+ /// </returns>
public static string OpenIdAjaxTextBox(this HtmlHelper html) {
return @"<div style='display: none' id='OpenIDForm'>
<span class='OpenIdAjaxTextBox' style='display: inline-block; position: relative; font-size: 16px'>
@@ -205,6 +267,17 @@ window.openid_trace = {1}; // causes lots of messages",
</div>";
}
+ /// <summary>
+ /// Emits the HTML to render a button as a part of the overall OpenID Selector UI.
+ /// </summary>
+ /// <param name="html">The <see cref="HtmlHelper"/> on the view.</param>
+ /// <param name="page">The page being rendered.</param>
+ /// <param name="id">The value to assign to the HTML id attribute.</param>
+ /// <param name="cssClass">The value to assign to the HTML class attribute.</param>
+ /// <param name="imageUrl">The URL of the image to draw on the button.</param>
+ /// <returns>
+ /// HTML that should be sent directly to the browser.
+ /// </returns>
private static string OpenIdSelectorButton(this HtmlHelper html, Page page, string id, string cssClass, string imageUrl) {
Contract.Requires<ArgumentNullException>(html != null);
Contract.Requires<ArgumentNullException>(page != null);
@@ -250,6 +323,11 @@ window.openid_trace = {1}; // causes lots of messages",
return writer.ToString();
}
+ /// <summary>
+ /// Emits &lt;script&gt; tags that import a given set of scripts given their URLs.
+ /// </summary>
+ /// <param name="writer">The writer to emit the tags to.</param>
+ /// <param name="scriptUrls">The locations of the scripts to import.</param>
private static void WriteScriptTags(this TextWriter writer, IEnumerable<string> scriptUrls) {
Contract.Requires<ArgumentNullException>(writer != null);
Contract.Requires<ArgumentNullException>(scriptUrls != null);
@@ -259,10 +337,22 @@ window.openid_trace = {1}; // causes lots of messages",
}
}
+ /// <summary>
+ /// Writes out script tags that import a script from resources embedded in this assembly.
+ /// </summary>
+ /// <param name="writer">The writer to emit the tags to.</param>
+ /// <param name="page">The page being rendered.</param>
+ /// <param name="resourceName">Name of the resource.</param>
private static void WriteScriptTags(this TextWriter writer, Page page, string resourceName) {
WriteScriptTags(writer, page, new[] { resourceName });
}
+ /// <summary>
+ /// Writes out script tags that import scripts from resources embedded in this assembly.
+ /// </summary>
+ /// <param name="writer">The writer to emit the tags to.</param>
+ /// <param name="page">The page being rendered.</param>
+ /// <param name="resourceNames">The resource names.</param>
private static void WriteScriptTags(this TextWriter writer, Page page, IEnumerable<string> resourceNames) {
Contract.Requires<ArgumentNullException>(writer != null);
Contract.Requires<ArgumentNullException>(page != null);
@@ -271,6 +361,11 @@ window.openid_trace = {1}; // causes lots of messages",
writer.WriteScriptTags(resourceNames.Select(r => page.ClientScript.GetWebResourceUrl(typeof(OpenIdRelyingPartyControlBase), r)));
}
+ /// <summary>
+ /// Writes a given script block, surrounding it with &lt;script&gt; and CDATA tags.
+ /// </summary>
+ /// <param name="writer">The writer to emit the tags to.</param>
+ /// <param name="script">The script to inline on the page.</param>
private static void WriteScriptBlock(this TextWriter writer, string script) {
writer.WriteLine("<script type='text/javascript' language='javascript'><!--");
writer.WriteLine("//<![CDATA[");
diff --git a/src/DotNetOpenAuth/OpenId/RelyingParty/OpenIdRelyingPartyAjaxControlBase.cs b/src/DotNetOpenAuth/OpenId/RelyingParty/OpenIdRelyingPartyAjaxControlBase.cs
index 7d6a9d5..c6c0a5d 100644
--- a/src/DotNetOpenAuth/OpenId/RelyingParty/OpenIdRelyingPartyAjaxControlBase.cs
+++ b/src/DotNetOpenAuth/OpenId/RelyingParty/OpenIdRelyingPartyAjaxControlBase.cs
@@ -41,9 +41,10 @@ namespace DotNetOpenAuth.OpenId.RelyingParty {
internal const string ClaimedIdParameterName = OpenIdUtilities.CustomParameterPrefix + "claimed_id";
/// <summary>
- /// The name of the javascript function that will initiate a synchronous callback.
+ /// The name of the javascript field that stores the maximum time a positive assertion is
+ /// good for before it must be refreshed.
/// </summary>
- protected const string CallbackJSFunction = "window.dnoa_internal.callback";
+ internal const string MaxPositiveAssertionLifetimeJsName = "window.dnoa_internal.maxPositiveAssertionLifetime";
/// <summary>
/// The name of the javascript function that will initiate an asynchronous callback.
@@ -51,10 +52,9 @@ namespace DotNetOpenAuth.OpenId.RelyingParty {
protected internal const string CallbackJSFunctionAsync = "window.dnoa_internal.callbackAsync";
/// <summary>
- /// The name of the javascript field that stores the maximum time a positive assertion is
- /// good for before it must be refreshed.
+ /// The name of the javascript function that will initiate a synchronous callback.
/// </summary>
- internal const string MaxPositiveAssertionLifetimeJsName = "window.dnoa_internal.maxPositiveAssertionLifetime";
+ protected const string CallbackJSFunction = "window.dnoa_internal.callback";
#region Property viewstate keys
diff --git a/src/DotNetOpenAuth/OpenId/RelyingParty/OpenIdSelector.cs b/src/DotNetOpenAuth/OpenId/RelyingParty/OpenIdSelector.cs
index b07b98a..5b85e7c 100644
--- a/src/DotNetOpenAuth/OpenId/RelyingParty/OpenIdSelector.cs
+++ b/src/DotNetOpenAuth/OpenId/RelyingParty/OpenIdSelector.cs
@@ -97,7 +97,7 @@ namespace DotNetOpenAuth.OpenId.RelyingParty {
public event EventHandler<TokenProcessingErrorEventArgs> TokenProcessingError;
/// <summary>
- /// Gets or sets the text box where applicable.
+ /// Gets the text box where applicable.
/// </summary>
public OpenIdAjaxTextBox TextBox {
get {
@@ -256,7 +256,7 @@ namespace DotNetOpenAuth.OpenId.RelyingParty {
/// <summary>
/// Ensures that the child controls have been built, but doesn't set control
- /// properties that require executing <see cref="EnsureID"/> in order to avoid
+ /// properties that require executing <see cref="Control.EnsureID"/> in order to avoid
/// certain initialization order problems.
/// </summary>
/// <remarks>