summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--samples/RelyingPartyPortal/ajaxlogin.aspx6
-rw-r--r--samples/RelyingPartyPortal/ajaxlogin.aspx.cs2
-rw-r--r--src/DotNetOpenId/DotNetOpenId.csproj2
-rw-r--r--src/DotNetOpenId/Extensions/IClientScriptExtensionResponse.cs (renamed from src/DotNetOpenId/Extensions/IClientScriptExtension.cs)6
-rw-r--r--src/DotNetOpenId/Extensions/SimpleRegistration/ClaimsRequest.cs3
-rw-r--r--src/DotNetOpenId/Extensions/SimpleRegistration/ClaimsResponse.cs4
-rw-r--r--src/DotNetOpenId/RelyingParty/AuthenticationResponse.cs12
-rw-r--r--src/DotNetOpenId/RelyingParty/OpenIdAjaxTextBox.cs18
-rw-r--r--src/DotNetOpenId/RelyingParty/OpenIdAjaxTextBox.js6
-rw-r--r--src/DotNetOpenId/Strings.Designer.cs15
-rw-r--r--src/DotNetOpenId/Strings.resx7
11 files changed, 56 insertions, 25 deletions
diff --git a/samples/RelyingPartyPortal/ajaxlogin.aspx b/samples/RelyingPartyPortal/ajaxlogin.aspx
index e0732cc..75ee603 100644
--- a/samples/RelyingPartyPortal/ajaxlogin.aspx
+++ b/samples/RelyingPartyPortal/ajaxlogin.aspx
@@ -1,9 +1,9 @@
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ajaxlogin.aspx.cs" Inherits="ConsumerPortal.ajaxlogin"
ValidateRequest="false" MasterPageFile="~/Site.Master" %>
-<%@ Register Assembly="DotNetOpenId" Namespace="DotNetOpenId.RelyingParty" TagPrefix="cc1" %>
+<%@ Register Assembly="DotNetOpenId" Namespace="DotNetOpenId.RelyingParty" TagPrefix="openid" %>
<asp:Content runat="server" ContentPlaceHolderID="head">
-<style>
+<style type="text/css">
.textbox
{
width: 200px;
@@ -41,7 +41,7 @@ td
OpenID
</td>
<td>
- <cc1:OpenIdAjaxTextBox ID="OpenIdAjaxTextBox1" runat="server" CssClass="openidtextbox"
+ <openid:OpenIdAjaxTextBox ID="OpenIdAjaxTextBox1" runat="server" CssClass="openidtextbox"
OnLoggingIn="OpenIdAjaxTextBox1_LoggingIn"
OnLoggedIn="OpenIdAjaxTextBox1_LoggedIn"
OnClientAssertionReceived="onauthenticated(sender)"
diff --git a/samples/RelyingPartyPortal/ajaxlogin.aspx.cs b/samples/RelyingPartyPortal/ajaxlogin.aspx.cs
index 7b08d03..40ecd27 100644
--- a/samples/RelyingPartyPortal/ajaxlogin.aspx.cs
+++ b/samples/RelyingPartyPortal/ajaxlogin.aspx.cs
@@ -47,7 +47,7 @@ namespace ConsumerPortal {
protected void OpenIdAjaxTextBox1_UnconfirmedPositiveAssertion(object sender, OpenIdEventArgs e) {
// This is where we register extensions that we want to have available in javascript
// on the browser.
- OpenIdAjaxTextBox1.RegisterClientScriptExtension(new ClaimsResponse(), "sreg");
+ OpenIdAjaxTextBox1.RegisterClientScriptExtension<ClaimsResponse>("sreg");
}
}
}
diff --git a/src/DotNetOpenId/DotNetOpenId.csproj b/src/DotNetOpenId/DotNetOpenId.csproj
index 3548a71..2f66205 100644
--- a/src/DotNetOpenId/DotNetOpenId.csproj
+++ b/src/DotNetOpenId/DotNetOpenId.csproj
@@ -64,7 +64,7 @@
<Compile Include="Configuration\WhiteBlackListCollection.cs" />
<Compile Include="Configuration\WhiteBlackListElement.cs" />
<Compile Include="DiffieHellmanUtil.cs" />
- <Compile Include="Extensions\IClientScriptExtension.cs" />
+ <Compile Include="Extensions\IClientScriptExtensionResponse.cs" />
<Compile Include="Provider\ProviderSecuritySettings.cs" />
<Compile Include="RelyingParty\AuthenticationResponseSnapshot.cs" />
<Compile Include="RelyingParty\OpenIdAjaxTextBox.cs" />
diff --git a/src/DotNetOpenId/Extensions/IClientScriptExtension.cs b/src/DotNetOpenId/Extensions/IClientScriptExtensionResponse.cs
index 48d30e5..11a3c0f 100644
--- a/src/DotNetOpenId/Extensions/IClientScriptExtension.cs
+++ b/src/DotNetOpenId/Extensions/IClientScriptExtensionResponse.cs
@@ -2,7 +2,11 @@
using DotNetOpenId.RelyingParty;
namespace DotNetOpenId.Extensions {
- public interface IClientScriptExtension : IExtension {
+ /// <summary>
+ /// An interface that OpenID extensions can implement to allow authentication response
+ /// messages with included extensions to be processed by Javascript on the user agent.
+ /// </summary>
+ public interface IClientScriptExtensionResponse : IExtension {
/// <summary>
/// Reads the extension information on an authentication response from the provider.
/// </summary>
diff --git a/src/DotNetOpenId/Extensions/SimpleRegistration/ClaimsRequest.cs b/src/DotNetOpenId/Extensions/SimpleRegistration/ClaimsRequest.cs
index e5d282e..aab0608 100644
--- a/src/DotNetOpenId/Extensions/SimpleRegistration/ClaimsRequest.cs
+++ b/src/DotNetOpenId/Extensions/SimpleRegistration/ClaimsRequest.cs
@@ -183,6 +183,9 @@ namespace DotNetOpenId.Extensions.SimpleRegistration {
/// version of Simple Registration used in the request message.
/// </summary>
public ClaimsResponse CreateResponse() {
+ if (typeUriDeserializedFrom == null) {
+ throw new InvalidOperationException(Strings.CallDeserializeBeforeCreateResponse);
+ }
return new ClaimsResponse(typeUriDeserializedFrom);
}
diff --git a/src/DotNetOpenId/Extensions/SimpleRegistration/ClaimsResponse.cs b/src/DotNetOpenId/Extensions/SimpleRegistration/ClaimsResponse.cs
index bf0a04b..738069f 100644
--- a/src/DotNetOpenId/Extensions/SimpleRegistration/ClaimsResponse.cs
+++ b/src/DotNetOpenId/Extensions/SimpleRegistration/ClaimsResponse.cs
@@ -21,7 +21,7 @@ namespace DotNetOpenId.Extensions.SimpleRegistration
/// authenticating user.
/// </summary>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2218:OverrideGetHashCodeOnOverridingEquals"), Serializable()]
- public sealed class ClaimsResponse : IExtensionResponse, IClientScriptExtension
+ public sealed class ClaimsResponse : IExtensionResponse, IClientScriptExtensionResponse
{
string typeUriToUse;
@@ -207,7 +207,7 @@ namespace DotNetOpenId.Extensions.SimpleRegistration
propertyName, Util.GetSafeJavascriptValue(value));
}
- string IClientScriptExtension.InitializeJavascriptData(IDictionary<string, string> sreg, IAuthenticationResponse response, string typeUri) {
+ string IClientScriptExtensionResponse.InitializeJavascriptData(IDictionary<string, string> sreg, IAuthenticationResponse response, string typeUri) {
StringBuilder builder = new StringBuilder();
builder.Append("{ ");
diff --git a/src/DotNetOpenId/RelyingParty/AuthenticationResponse.cs b/src/DotNetOpenId/RelyingParty/AuthenticationResponse.cs
index 10a5312..9b007a7 100644
--- a/src/DotNetOpenId/RelyingParty/AuthenticationResponse.cs
+++ b/src/DotNetOpenId/RelyingParty/AuthenticationResponse.cs
@@ -112,7 +112,17 @@ namespace DotNetOpenId.RelyingParty {
get { return new Uri(Util.GetRequiredArg(signedArguments, Provider.Protocol.openid.return_to)); }
}
- internal string GetExtensionClientScript(IClientScriptExtension extension) {
+ internal string GetExtensionClientScript(Type extensionType) {
+ if (extensionType == null) throw new ArgumentNullException("extensionType");
+ if (!typeof(DotNetOpenId.Extensions.IClientScriptExtensionResponse).IsAssignableFrom(extensionType))
+ throw new ArgumentException(string.Format(CultureInfo.CurrentCulture,
+ Strings.TypeMustImplementX, typeof(IClientScriptExtensionResponse).FullName),
+ "extensionType");
+ var extension = (IClientScriptExtensionResponse)Activator.CreateInstance(extensionType);
+ return GetExtensionClientScript(extension);
+ }
+
+ internal string GetExtensionClientScript(IClientScriptExtensionResponse extension) {
var fields = IncomingExtensions.GetExtensionArguments(extension.TypeUri);
if (fields != null) {
// The extension was found using the preferred TypeUri.
diff --git a/src/DotNetOpenId/RelyingParty/OpenIdAjaxTextBox.cs b/src/DotNetOpenId/RelyingParty/OpenIdAjaxTextBox.cs
index e331e1c..d5fa243 100644
--- a/src/DotNetOpenId/RelyingParty/OpenIdAjaxTextBox.cs
+++ b/src/DotNetOpenId/RelyingParty/OpenIdAjaxTextBox.cs
@@ -335,28 +335,30 @@ namespace DotNetOpenId.RelyingParty {
#endregion
- Dictionary<IClientScriptExtension, string> clientScriptExtensions = new Dictionary<IClientScriptExtension, string>();
+ Dictionary<Type, string> clientScriptExtensions = new Dictionary<Type, string>();
/// <summary>
/// Allows an OpenID extension to read data out of an unverified positive authentication assertion
/// and send it down to the client browser so that Javascript running on the page can perform
/// some preprocessing on the extension data.
/// </summary>
- /// <param name="extension">The extension that will read data from the assertion.</param>
+ /// <typeparam name="T">The extension <i>response</i> type that will read data from the assertion.</typeparam>
/// <param name="propertyName">The property name on the openid_identifier input box object that will be used to store the extension data. For example: sreg</param>
- public void RegisterClientScriptExtension(IClientScriptExtension extension, string propertyName) {
- if (extension == null) throw new ArgumentNullException("extension");
+ /// <remarks>
+ /// This method should be called from the <see cref="UnconfirmedPositiveAssertion"/> event handler.
+ /// </remarks>
+ public void RegisterClientScriptExtension<T>(string propertyName) where T : IClientScriptExtensionResponse {
if (String.IsNullOrEmpty(propertyName)) throw new ArgumentNullException("propertyName");
if (clientScriptExtensions.ContainsValue(propertyName)) {
throw new ArgumentException(string.Format(CultureInfo.CurrentCulture,
Strings.ClientScriptExtensionPropertyNameCollision, propertyName), "propertyName");
}
- foreach (IClientScriptExtension ext in clientScriptExtensions.Keys) {
- if (ext.TypeUri == extension.TypeUri) {
+ foreach (var ext in clientScriptExtensions.Keys) {
+ if (ext == typeof(T)) {
throw new ArgumentException(string.Format(CultureInfo.CurrentCulture,
- Strings.ClientScriptExtensionTypeUriCollision, extension.TypeUri), "extension");
+ Strings.ClientScriptExtensionTypeCollision, typeof(T).FullName));
}
}
- clientScriptExtensions.Add(extension, propertyName);
+ clientScriptExtensions.Add(typeof(T), propertyName);
}
/// <summary>
diff --git a/src/DotNetOpenId/RelyingParty/OpenIdAjaxTextBox.js b/src/DotNetOpenId/RelyingParty/OpenIdAjaxTextBox.js
index 320572c..9dc980f 100644
--- a/src/DotNetOpenId/RelyingParty/OpenIdAjaxTextBox.js
+++ b/src/DotNetOpenId/RelyingParty/OpenIdAjaxTextBox.js
@@ -195,9 +195,9 @@ function initAjaxOpenId(box, dotnetopenid_logo_url, spinner_url, timeout, assert
function createHiddenFrame(url) {
var iframe = document.createElement("iframe");
- iframe.setAttribute("width", 0);
- iframe.setAttribute("height", 0);
- iframe.setAttribute("style", "display: none");
+// iframe.setAttribute("width", 0);
+// iframe.setAttribute("height", 0);
+// iframe.setAttribute("style", "display: none");
iframe.setAttribute("src", url);
iframe.openidBox = box;
box.parentNode.insertBefore(iframe, box);
diff --git a/src/DotNetOpenId/Strings.Designer.cs b/src/DotNetOpenId/Strings.Designer.cs
index fea5283..b53412c 100644
--- a/src/DotNetOpenId/Strings.Designer.cs
+++ b/src/DotNetOpenId/Strings.Designer.cs
@@ -88,6 +88,15 @@ namespace DotNetOpenId {
}
/// <summary>
+ /// Looks up a localized string similar to A Simple Registration request must be deserialized before CreateResponse can be called..
+ /// </summary>
+ internal static string CallDeserializeBeforeCreateResponse {
+ get {
+ return ResourceManager.GetString("CallDeserializeBeforeCreateResponse", resourceCulture);
+ }
+ }
+
+ /// <summary>
/// Looks up a localized string similar to XRI CanonicalID verification failed..
/// </summary>
internal static string CIDVerificationFailed {
@@ -115,11 +124,11 @@ namespace DotNetOpenId {
}
/// <summary>
- /// Looks up a localized string similar to An extension with this extension type URI (&apos;{0}&apos;) has already been registered..
+ /// Looks up a localized string similar to The extension &apos;{0}&apos; has already been registered..
/// </summary>
- internal static string ClientScriptExtensionTypeUriCollision {
+ internal static string ClientScriptExtensionTypeCollision {
get {
- return ResourceManager.GetString("ClientScriptExtensionTypeUriCollision", resourceCulture);
+ return ResourceManager.GetString("ClientScriptExtensionTypeCollision", resourceCulture);
}
}
diff --git a/src/DotNetOpenId/Strings.resx b/src/DotNetOpenId/Strings.resx
index ac6a50d..f5a9d10 100644
--- a/src/DotNetOpenId/Strings.resx
+++ b/src/DotNetOpenId/Strings.resx
@@ -126,6 +126,9 @@
<data name="BadAssociationPrivateData" xml:space="preserve">
<value>The private data supplied does not meet the requirements of any known Association type. Its length may be too short, or it may have been corrupted.</value>
</data>
+ <data name="CallDeserializeBeforeCreateResponse" xml:space="preserve">
+ <value>A Simple Registration request must be deserialized before CreateResponse can be called.</value>
+ </data>
<data name="CIDVerificationFailed" xml:space="preserve">
<value>XRI CanonicalID verification failed.</value>
</data>
@@ -135,8 +138,8 @@
<data name="ClientScriptExtensionPropertyNameCollision" xml:space="preserve">
<value>An extension with this property name ('{0}') has already been registered.</value>
</data>
- <data name="ClientScriptExtensionTypeUriCollision" xml:space="preserve">
- <value>An extension with this extension type URI ('{0}') has already been registered.</value>
+ <data name="ClientScriptExtensionTypeCollision" xml:space="preserve">
+ <value>The extension '{0}' has already been registered.</value>
</data>
<data name="CreateRequestAlreadyCalled" xml:space="preserve">
<value>An authentication request has already been created using CreateRequest().</value>