diff options
author | Andrew Arnott <andrewarnott@gmail.com> | 2010-03-11 17:17:10 -0800 |
---|---|---|
committer | Andrew Arnott <andrewarnott@gmail.com> | 2010-03-11 17:17:10 -0800 |
commit | aac91f26a99f6d3ecf6beca4cb3b4e8a93471da5 (patch) | |
tree | dceb0d4b711f549c6299bc1187d9fc7150ecb9fb | |
parent | 2825d2b41a4ae3e0a533a32bced2e674299010db (diff) | |
download | DotNetOpenAuth-aac91f26a99f6d3ecf6beca4cb3b4e8a93471da5.zip DotNetOpenAuth-aac91f26a99f6d3ecf6beca4cb3b4e8a93471da5.tar.gz DotNetOpenAuth-aac91f26a99f6d3ecf6beca4cb3b4e8a93471da5.tar.bz2 |
Diverted localizable resources into existing resource files.
-rw-r--r-- | projecttemplates/MvcRelyingParty/Views/Auth/LogOnScripts.ascx | 2 | ||||
-rw-r--r-- | src/DotNetOpenAuth/DotNetOpenAuth.csproj | 2 | ||||
-rw-r--r-- | src/DotNetOpenAuth/Mvc/OpenIdAjaxOptions.cs (renamed from src/DotNetOpenAuth/Mvc/OpenIdSelectorOptions.cs) | 7 | ||||
-rw-r--r-- | src/DotNetOpenAuth/Mvc/OpenIdHelper.cs | 65 | ||||
-rw-r--r-- | src/DotNetOpenAuth/OpenId/RelyingParty/OpenIdAjaxTextBox.cs | 10 | ||||
-rw-r--r-- | src/DotNetOpenAuth/OpenId/RelyingParty/OpenIdSelector.cs | 44 |
6 files changed, 89 insertions, 41 deletions
diff --git a/projecttemplates/MvcRelyingParty/Views/Auth/LogOnScripts.ascx b/projecttemplates/MvcRelyingParty/Views/Auth/LogOnScripts.ascx index e983872..64c4fae 100644 --- a/projecttemplates/MvcRelyingParty/Views/Auth/LogOnScripts.ascx +++ b/projecttemplates/MvcRelyingParty/Views/Auth/LogOnScripts.ascx @@ -3,4 +3,4 @@ <script type="text/javascript" src='<%= Url.Content("~/Scripts/MicrosoftAjax.js") %>'></script> <script type="text/javascript" src='<%= Url.Content("~/Scripts/MicrosoftMvcAjax.js") %>'></script> <script type="text/javascript" src='<%= Url.Content("~/Scripts/jquery.cookie.js") %>'></script> -<%= Html.OpenIdSelectorScripts(this.Page, new OpenIdSelectorOptions { })%> +<%= Html.OpenIdSelectorScripts(this.Page)%> diff --git a/src/DotNetOpenAuth/DotNetOpenAuth.csproj b/src/DotNetOpenAuth/DotNetOpenAuth.csproj index aaeb501..4754514 100644 --- a/src/DotNetOpenAuth/DotNetOpenAuth.csproj +++ b/src/DotNetOpenAuth/DotNetOpenAuth.csproj @@ -303,7 +303,7 @@ http://opensource.org/licenses/ms-pl.html <Compile Include="Messaging\Reflection\IMessagePartNullEncoder.cs" /> <Compile Include="Messaging\Reflection\MessageDescriptionCollection.cs" /> <Compile Include="Mvc\OpenIdHelper.cs" /> - <Compile Include="Mvc\OpenIdSelectorOptions.cs" /> + <Compile Include="Mvc\OpenIdAjaxOptions.cs" /> <Compile Include="OAuth\ChannelElements\ICombinedOpenIdProviderTokenManager.cs" /> <Compile Include="OAuth\ChannelElements\IConsumerDescription.cs" /> <Compile Include="OAuth\ChannelElements\IConsumerTokenManager.cs" /> diff --git a/src/DotNetOpenAuth/Mvc/OpenIdSelectorOptions.cs b/src/DotNetOpenAuth/Mvc/OpenIdAjaxOptions.cs index 487851b..d50af97 100644 --- a/src/DotNetOpenAuth/Mvc/OpenIdSelectorOptions.cs +++ b/src/DotNetOpenAuth/Mvc/OpenIdAjaxOptions.cs @@ -10,14 +10,11 @@ namespace DotNetOpenAuth.Mvc { using System.Linq; using System.Text; - public class OpenIdSelectorOptions { - public OpenIdSelectorOptions() { - this.DownloadYahooUILibrary = true; + public class OpenIdAjaxOptions { + public OpenIdAjaxOptions() { this.AssertionHiddenFieldId = "openid_openidAuthData"; } - public bool DownloadYahooUILibrary { get; set; } - public string AssertionHiddenFieldId { get; set; } public bool ShowDiagnosticTrace { get; set; } diff --git a/src/DotNetOpenAuth/Mvc/OpenIdHelper.cs b/src/DotNetOpenAuth/Mvc/OpenIdHelper.cs index 8ee1781..0df4657 100644 --- a/src/DotNetOpenAuth/Mvc/OpenIdHelper.cs +++ b/src/DotNetOpenAuth/Mvc/OpenIdHelper.cs @@ -22,21 +22,32 @@ namespace DotNetOpenAuth.Mvc { using DotNetOpenAuth.OpenId.RelyingParty; public static class OpenIdHelper { - public static string OpenIdSelectorScripts(this HtmlHelper html, Page page, OpenIdSelectorOptions options) { + public static string OpenIdSelectorScripts(this HtmlHelper html, Page page) { + return OpenIdSelectorScripts(html, page, null, null); + } + + public static string OpenIdSelectorScripts(this HtmlHelper html, Page page, OpenIdSelector selectorOptions, OpenIdAjaxOptions additionalOptions) { Contract.Requires<ArgumentNullException>(html != null); Contract.Requires<ArgumentNullException>(page != null); - Contract.Requires<ArgumentNullException>(options != null); Contract.Ensures(Contract.Result<string>() != null); + if (selectorOptions == null) { + selectorOptions = new OpenId.RelyingParty.OpenIdSelector(); + } + + if (additionalOptions == null) { + additionalOptions = new OpenIdAjaxOptions(); + } + StringWriter result = new StringWriter(); - if (options.ShowDiagnosticIFrame || options.ShowDiagnosticTrace) { + if (additionalOptions.ShowDiagnosticIFrame || additionalOptions.ShowDiagnosticTrace) { 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", - options.ShowDiagnosticIFrame ? "true" : "false", - options.ShowDiagnosticTrace ? "true" : "false")); + additionalOptions.ShowDiagnosticIFrame ? "true" : "false", + additionalOptions.ShowDiagnosticTrace ? "true" : "false")); } result.WriteScriptTags(page, new[] { OpenIdRelyingPartyControlBase.EmbeddedJavascriptResource, @@ -44,12 +55,12 @@ window.openid_trace = {1}; // causes lots of messages", OpenId.RelyingParty.OpenIdAjaxTextBox.EmbeddedScriptResourceName, }); - if (options.DownloadYahooUILibrary) { + if (selectorOptions.DownloadYahooUILibrary) { result.WriteScriptTags(new[] { "https://ajax.googleapis.com/ajax/libs/yui/2.8.0r4/build/yuiloader/yuiloader-min.js" }); } var blockBuilder = new StringWriter(); - if (options.DownloadYahooUILibrary) { + if (selectorOptions.DownloadYahooUILibrary) { blockBuilder.WriteLine(@" try { if (YAHOO) { var loader = new YAHOO.util.YUILoader({ @@ -94,38 +105,34 @@ window.openid_trace = {1}; // causes lots of messages", }} document.forms[0].submit(); }};", - options.AssertionHiddenFieldId); + additionalOptions.AssertionHiddenFieldId); blockBuilder.WriteLine(@" $(function () {{ var box = document.getElementsByName('openid_identifier')[0]; - initAjaxOpenId( - box, - {0}, - {1}, - {2}, - {3}, - 3, // throttle - 8000, // timeout + initAjaxOpenId(box, {0}, {1}, {2}, {3}, {4}, {5}, null, // js function to invoke on receiving a positive assertion - 'LOG IN', - 'Click here to log in using a pop-up window.', - true, // ShowLogOnPostBackButton - 'Click here to log in immediately.', - 'RETRY', - 'Retry a failed identifier discovery.', - 'Discovering/authenticating', - 'Please correct errors in OpenID identifier and allow login to complete before submitting.', - 'Please wait for login to complete.', - 'Authenticated by {{0}}.', - 'Authenticated as {{0}}.', - 'Authentication failed.', + {6}, {7}, {8}, {9}, {10}, {11}, {12}, {13}, {14}, {15}, {16}, {17}, false, // auto postback null); // PostBackEventReference (unused in MVC) }});", 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)), - MessagingUtilities.GetSafeJavascriptValue(page.ClientScript.GetWebResourceUrl(typeof(OpenIdRelyingPartyControlBase), OpenId.RelyingParty.OpenIdAjaxTextBox.EmbeddedLoginFailureResourceName))); + MessagingUtilities.GetSafeJavascriptValue(page.ClientScript.GetWebResourceUrl(typeof(OpenIdRelyingPartyControlBase), OpenId.RelyingParty.OpenIdAjaxTextBox.EmbeddedLoginFailureResourceName)), + selectorOptions.Throttle, + selectorOptions.Timeout.TotalMilliseconds, + MessagingUtilities.GetSafeJavascriptValue(selectorOptions.TextBox.LogOnText), + MessagingUtilities.GetSafeJavascriptValue(selectorOptions.TextBox.LogOnToolTip), + selectorOptions.TextBox.ShowLogOnPostBackButton ? "true" : "false", + MessagingUtilities.GetSafeJavascriptValue(selectorOptions.TextBox.LogOnPostBackToolTip), + MessagingUtilities.GetSafeJavascriptValue(selectorOptions.TextBox.RetryText), + MessagingUtilities.GetSafeJavascriptValue(selectorOptions.TextBox.RetryToolTip), + MessagingUtilities.GetSafeJavascriptValue(selectorOptions.TextBox.BusyToolTip), + MessagingUtilities.GetSafeJavascriptValue(selectorOptions.TextBox.IdentifierRequiredMessage), + MessagingUtilities.GetSafeJavascriptValue(selectorOptions.TextBox.LogOnInProgressMessage), + MessagingUtilities.GetSafeJavascriptValue(selectorOptions.TextBox.AuthenticationSucceededToolTip), + MessagingUtilities.GetSafeJavascriptValue(selectorOptions.TextBox.AuthenticatedAsToolTip), + MessagingUtilities.GetSafeJavascriptValue(selectorOptions.TextBox.AuthenticationFailedToolTip)); result.WriteScriptBlock(blockBuilder.ToString()); result.WriteScriptTags(page, OpenId.RelyingParty.OpenIdSelector.EmbeddedScriptResourceName); diff --git a/src/DotNetOpenAuth/OpenId/RelyingParty/OpenIdAjaxTextBox.cs b/src/DotNetOpenAuth/OpenId/RelyingParty/OpenIdAjaxTextBox.cs index 097d065..d80bf6a 100644 --- a/src/DotNetOpenAuth/OpenId/RelyingParty/OpenIdAjaxTextBox.cs +++ b/src/DotNetOpenAuth/OpenId/RelyingParty/OpenIdAjaxTextBox.cs @@ -64,6 +64,11 @@ namespace DotNetOpenAuth.OpenId.RelyingParty { /// </summary> internal const bool DownloadYahooUILibraryDefault = true; + /// <summary> + /// The default value for the <see cref="Throttle"/> property. + /// </summary> + internal const int ThrottleDefault = 3; + #region Property viewstate keys /// <summary> @@ -221,11 +226,6 @@ namespace DotNetOpenAuth.OpenId.RelyingParty { private const string AuthenticationFailedToolTipDefault = "Authentication failed."; /// <summary> - /// The default value for the <see cref="Throttle"/> property. - /// </summary> - private const int ThrottleDefault = 3; - - /// <summary> /// The default value for the <see cref="LogOnText"/> property. /// </summary> private const string LogOnTextDefault = "LOG IN"; diff --git a/src/DotNetOpenAuth/OpenId/RelyingParty/OpenIdSelector.cs b/src/DotNetOpenAuth/OpenId/RelyingParty/OpenIdSelector.cs index e125181..b07b98a 100644 --- a/src/DotNetOpenAuth/OpenId/RelyingParty/OpenIdSelector.cs +++ b/src/DotNetOpenAuth/OpenId/RelyingParty/OpenIdSelector.cs @@ -97,6 +97,50 @@ namespace DotNetOpenAuth.OpenId.RelyingParty { public event EventHandler<TokenProcessingErrorEventArgs> TokenProcessingError; /// <summary> + /// Gets or sets the text box where applicable. + /// </summary> + public OpenIdAjaxTextBox TextBox { + get { + this.EnsureChildControlsAreCreatedSafe(); + return this.textBox; + } + } + + /// <summary> + /// Gets or sets the maximum number of OpenID Providers to simultaneously try to authenticate with. + /// </summary> + [Browsable(true), DefaultValue(OpenIdAjaxTextBox.ThrottleDefault), Category(BehaviorCategory)] + [Description("The maximum number of OpenID Providers to simultaneously try to authenticate with.")] + public int Throttle { + get { + this.EnsureChildControlsAreCreatedSafe(); + return this.textBox.Throttle; + } + + set { + this.EnsureChildControlsAreCreatedSafe(); + this.textBox.Throttle = value; + } + } + + /// <summary> + /// Gets or sets the time duration for the AJAX control to wait for an OP to respond before reporting failure to the user. + /// </summary> + [Browsable(true), DefaultValue(typeof(TimeSpan), "00:00:08"), Category(BehaviorCategory)] + [Description("The time duration for the AJAX control to wait for an OP to respond before reporting failure to the user.")] + public TimeSpan Timeout { + get { + this.EnsureChildControlsAreCreatedSafe(); + return this.textBox.Timeout; + } + + set { + this.EnsureChildControlsAreCreatedSafe(); + this.textBox.Timeout = value; + } + } + + /// <summary> /// Gets or sets the tool tip text that appears on the green checkmark when authentication succeeds. /// </summary> [Bindable(true), DefaultValue(AuthenticatedAsToolTipDefault), Localizable(true), Category(AppearanceCategory)] |