summaryrefslogtreecommitdiffstats
path: root/samples/OpenIdRelyingPartyWebForms
diff options
context:
space:
mode:
Diffstat (limited to 'samples/OpenIdRelyingPartyWebForms')
-rw-r--r--samples/OpenIdRelyingPartyWebForms/NoIdentityOpenId.aspx41
-rw-r--r--samples/OpenIdRelyingPartyWebForms/NoIdentityOpenId.aspx.cs79
-rw-r--r--samples/OpenIdRelyingPartyWebForms/NoIdentityOpenId.aspx.designer.cs115
-rw-r--r--samples/OpenIdRelyingPartyWebForms/OpenIdRelyingPartyWebForms.csproj8
-rw-r--r--samples/OpenIdRelyingPartyWebForms/login.aspx.designer.cs2
-rw-r--r--samples/OpenIdRelyingPartyWebForms/loginProgrammatic.aspx1
-rw-r--r--samples/OpenIdRelyingPartyWebForms/loginProgrammatic.aspx.cs5
-rw-r--r--samples/OpenIdRelyingPartyWebForms/loginProgrammatic.aspx.designer.cs11
-rw-r--r--samples/OpenIdRelyingPartyWebForms/xrds.aspx1
9 files changed, 256 insertions, 7 deletions
diff --git a/samples/OpenIdRelyingPartyWebForms/NoIdentityOpenId.aspx b/samples/OpenIdRelyingPartyWebForms/NoIdentityOpenId.aspx
new file mode 100644
index 0000000..dc0c2bb
--- /dev/null
+++ b/samples/OpenIdRelyingPartyWebForms/NoIdentityOpenId.aspx
@@ -0,0 +1,41 @@
+<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="NoIdentityOpenId.aspx.cs"
+ MasterPageFile="~/Site.Master" Inherits="OpenIdRelyingPartyWebForms.NoIdentityOpenId" %>
+
+<asp:Content runat="server" ContentPlaceHolderID="Main">
+ <h2>No-login OpenID extension Page </h2>
+ <p>This demonstrates an RP sending an extension-only request to an OP that carries
+ extensions that request anonymous information about you. In this scenario, the OP
+ would still authenticate the user, but would not assert any OpenID Identifier back
+ to the RP, but might provide information regarding the user such as age or membership
+ in an organization. </p>
+ <p><b>Note: </b>At time of this writing, most OPs do not support this feature, although
+ it is documented in the OpenID 2.0 spec. </p>
+ <asp:Label ID="Label1" runat="server" Text="OpenID Identifier" /> <asp:TextBox ID="openIdBox"
+ runat="server" />
+ <asp:Button ID="beginButton" runat="server" Text="Begin" OnClick="beginButton_Click" />
+ <asp:CustomValidator runat="server" ID="openidValidator" ErrorMessage="Invalid OpenID Identifier"
+ ControlToValidate="openIdBox" EnableViewState="false" Display="Dynamic" OnServerValidate="openidValidator_ServerValidate" />
+ <asp:Label runat="server" EnableViewState="false" ID="resultMessage" />
+ <asp:Panel runat="server" ID="ExtensionResponsesPanel" EnableViewState="false" Visible="false">
+ <p>We have received a reasonable response from the Provider. Below is the Simple Registration
+ response we received, if any: </p>
+ <table id="profileFieldsTable" runat="server">
+ <tr>
+ <td>Gender </td>
+ <td><asp:Label runat="server" ID="genderLabel" /> </td>
+ </tr>
+ <tr>
+ <td>Post Code </td>
+ <td><asp:Label runat="server" ID="postalCodeLabel" /> </td>
+ </tr>
+ <tr>
+ <td>Country </td>
+ <td><asp:Label runat="server" ID="countryLabel" /> </td>
+ </tr>
+ <tr>
+ <td>Timezone </td>
+ <td><asp:Label runat="server" ID="timeZoneLabel" /> </td>
+ </tr>
+ </table>
+ </asp:Panel>
+</asp:Content>
diff --git a/samples/OpenIdRelyingPartyWebForms/NoIdentityOpenId.aspx.cs b/samples/OpenIdRelyingPartyWebForms/NoIdentityOpenId.aspx.cs
new file mode 100644
index 0000000..8b9ea78
--- /dev/null
+++ b/samples/OpenIdRelyingPartyWebForms/NoIdentityOpenId.aspx.cs
@@ -0,0 +1,79 @@
+namespace OpenIdRelyingPartyWebForms {
+ using System;
+ using System.Web.UI.WebControls;
+ using DotNetOpenAuth.Messaging;
+ using DotNetOpenAuth.OpenId;
+ using DotNetOpenAuth.OpenId.Extensions.SimpleRegistration;
+ using DotNetOpenAuth.OpenId.RelyingParty;
+
+ public partial class NoIdentityOpenId : System.Web.UI.Page {
+ protected void Page_Load(object sender, EventArgs e) {
+ openIdBox.Focus();
+ using (OpenIdRelyingParty rp = new OpenIdRelyingParty()) {
+ IAuthenticationResponse response = rp.GetResponse();
+ if (response != null) {
+ switch (response.Status) {
+ case AuthenticationStatus.ExtensionsOnly:
+ ExtensionResponsesPanel.Visible = true;
+
+ // This is the "success" status we get when no authentication was requested.
+ var sreg = response.GetExtension<ClaimsResponse>();
+ if (sreg != null) {
+ timeZoneLabel.Text = sreg.TimeZone;
+ postalCodeLabel.Text = sreg.PostalCode;
+ countryLabel.Text = sreg.Country;
+ if (sreg.Gender.HasValue) {
+ genderLabel.Text = sreg.Gender.Value.ToString();
+ }
+ }
+ break;
+ case AuthenticationStatus.Canceled:
+ resultMessage.Text = "Canceled at OP. This may be a sign that the OP doesn't support this message.";
+ break;
+ case AuthenticationStatus.Failed:
+ resultMessage.Text = "OP returned a failure: " + response.Exception;
+ break;
+ case AuthenticationStatus.SetupRequired:
+ case AuthenticationStatus.Authenticated:
+ default:
+ resultMessage.Text = "OP returned an unexpected response.";
+ break;
+ }
+ }
+ }
+ }
+
+ protected void beginButton_Click(object sender, EventArgs e) {
+ if (!this.Page.IsValid) {
+ return; // don't login if custom validation failed.
+ }
+ try {
+ using (OpenIdRelyingParty rp = new OpenIdRelyingParty()) {
+ var request = rp.CreateRequest(openIdBox.Text);
+ request.IsExtensionOnly = true;
+
+ // This is where you would add any OpenID extensions you wanted
+ // to include in the request.
+ request.AddExtension(new ClaimsRequest {
+ Country = DemandLevel.Request,
+ Gender = DemandLevel.Require,
+ PostalCode = DemandLevel.Require,
+ TimeZone = DemandLevel.Require,
+ });
+
+ request.RedirectToProvider();
+ }
+ } catch (ProtocolException ex) {
+ // The user probably entered an Identifier that
+ // was not a valid OpenID endpoint.
+ this.openidValidator.Text = ex.Message;
+ this.openidValidator.IsValid = false;
+ }
+ }
+
+ protected void openidValidator_ServerValidate(object source, ServerValidateEventArgs args) {
+ // This catches common typos that result in an invalid OpenID Identifier.
+ args.IsValid = Identifier.IsValid(args.Value);
+ }
+ }
+}
diff --git a/samples/OpenIdRelyingPartyWebForms/NoIdentityOpenId.aspx.designer.cs b/samples/OpenIdRelyingPartyWebForms/NoIdentityOpenId.aspx.designer.cs
new file mode 100644
index 0000000..fb959a3
--- /dev/null
+++ b/samples/OpenIdRelyingPartyWebForms/NoIdentityOpenId.aspx.designer.cs
@@ -0,0 +1,115 @@
+//------------------------------------------------------------------------------
+// <auto-generated>
+// This code was generated by a tool.
+// Runtime Version:2.0.50727.4918
+//
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
+// </auto-generated>
+//------------------------------------------------------------------------------
+
+namespace OpenIdRelyingPartyWebForms {
+
+
+ public partial class NoIdentityOpenId {
+
+ /// <summary>
+ /// Label1 control.
+ /// </summary>
+ /// <remarks>
+ /// Auto-generated field.
+ /// To modify move field declaration from designer file to code-behind file.
+ /// </remarks>
+ protected global::System.Web.UI.WebControls.Label Label1;
+
+ /// <summary>
+ /// openIdBox control.
+ /// </summary>
+ /// <remarks>
+ /// Auto-generated field.
+ /// To modify move field declaration from designer file to code-behind file.
+ /// </remarks>
+ protected global::System.Web.UI.WebControls.TextBox openIdBox;
+
+ /// <summary>
+ /// beginButton control.
+ /// </summary>
+ /// <remarks>
+ /// Auto-generated field.
+ /// To modify move field declaration from designer file to code-behind file.
+ /// </remarks>
+ protected global::System.Web.UI.WebControls.Button beginButton;
+
+ /// <summary>
+ /// openidValidator control.
+ /// </summary>
+ /// <remarks>
+ /// Auto-generated field.
+ /// To modify move field declaration from designer file to code-behind file.
+ /// </remarks>
+ protected global::System.Web.UI.WebControls.CustomValidator openidValidator;
+
+ /// <summary>
+ /// resultMessage control.
+ /// </summary>
+ /// <remarks>
+ /// Auto-generated field.
+ /// To modify move field declaration from designer file to code-behind file.
+ /// </remarks>
+ protected global::System.Web.UI.WebControls.Label resultMessage;
+
+ /// <summary>
+ /// ExtensionResponsesPanel control.
+ /// </summary>
+ /// <remarks>
+ /// Auto-generated field.
+ /// To modify move field declaration from designer file to code-behind file.
+ /// </remarks>
+ protected global::System.Web.UI.WebControls.Panel ExtensionResponsesPanel;
+
+ /// <summary>
+ /// profileFieldsTable control.
+ /// </summary>
+ /// <remarks>
+ /// Auto-generated field.
+ /// To modify move field declaration from designer file to code-behind file.
+ /// </remarks>
+ protected global::System.Web.UI.HtmlControls.HtmlTable profileFieldsTable;
+
+ /// <summary>
+ /// genderLabel control.
+ /// </summary>
+ /// <remarks>
+ /// Auto-generated field.
+ /// To modify move field declaration from designer file to code-behind file.
+ /// </remarks>
+ protected global::System.Web.UI.WebControls.Label genderLabel;
+
+ /// <summary>
+ /// postalCodeLabel control.
+ /// </summary>
+ /// <remarks>
+ /// Auto-generated field.
+ /// To modify move field declaration from designer file to code-behind file.
+ /// </remarks>
+ protected global::System.Web.UI.WebControls.Label postalCodeLabel;
+
+ /// <summary>
+ /// countryLabel control.
+ /// </summary>
+ /// <remarks>
+ /// Auto-generated field.
+ /// To modify move field declaration from designer file to code-behind file.
+ /// </remarks>
+ protected global::System.Web.UI.WebControls.Label countryLabel;
+
+ /// <summary>
+ /// timeZoneLabel control.
+ /// </summary>
+ /// <remarks>
+ /// Auto-generated field.
+ /// To modify move field declaration from designer file to code-behind file.
+ /// </remarks>
+ protected global::System.Web.UI.WebControls.Label timeZoneLabel;
+ }
+}
diff --git a/samples/OpenIdRelyingPartyWebForms/OpenIdRelyingPartyWebForms.csproj b/samples/OpenIdRelyingPartyWebForms/OpenIdRelyingPartyWebForms.csproj
index c45f007..556dadf 100644
--- a/samples/OpenIdRelyingPartyWebForms/OpenIdRelyingPartyWebForms.csproj
+++ b/samples/OpenIdRelyingPartyWebForms/OpenIdRelyingPartyWebForms.csproj
@@ -139,6 +139,13 @@
<Compile Include="m\Login.aspx.designer.cs">
<DependentUpon>Login.aspx</DependentUpon>
</Compile>
+ <Compile Include="NoIdentityOpenId.aspx.cs">
+ <DependentUpon>NoIdentityOpenId.aspx</DependentUpon>
+ <SubType>ASPXCodeBehind</SubType>
+ </Compile>
+ <Compile Include="NoIdentityOpenId.aspx.designer.cs">
+ <DependentUpon>NoIdentityOpenId.aspx</DependentUpon>
+ </Compile>
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="TracePage.aspx.cs">
<DependentUpon>TracePage.aspx</DependentUpon>
@@ -163,6 +170,7 @@
<Content Include="MembersOnly\DisplayGoogleContacts.aspx" />
<Content Include="MembersOnly\Web.config" />
<Content Include="m\Login.aspx" />
+ <Content Include="NoIdentityOpenId.aspx" />
</ItemGroup>
<ItemGroup>
<None Include="Code\CustomStoreDataSet.xsc">
diff --git a/samples/OpenIdRelyingPartyWebForms/login.aspx.designer.cs b/samples/OpenIdRelyingPartyWebForms/login.aspx.designer.cs
index 436ef7b..d175fc8 100644
--- a/samples/OpenIdRelyingPartyWebForms/login.aspx.designer.cs
+++ b/samples/OpenIdRelyingPartyWebForms/login.aspx.designer.cs
@@ -1,7 +1,7 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
-// Runtime Version:2.0.50727.4912
+// Runtime Version:2.0.50727.4918
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
diff --git a/samples/OpenIdRelyingPartyWebForms/loginProgrammatic.aspx b/samples/OpenIdRelyingPartyWebForms/loginProgrammatic.aspx
index a00eccd..78179f7 100644
--- a/samples/OpenIdRelyingPartyWebForms/loginProgrammatic.aspx
+++ b/samples/OpenIdRelyingPartyWebForms/loginProgrammatic.aspx
@@ -12,4 +12,5 @@
Visible="False" />
<asp:Label ID="loginCanceledLabel" runat="server" EnableViewState="False" Text="Login canceled"
Visible="False" />
+ <asp:CheckBox ID="noLoginCheckBox" runat="server" Text="Extensions only (no login) -- most OPs don't yet support this" />
</asp:Content> \ No newline at end of file
diff --git a/samples/OpenIdRelyingPartyWebForms/loginProgrammatic.aspx.cs b/samples/OpenIdRelyingPartyWebForms/loginProgrammatic.aspx.cs
index fe73b7e..ed11148 100644
--- a/samples/OpenIdRelyingPartyWebForms/loginProgrammatic.aspx.cs
+++ b/samples/OpenIdRelyingPartyWebForms/loginProgrammatic.aspx.cs
@@ -41,11 +41,6 @@
// was not a valid OpenID endpoint.
this.openidValidator.Text = ex.Message;
this.openidValidator.IsValid = false;
- } catch (WebException ex) {
- // The user probably entered an Identifier that
- // was not a valid OpenID endpoint.
- this.openidValidator.Text = ex.Message;
- this.openidValidator.IsValid = false;
}
}
diff --git a/samples/OpenIdRelyingPartyWebForms/loginProgrammatic.aspx.designer.cs b/samples/OpenIdRelyingPartyWebForms/loginProgrammatic.aspx.designer.cs
index 0363be7..239d7b8 100644
--- a/samples/OpenIdRelyingPartyWebForms/loginProgrammatic.aspx.designer.cs
+++ b/samples/OpenIdRelyingPartyWebForms/loginProgrammatic.aspx.designer.cs
@@ -1,7 +1,7 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
-// Runtime Version:2.0.50727.4912
+// Runtime Version:2.0.50727.4918
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
@@ -66,5 +66,14 @@ namespace OpenIdRelyingPartyWebForms {
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.Label loginCanceledLabel;
+
+ /// <summary>
+ /// noLoginCheckBox control.
+ /// </summary>
+ /// <remarks>
+ /// Auto-generated field.
+ /// To modify move field declaration from designer file to code-behind file.
+ /// </remarks>
+ protected global::System.Web.UI.WebControls.CheckBox noLoginCheckBox;
}
}
diff --git a/samples/OpenIdRelyingPartyWebForms/xrds.aspx b/samples/OpenIdRelyingPartyWebForms/xrds.aspx
index e169bc7..9e201d0 100644
--- a/samples/OpenIdRelyingPartyWebForms/xrds.aspx
+++ b/samples/OpenIdRelyingPartyWebForms/xrds.aspx
@@ -17,6 +17,7 @@ is default.aspx.
<URI priority="1"><%=new Uri(Request.Url, Response.ApplyAppPathModifier("~/login.aspx"))%></URI>
<URI priority="2"><%=new Uri(Request.Url, Response.ApplyAppPathModifier("~/loginProgrammatic.aspx"))%></URI>
<URI priority="3"><%=new Uri(Request.Url, Response.ApplyAppPathModifier("~/ajaxlogin.aspx"))%></URI>
+ <URI priority="3"><%=new Uri(Request.Url, Response.ApplyAppPathModifier("~/NoIdentityOpenId.aspx"))%></URI>
</Service>
</XRD>
</xrds:XRDS>