diff options
Diffstat (limited to 'samples/OpenIdRelyingPartyWebForms')
43 files changed, 3654 insertions, 0 deletions
diff --git a/samples/OpenIdRelyingPartyWebForms/.gitignore b/samples/OpenIdRelyingPartyWebForms/.gitignore new file mode 100644 index 0000000..b086a60 --- /dev/null +++ b/samples/OpenIdRelyingPartyWebForms/.gitignore @@ -0,0 +1,5 @@ +Bin +obj +*.user +*.log +StyleCop.Cache diff --git a/samples/OpenIdRelyingPartyWebForms/Code/CustomStore.cs b/samples/OpenIdRelyingPartyWebForms/Code/CustomStore.cs new file mode 100644 index 0000000..2363aec --- /dev/null +++ b/samples/OpenIdRelyingPartyWebForms/Code/CustomStore.cs @@ -0,0 +1,142 @@ +namespace OpenIdRelyingPartyWebForms.Code { + using System; + using System.Data; + using System.Globalization; + using System.Security.Cryptography; + using DotNetOpenAuth.OpenId; + using DotNetOpenAuth.OpenId.RelyingParty; + + /// <summary> + /// This custom store serializes all elements to demonstrate peristent and/or shared storage. + /// This is common in a web farm, for example. + /// </summary> + /// <remarks> + /// This doesn't actually serialize anything to a persistent store, so restarting the web server + /// will still clear everything this store is supposed to remember. + /// But we "persist" all associations and nonces into a DataTable to demonstrate + /// that using a database is possible. + /// </remarks> + public class CustomStore : IRelyingPartyApplicationStore { + private static CustomStoreDataSet dataSet = new CustomStoreDataSet(); + + #region IPrivateSecretStore Members + + /// <summary> + /// Gets or sets a secret key that can be used for signing. + /// </summary> + /// <value>A 64-byte binary value, which may contain null bytes.</value> + public byte[] PrivateSecret { get; set; } + + #endregion + + #region INonceStore Members + + /// <summary> + /// Stores a given nonce and timestamp. + /// </summary> + /// <param name="context">The context, or namespace, within which the + /// <paramref name="nonce"/> must be unique. + /// The context SHOULD be treated as case-sensitive. + /// The value will never be <c>null</c> but may be the empty string.</param> + /// <param name="nonce">A series of random characters.</param> + /// <param name="timestamp">The timestamp that together with the nonce string make it unique. + /// The timestamp may also be used by the data store to clear out old nonces.</param> + /// <returns> + /// True if the nonce+timestamp (combination) was not previously in the database. + /// False if the nonce was stored previously with the same timestamp. + /// </returns> + /// <remarks> + /// The nonce must be stored for no less than the maximum time window a message may + /// be processed within before being discarded as an expired message. + /// If the binding element is applicable to your channel, this expiration window + /// is retrieved or set using the + /// <see cref="StandardExpirationBindingElement.MaximumMessageAge"/> property. + /// </remarks> + public bool StoreNonce(string context, string nonce, DateTime timestamp) { + // IMPORTANT: If actually persisting to a database that can be reached from + // different servers/instances of this class at once, it is vitally important + // to protect against race condition attacks by one or more of these: + // 1) setting a UNIQUE constraint on the nonce CODE in the SQL table + // 2) Using a transaction with repeatable reads to guarantee that a check + // that verified a nonce did not exist will prevent that nonce from being + // added by another process while this process is adding it. + // And then you'll want to catch the exception that the SQL database can throw + // at you in the result of a race condition somewhere in your web site UI code + // and display some message to have the user try to log in again, and possibly + // warn them about a replay attack. + lock (this) { + if (dataSet.Nonce.FindByCodeContext(nonce, context) != null) { + return false; + } + + TimeSpan maxMessageAge = DotNetOpenAuth.Configuration.DotNetOpenAuthSection.Configuration.Messaging.MaximumMessageLifetime; + dataSet.Nonce.AddNonceRow(context, nonce, timestamp.ToLocalTime(), (timestamp + maxMessageAge).ToLocalTime()); + return true; + } + } + + public void ClearExpiredNonces() { + this.removeExpiredRows(dataSet.Nonce, dataSet.Nonce.ExpiresColumn.ColumnName); + } + + #endregion + + #region IAssociationStore<Uri> Members + + public void StoreAssociation(Uri distinguishingFactor, Association assoc) { + var assocRow = dataSet.Association.NewAssociationRow(); + assocRow.DistinguishingFactor = distinguishingFactor.AbsoluteUri; + assocRow.Handle = assoc.Handle; + assocRow.Expires = assoc.Expires.ToLocalTime(); + assocRow.PrivateData = assoc.SerializePrivateData(); + dataSet.Association.AddAssociationRow(assocRow); + } + + public Association GetAssociation(Uri distinguishingFactor, SecuritySettings securitySettings) { + // TODO: properly consider the securitySettings when picking an association to return. + // properly escape the URL to prevent injection attacks. + string value = distinguishingFactor.AbsoluteUri.Replace("'", "''"); + string filter = string.Format( + CultureInfo.InvariantCulture, + "{0} = '{1}'", + dataSet.Association.DistinguishingFactorColumn.ColumnName, + value); + string sort = dataSet.Association.ExpiresColumn.ColumnName + " DESC"; + DataView view = new DataView(dataSet.Association, filter, sort, DataViewRowState.CurrentRows); + if (view.Count == 0) { + return null; + } + var row = (CustomStoreDataSet.AssociationRow)view[0].Row; + return Association.Deserialize(row.Handle, row.Expires.ToUniversalTime(), row.PrivateData); + } + + public Association GetAssociation(Uri distinguishingFactor, string handle) { + var assocRow = dataSet.Association.FindByDistinguishingFactorHandle(distinguishingFactor.AbsoluteUri, handle); + return Association.Deserialize(assocRow.Handle, assocRow.Expires, assocRow.PrivateData); + } + + public bool RemoveAssociation(Uri distinguishingFactor, string handle) { + var row = dataSet.Association.FindByDistinguishingFactorHandle(distinguishingFactor.AbsoluteUri, handle); + if (row != null) { + dataSet.Association.RemoveAssociationRow(row); + return true; + } else { + return false; + } + } + + public void ClearExpiredAssociations() { + this.removeExpiredRows(dataSet.Association, dataSet.Association.ExpiresColumn.ColumnName); + } + + #endregion + + private void removeExpiredRows(DataTable table, string expiredColumnName) { + string filter = string.Format(CultureInfo.InvariantCulture, "{0} < #{1}#", expiredColumnName, DateTime.Now); + DataView view = new DataView(table, filter, null, DataViewRowState.CurrentRows); + for (int i = view.Count - 1; i >= 0; i--) { + view.Delete(i); + } + } + } +} diff --git a/samples/OpenIdRelyingPartyWebForms/Code/CustomStoreDataSet.Designer.cs b/samples/OpenIdRelyingPartyWebForms/Code/CustomStoreDataSet.Designer.cs new file mode 100644 index 0000000..beacfc4 --- /dev/null +++ b/samples/OpenIdRelyingPartyWebForms/Code/CustomStoreDataSet.Designer.cs @@ -0,0 +1,976 @@ +//------------------------------------------------------------------------------ +// <auto-generated> +// This code was generated by a tool. +// Runtime Version:2.0.50727.3053 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// </auto-generated> +//------------------------------------------------------------------------------ + +#pragma warning disable 1591 + +namespace OpenIdRelyingPartyWebForms { + + + /// <summary> + ///Represents a strongly typed in-memory cache of data. + ///</summary> + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "2.0.0.0")] + [global::System.Serializable()] + [global::System.ComponentModel.DesignerCategoryAttribute("code")] + [global::System.ComponentModel.ToolboxItem(true)] + [global::System.Xml.Serialization.XmlSchemaProviderAttribute("GetTypedDataSetSchema")] + [global::System.Xml.Serialization.XmlRootAttribute("CustomStoreDataSet")] + [global::System.ComponentModel.Design.HelpKeywordAttribute("vs.data.DataSet")] + public partial class CustomStoreDataSet : global::System.Data.DataSet { + + private AssociationDataTable tableAssociation; + + private NonceDataTable tableNonce; + + private global::System.Data.SchemaSerializationMode _schemaSerializationMode = global::System.Data.SchemaSerializationMode.IncludeSchema; + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public CustomStoreDataSet() { + this.BeginInit(); + this.InitClass(); + global::System.ComponentModel.CollectionChangeEventHandler schemaChangedHandler = new global::System.ComponentModel.CollectionChangeEventHandler(this.SchemaChanged); + base.Tables.CollectionChanged += schemaChangedHandler; + base.Relations.CollectionChanged += schemaChangedHandler; + this.EndInit(); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + protected CustomStoreDataSet(global::System.Runtime.Serialization.SerializationInfo info, global::System.Runtime.Serialization.StreamingContext context) : + base(info, context, false) { + if ((this.IsBinarySerialized(info, context) == true)) { + this.InitVars(false); + global::System.ComponentModel.CollectionChangeEventHandler schemaChangedHandler1 = new global::System.ComponentModel.CollectionChangeEventHandler(this.SchemaChanged); + this.Tables.CollectionChanged += schemaChangedHandler1; + this.Relations.CollectionChanged += schemaChangedHandler1; + return; + } + string strSchema = ((string)(info.GetValue("XmlSchema", typeof(string)))); + if ((this.DetermineSchemaSerializationMode(info, context) == global::System.Data.SchemaSerializationMode.IncludeSchema)) { + global::System.Data.DataSet ds = new global::System.Data.DataSet(); + ds.ReadXmlSchema(new global::System.Xml.XmlTextReader(new global::System.IO.StringReader(strSchema))); + if ((ds.Tables["Association"] != null)) { + base.Tables.Add(new AssociationDataTable(ds.Tables["Association"])); + } + if ((ds.Tables["Nonce"] != null)) { + base.Tables.Add(new NonceDataTable(ds.Tables["Nonce"])); + } + this.DataSetName = ds.DataSetName; + this.Prefix = ds.Prefix; + this.Namespace = ds.Namespace; + this.Locale = ds.Locale; + this.CaseSensitive = ds.CaseSensitive; + this.EnforceConstraints = ds.EnforceConstraints; + this.Merge(ds, false, global::System.Data.MissingSchemaAction.Add); + this.InitVars(); + } + else { + this.ReadXmlSchema(new global::System.Xml.XmlTextReader(new global::System.IO.StringReader(strSchema))); + } + this.GetSerializationData(info, context); + global::System.ComponentModel.CollectionChangeEventHandler schemaChangedHandler = new global::System.ComponentModel.CollectionChangeEventHandler(this.SchemaChanged); + base.Tables.CollectionChanged += schemaChangedHandler; + this.Relations.CollectionChanged += schemaChangedHandler; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.ComponentModel.Browsable(false)] + [global::System.ComponentModel.DesignerSerializationVisibility(global::System.ComponentModel.DesignerSerializationVisibility.Content)] + public AssociationDataTable Association { + get { + return this.tableAssociation; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.ComponentModel.Browsable(false)] + [global::System.ComponentModel.DesignerSerializationVisibility(global::System.ComponentModel.DesignerSerializationVisibility.Content)] + public NonceDataTable Nonce { + get { + return this.tableNonce; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.ComponentModel.BrowsableAttribute(true)] + [global::System.ComponentModel.DesignerSerializationVisibilityAttribute(global::System.ComponentModel.DesignerSerializationVisibility.Visible)] + public override global::System.Data.SchemaSerializationMode SchemaSerializationMode { + get { + return this._schemaSerializationMode; + } + set { + this._schemaSerializationMode = value; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.ComponentModel.DesignerSerializationVisibilityAttribute(global::System.ComponentModel.DesignerSerializationVisibility.Hidden)] + public new global::System.Data.DataTableCollection Tables { + get { + return base.Tables; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.ComponentModel.DesignerSerializationVisibilityAttribute(global::System.ComponentModel.DesignerSerializationVisibility.Hidden)] + public new global::System.Data.DataRelationCollection Relations { + get { + return base.Relations; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + protected override void InitializeDerivedDataSet() { + this.BeginInit(); + this.InitClass(); + this.EndInit(); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public override global::System.Data.DataSet Clone() { + CustomStoreDataSet cln = ((CustomStoreDataSet)(base.Clone())); + cln.InitVars(); + cln.SchemaSerializationMode = this.SchemaSerializationMode; + return cln; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + protected override bool ShouldSerializeTables() { + return false; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + protected override bool ShouldSerializeRelations() { + return false; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + protected override void ReadXmlSerializable(global::System.Xml.XmlReader reader) { + if ((this.DetermineSchemaSerializationMode(reader) == global::System.Data.SchemaSerializationMode.IncludeSchema)) { + this.Reset(); + global::System.Data.DataSet ds = new global::System.Data.DataSet(); + ds.ReadXml(reader); + if ((ds.Tables["Association"] != null)) { + base.Tables.Add(new AssociationDataTable(ds.Tables["Association"])); + } + if ((ds.Tables["Nonce"] != null)) { + base.Tables.Add(new NonceDataTable(ds.Tables["Nonce"])); + } + this.DataSetName = ds.DataSetName; + this.Prefix = ds.Prefix; + this.Namespace = ds.Namespace; + this.Locale = ds.Locale; + this.CaseSensitive = ds.CaseSensitive; + this.EnforceConstraints = ds.EnforceConstraints; + this.Merge(ds, false, global::System.Data.MissingSchemaAction.Add); + this.InitVars(); + } + else { + this.ReadXml(reader); + this.InitVars(); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + protected override global::System.Xml.Schema.XmlSchema GetSchemaSerializable() { + global::System.IO.MemoryStream stream = new global::System.IO.MemoryStream(); + this.WriteXmlSchema(new global::System.Xml.XmlTextWriter(stream, null)); + stream.Position = 0; + return global::System.Xml.Schema.XmlSchema.Read(new global::System.Xml.XmlTextReader(stream), null); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + internal void InitVars() { + this.InitVars(true); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + internal void InitVars(bool initTable) { + this.tableAssociation = ((AssociationDataTable)(base.Tables["Association"])); + if ((initTable == true)) { + if ((this.tableAssociation != null)) { + this.tableAssociation.InitVars(); + } + } + this.tableNonce = ((NonceDataTable)(base.Tables["Nonce"])); + if ((initTable == true)) { + if ((this.tableNonce != null)) { + this.tableNonce.InitVars(); + } + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + private void InitClass() { + this.DataSetName = "CustomStoreDataSet"; + this.Prefix = ""; + this.Namespace = "http://tempuri.org/CustomStoreDataSet.xsd"; + this.EnforceConstraints = true; + this.SchemaSerializationMode = global::System.Data.SchemaSerializationMode.IncludeSchema; + this.tableAssociation = new AssociationDataTable(); + base.Tables.Add(this.tableAssociation); + this.tableNonce = new NonceDataTable(); + base.Tables.Add(this.tableNonce); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + private bool ShouldSerializeAssociation() { + return false; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + private bool ShouldSerializeNonce() { + return false; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + private void SchemaChanged(object sender, global::System.ComponentModel.CollectionChangeEventArgs e) { + if ((e.Action == global::System.ComponentModel.CollectionChangeAction.Remove)) { + this.InitVars(); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public static global::System.Xml.Schema.XmlSchemaComplexType GetTypedDataSetSchema(global::System.Xml.Schema.XmlSchemaSet xs) { + CustomStoreDataSet ds = new CustomStoreDataSet(); + global::System.Xml.Schema.XmlSchemaComplexType type = new global::System.Xml.Schema.XmlSchemaComplexType(); + global::System.Xml.Schema.XmlSchemaSequence sequence = new global::System.Xml.Schema.XmlSchemaSequence(); + global::System.Xml.Schema.XmlSchemaAny any = new global::System.Xml.Schema.XmlSchemaAny(); + any.Namespace = ds.Namespace; + sequence.Items.Add(any); + type.Particle = sequence; + global::System.Xml.Schema.XmlSchema dsSchema = ds.GetSchemaSerializable(); + if (xs.Contains(dsSchema.TargetNamespace)) { + global::System.IO.MemoryStream s1 = new global::System.IO.MemoryStream(); + global::System.IO.MemoryStream s2 = new global::System.IO.MemoryStream(); + try { + global::System.Xml.Schema.XmlSchema schema = null; + dsSchema.Write(s1); + for (global::System.Collections.IEnumerator schemas = xs.Schemas(dsSchema.TargetNamespace).GetEnumerator(); schemas.MoveNext(); ) { + schema = ((global::System.Xml.Schema.XmlSchema)(schemas.Current)); + s2.SetLength(0); + schema.Write(s2); + if ((s1.Length == s2.Length)) { + s1.Position = 0; + s2.Position = 0; + for (; ((s1.Position != s1.Length) + && (s1.ReadByte() == s2.ReadByte())); ) { + ; + } + if ((s1.Position == s1.Length)) { + return type; + } + } + } + } + finally { + if ((s1 != null)) { + s1.Close(); + } + if ((s2 != null)) { + s2.Close(); + } + } + } + xs.Add(dsSchema); + return type; + } + + public delegate void AssociationRowChangeEventHandler(object sender, AssociationRowChangeEvent e); + + public delegate void NonceRowChangeEventHandler(object sender, NonceRowChangeEvent e); + + /// <summary> + ///Represents the strongly named DataTable class. + ///</summary> + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "2.0.0.0")] + [global::System.Serializable()] + [global::System.Xml.Serialization.XmlSchemaProviderAttribute("GetTypedTableSchema")] + public partial class AssociationDataTable : global::System.Data.DataTable, global::System.Collections.IEnumerable { + + private global::System.Data.DataColumn columnDistinguishingFactor; + + private global::System.Data.DataColumn columnHandle; + + private global::System.Data.DataColumn columnExpires; + + private global::System.Data.DataColumn columnPrivateData; + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public AssociationDataTable() { + this.TableName = "Association"; + this.BeginInit(); + this.InitClass(); + this.EndInit(); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + internal AssociationDataTable(global::System.Data.DataTable table) { + this.TableName = table.TableName; + if ((table.CaseSensitive != table.DataSet.CaseSensitive)) { + this.CaseSensitive = table.CaseSensitive; + } + if ((table.Locale.ToString() != table.DataSet.Locale.ToString())) { + this.Locale = table.Locale; + } + if ((table.Namespace != table.DataSet.Namespace)) { + this.Namespace = table.Namespace; + } + this.Prefix = table.Prefix; + this.MinimumCapacity = table.MinimumCapacity; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + protected AssociationDataTable(global::System.Runtime.Serialization.SerializationInfo info, global::System.Runtime.Serialization.StreamingContext context) : + base(info, context) { + this.InitVars(); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public global::System.Data.DataColumn DistinguishingFactorColumn { + get { + return this.columnDistinguishingFactor; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public global::System.Data.DataColumn HandleColumn { + get { + return this.columnHandle; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public global::System.Data.DataColumn ExpiresColumn { + get { + return this.columnExpires; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public global::System.Data.DataColumn PrivateDataColumn { + get { + return this.columnPrivateData; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.ComponentModel.Browsable(false)] + public int Count { + get { + return this.Rows.Count; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public AssociationRow this[int index] { + get { + return ((AssociationRow)(this.Rows[index])); + } + } + + public event AssociationRowChangeEventHandler AssociationRowChanging; + + public event AssociationRowChangeEventHandler AssociationRowChanged; + + public event AssociationRowChangeEventHandler AssociationRowDeleting; + + public event AssociationRowChangeEventHandler AssociationRowDeleted; + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public void AddAssociationRow(AssociationRow row) { + this.Rows.Add(row); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public AssociationRow AddAssociationRow(string DistinguishingFactor, string Handle, System.DateTime Expires, byte[] PrivateData) { + AssociationRow rowAssociationRow = ((AssociationRow)(this.NewRow())); + object[] columnValuesArray = new object[] { + DistinguishingFactor, + Handle, + Expires, + PrivateData}; + rowAssociationRow.ItemArray = columnValuesArray; + this.Rows.Add(rowAssociationRow); + return rowAssociationRow; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public AssociationRow FindByDistinguishingFactorHandle(string DistinguishingFactor, string Handle) { + return ((AssociationRow)(this.Rows.Find(new object[] { + DistinguishingFactor, + Handle}))); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public virtual global::System.Collections.IEnumerator GetEnumerator() { + return this.Rows.GetEnumerator(); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public override global::System.Data.DataTable Clone() { + AssociationDataTable cln = ((AssociationDataTable)(base.Clone())); + cln.InitVars(); + return cln; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + protected override global::System.Data.DataTable CreateInstance() { + return new AssociationDataTable(); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + internal void InitVars() { + this.columnDistinguishingFactor = base.Columns["DistinguishingFactor"]; + this.columnHandle = base.Columns["Handle"]; + this.columnExpires = base.Columns["Expires"]; + this.columnPrivateData = base.Columns["PrivateData"]; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + private void InitClass() { + this.columnDistinguishingFactor = new global::System.Data.DataColumn("DistinguishingFactor", typeof(string), null, global::System.Data.MappingType.Element); + base.Columns.Add(this.columnDistinguishingFactor); + this.columnHandle = new global::System.Data.DataColumn("Handle", typeof(string), null, global::System.Data.MappingType.Element); + base.Columns.Add(this.columnHandle); + this.columnExpires = new global::System.Data.DataColumn("Expires", typeof(global::System.DateTime), null, global::System.Data.MappingType.Element); + base.Columns.Add(this.columnExpires); + this.columnPrivateData = new global::System.Data.DataColumn("PrivateData", typeof(byte[]), null, global::System.Data.MappingType.Element); + base.Columns.Add(this.columnPrivateData); + this.Constraints.Add(new global::System.Data.UniqueConstraint("PrimaryKey", new global::System.Data.DataColumn[] { + this.columnDistinguishingFactor, + this.columnHandle}, true)); + this.columnDistinguishingFactor.AllowDBNull = false; + this.columnHandle.AllowDBNull = false; + this.columnExpires.AllowDBNull = false; + this.columnPrivateData.AllowDBNull = false; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public AssociationRow NewAssociationRow() { + return ((AssociationRow)(this.NewRow())); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + protected override global::System.Data.DataRow NewRowFromBuilder(global::System.Data.DataRowBuilder builder) { + return new AssociationRow(builder); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + protected override global::System.Type GetRowType() { + return typeof(AssociationRow); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + protected override void OnRowChanged(global::System.Data.DataRowChangeEventArgs e) { + base.OnRowChanged(e); + if ((this.AssociationRowChanged != null)) { + this.AssociationRowChanged(this, new AssociationRowChangeEvent(((AssociationRow)(e.Row)), e.Action)); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + protected override void OnRowChanging(global::System.Data.DataRowChangeEventArgs e) { + base.OnRowChanging(e); + if ((this.AssociationRowChanging != null)) { + this.AssociationRowChanging(this, new AssociationRowChangeEvent(((AssociationRow)(e.Row)), e.Action)); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + protected override void OnRowDeleted(global::System.Data.DataRowChangeEventArgs e) { + base.OnRowDeleted(e); + if ((this.AssociationRowDeleted != null)) { + this.AssociationRowDeleted(this, new AssociationRowChangeEvent(((AssociationRow)(e.Row)), e.Action)); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + protected override void OnRowDeleting(global::System.Data.DataRowChangeEventArgs e) { + base.OnRowDeleting(e); + if ((this.AssociationRowDeleting != null)) { + this.AssociationRowDeleting(this, new AssociationRowChangeEvent(((AssociationRow)(e.Row)), e.Action)); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public void RemoveAssociationRow(AssociationRow row) { + this.Rows.Remove(row); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public static global::System.Xml.Schema.XmlSchemaComplexType GetTypedTableSchema(global::System.Xml.Schema.XmlSchemaSet xs) { + global::System.Xml.Schema.XmlSchemaComplexType type = new global::System.Xml.Schema.XmlSchemaComplexType(); + global::System.Xml.Schema.XmlSchemaSequence sequence = new global::System.Xml.Schema.XmlSchemaSequence(); + CustomStoreDataSet ds = new CustomStoreDataSet(); + global::System.Xml.Schema.XmlSchemaAny any1 = new global::System.Xml.Schema.XmlSchemaAny(); + any1.Namespace = "http://www.w3.org/2001/XMLSchema"; + any1.MinOccurs = new decimal(0); + any1.MaxOccurs = decimal.MaxValue; + any1.ProcessContents = global::System.Xml.Schema.XmlSchemaContentProcessing.Lax; + sequence.Items.Add(any1); + global::System.Xml.Schema.XmlSchemaAny any2 = new global::System.Xml.Schema.XmlSchemaAny(); + any2.Namespace = "urn:schemas-microsoft-com:xml-diffgram-v1"; + any2.MinOccurs = new decimal(1); + any2.ProcessContents = global::System.Xml.Schema.XmlSchemaContentProcessing.Lax; + sequence.Items.Add(any2); + global::System.Xml.Schema.XmlSchemaAttribute attribute1 = new global::System.Xml.Schema.XmlSchemaAttribute(); + attribute1.Name = "namespace"; + attribute1.FixedValue = ds.Namespace; + type.Attributes.Add(attribute1); + global::System.Xml.Schema.XmlSchemaAttribute attribute2 = new global::System.Xml.Schema.XmlSchemaAttribute(); + attribute2.Name = "tableTypeName"; + attribute2.FixedValue = "AssociationDataTable"; + type.Attributes.Add(attribute2); + type.Particle = sequence; + global::System.Xml.Schema.XmlSchema dsSchema = ds.GetSchemaSerializable(); + if (xs.Contains(dsSchema.TargetNamespace)) { + global::System.IO.MemoryStream s1 = new global::System.IO.MemoryStream(); + global::System.IO.MemoryStream s2 = new global::System.IO.MemoryStream(); + try { + global::System.Xml.Schema.XmlSchema schema = null; + dsSchema.Write(s1); + for (global::System.Collections.IEnumerator schemas = xs.Schemas(dsSchema.TargetNamespace).GetEnumerator(); schemas.MoveNext(); ) { + schema = ((global::System.Xml.Schema.XmlSchema)(schemas.Current)); + s2.SetLength(0); + schema.Write(s2); + if ((s1.Length == s2.Length)) { + s1.Position = 0; + s2.Position = 0; + for (; ((s1.Position != s1.Length) + && (s1.ReadByte() == s2.ReadByte())); ) { + ; + } + if ((s1.Position == s1.Length)) { + return type; + } + } + } + } + finally { + if ((s1 != null)) { + s1.Close(); + } + if ((s2 != null)) { + s2.Close(); + } + } + } + xs.Add(dsSchema); + return type; + } + } + + /// <summary> + ///Represents the strongly named DataTable class. + ///</summary> + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "2.0.0.0")] + [global::System.Serializable()] + [global::System.Xml.Serialization.XmlSchemaProviderAttribute("GetTypedTableSchema")] + public partial class NonceDataTable : global::System.Data.DataTable, global::System.Collections.IEnumerable { + + private global::System.Data.DataColumn columnCode; + + private global::System.Data.DataColumn columnExpires; + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public NonceDataTable() { + this.TableName = "Nonce"; + this.BeginInit(); + this.InitClass(); + this.EndInit(); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + internal NonceDataTable(global::System.Data.DataTable table) { + this.TableName = table.TableName; + if ((table.CaseSensitive != table.DataSet.CaseSensitive)) { + this.CaseSensitive = table.CaseSensitive; + } + if ((table.Locale.ToString() != table.DataSet.Locale.ToString())) { + this.Locale = table.Locale; + } + if ((table.Namespace != table.DataSet.Namespace)) { + this.Namespace = table.Namespace; + } + this.Prefix = table.Prefix; + this.MinimumCapacity = table.MinimumCapacity; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + protected NonceDataTable(global::System.Runtime.Serialization.SerializationInfo info, global::System.Runtime.Serialization.StreamingContext context) : + base(info, context) { + this.InitVars(); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public global::System.Data.DataColumn CodeColumn { + get { + return this.columnCode; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public global::System.Data.DataColumn ExpiresColumn { + get { + return this.columnExpires; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.ComponentModel.Browsable(false)] + public int Count { + get { + return this.Rows.Count; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public NonceRow this[int index] { + get { + return ((NonceRow)(this.Rows[index])); + } + } + + public event NonceRowChangeEventHandler NonceRowChanging; + + public event NonceRowChangeEventHandler NonceRowChanged; + + public event NonceRowChangeEventHandler NonceRowDeleting; + + public event NonceRowChangeEventHandler NonceRowDeleted; + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public void AddNonceRow(NonceRow row) { + this.Rows.Add(row); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public NonceRow AddNonceRow(string Code, System.DateTime Expires) { + NonceRow rowNonceRow = ((NonceRow)(this.NewRow())); + object[] columnValuesArray = new object[] { + Code, + Expires}; + rowNonceRow.ItemArray = columnValuesArray; + this.Rows.Add(rowNonceRow); + return rowNonceRow; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public NonceRow FindByCode(string Code) { + return ((NonceRow)(this.Rows.Find(new object[] { + Code}))); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public virtual global::System.Collections.IEnumerator GetEnumerator() { + return this.Rows.GetEnumerator(); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public override global::System.Data.DataTable Clone() { + NonceDataTable cln = ((NonceDataTable)(base.Clone())); + cln.InitVars(); + return cln; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + protected override global::System.Data.DataTable CreateInstance() { + return new NonceDataTable(); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + internal void InitVars() { + this.columnCode = base.Columns["Code"]; + this.columnExpires = base.Columns["Expires"]; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + private void InitClass() { + this.columnCode = new global::System.Data.DataColumn("Code", typeof(string), null, global::System.Data.MappingType.Element); + base.Columns.Add(this.columnCode); + this.columnExpires = new global::System.Data.DataColumn("Expires", typeof(global::System.DateTime), null, global::System.Data.MappingType.Element); + base.Columns.Add(this.columnExpires); + this.Constraints.Add(new global::System.Data.UniqueConstraint("PrimaryKey", new global::System.Data.DataColumn[] { + this.columnCode}, true)); + this.columnCode.AllowDBNull = false; + this.columnCode.Unique = true; + this.columnExpires.AllowDBNull = false; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public NonceRow NewNonceRow() { + return ((NonceRow)(this.NewRow())); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + protected override global::System.Data.DataRow NewRowFromBuilder(global::System.Data.DataRowBuilder builder) { + return new NonceRow(builder); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + protected override global::System.Type GetRowType() { + return typeof(NonceRow); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + protected override void OnRowChanged(global::System.Data.DataRowChangeEventArgs e) { + base.OnRowChanged(e); + if ((this.NonceRowChanged != null)) { + this.NonceRowChanged(this, new NonceRowChangeEvent(((NonceRow)(e.Row)), e.Action)); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + protected override void OnRowChanging(global::System.Data.DataRowChangeEventArgs e) { + base.OnRowChanging(e); + if ((this.NonceRowChanging != null)) { + this.NonceRowChanging(this, new NonceRowChangeEvent(((NonceRow)(e.Row)), e.Action)); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + protected override void OnRowDeleted(global::System.Data.DataRowChangeEventArgs e) { + base.OnRowDeleted(e); + if ((this.NonceRowDeleted != null)) { + this.NonceRowDeleted(this, new NonceRowChangeEvent(((NonceRow)(e.Row)), e.Action)); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + protected override void OnRowDeleting(global::System.Data.DataRowChangeEventArgs e) { + base.OnRowDeleting(e); + if ((this.NonceRowDeleting != null)) { + this.NonceRowDeleting(this, new NonceRowChangeEvent(((NonceRow)(e.Row)), e.Action)); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public void RemoveNonceRow(NonceRow row) { + this.Rows.Remove(row); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public static global::System.Xml.Schema.XmlSchemaComplexType GetTypedTableSchema(global::System.Xml.Schema.XmlSchemaSet xs) { + global::System.Xml.Schema.XmlSchemaComplexType type = new global::System.Xml.Schema.XmlSchemaComplexType(); + global::System.Xml.Schema.XmlSchemaSequence sequence = new global::System.Xml.Schema.XmlSchemaSequence(); + CustomStoreDataSet ds = new CustomStoreDataSet(); + global::System.Xml.Schema.XmlSchemaAny any1 = new global::System.Xml.Schema.XmlSchemaAny(); + any1.Namespace = "http://www.w3.org/2001/XMLSchema"; + any1.MinOccurs = new decimal(0); + any1.MaxOccurs = decimal.MaxValue; + any1.ProcessContents = global::System.Xml.Schema.XmlSchemaContentProcessing.Lax; + sequence.Items.Add(any1); + global::System.Xml.Schema.XmlSchemaAny any2 = new global::System.Xml.Schema.XmlSchemaAny(); + any2.Namespace = "urn:schemas-microsoft-com:xml-diffgram-v1"; + any2.MinOccurs = new decimal(1); + any2.ProcessContents = global::System.Xml.Schema.XmlSchemaContentProcessing.Lax; + sequence.Items.Add(any2); + global::System.Xml.Schema.XmlSchemaAttribute attribute1 = new global::System.Xml.Schema.XmlSchemaAttribute(); + attribute1.Name = "namespace"; + attribute1.FixedValue = ds.Namespace; + type.Attributes.Add(attribute1); + global::System.Xml.Schema.XmlSchemaAttribute attribute2 = new global::System.Xml.Schema.XmlSchemaAttribute(); + attribute2.Name = "tableTypeName"; + attribute2.FixedValue = "NonceDataTable"; + type.Attributes.Add(attribute2); + type.Particle = sequence; + global::System.Xml.Schema.XmlSchema dsSchema = ds.GetSchemaSerializable(); + if (xs.Contains(dsSchema.TargetNamespace)) { + global::System.IO.MemoryStream s1 = new global::System.IO.MemoryStream(); + global::System.IO.MemoryStream s2 = new global::System.IO.MemoryStream(); + try { + global::System.Xml.Schema.XmlSchema schema = null; + dsSchema.Write(s1); + for (global::System.Collections.IEnumerator schemas = xs.Schemas(dsSchema.TargetNamespace).GetEnumerator(); schemas.MoveNext(); ) { + schema = ((global::System.Xml.Schema.XmlSchema)(schemas.Current)); + s2.SetLength(0); + schema.Write(s2); + if ((s1.Length == s2.Length)) { + s1.Position = 0; + s2.Position = 0; + for (; ((s1.Position != s1.Length) + && (s1.ReadByte() == s2.ReadByte())); ) { + ; + } + if ((s1.Position == s1.Length)) { + return type; + } + } + } + } + finally { + if ((s1 != null)) { + s1.Close(); + } + if ((s2 != null)) { + s2.Close(); + } + } + } + xs.Add(dsSchema); + return type; + } + } + + /// <summary> + ///Represents strongly named DataRow class. + ///</summary> + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "2.0.0.0")] + public partial class AssociationRow : global::System.Data.DataRow { + + private AssociationDataTable tableAssociation; + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + internal AssociationRow(global::System.Data.DataRowBuilder rb) : + base(rb) { + this.tableAssociation = ((AssociationDataTable)(this.Table)); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public string DistinguishingFactor { + get { + return ((string)(this[this.tableAssociation.DistinguishingFactorColumn])); + } + set { + this[this.tableAssociation.DistinguishingFactorColumn] = value; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public string Handle { + get { + return ((string)(this[this.tableAssociation.HandleColumn])); + } + set { + this[this.tableAssociation.HandleColumn] = value; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public System.DateTime Expires { + get { + return ((global::System.DateTime)(this[this.tableAssociation.ExpiresColumn])); + } + set { + this[this.tableAssociation.ExpiresColumn] = value; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public byte[] PrivateData { + get { + return ((byte[])(this[this.tableAssociation.PrivateDataColumn])); + } + set { + this[this.tableAssociation.PrivateDataColumn] = value; + } + } + } + + /// <summary> + ///Represents strongly named DataRow class. + ///</summary> + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "2.0.0.0")] + public partial class NonceRow : global::System.Data.DataRow { + + private NonceDataTable tableNonce; + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + internal NonceRow(global::System.Data.DataRowBuilder rb) : + base(rb) { + this.tableNonce = ((NonceDataTable)(this.Table)); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public string Code { + get { + return ((string)(this[this.tableNonce.CodeColumn])); + } + set { + this[this.tableNonce.CodeColumn] = value; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public System.DateTime Expires { + get { + return ((global::System.DateTime)(this[this.tableNonce.ExpiresColumn])); + } + set { + this[this.tableNonce.ExpiresColumn] = value; + } + } + } + + /// <summary> + ///Row event argument class + ///</summary> + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "2.0.0.0")] + public class AssociationRowChangeEvent : global::System.EventArgs { + + private AssociationRow eventRow; + + private global::System.Data.DataRowAction eventAction; + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public AssociationRowChangeEvent(AssociationRow row, global::System.Data.DataRowAction action) { + this.eventRow = row; + this.eventAction = action; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public AssociationRow Row { + get { + return this.eventRow; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public global::System.Data.DataRowAction Action { + get { + return this.eventAction; + } + } + } + + /// <summary> + ///Row event argument class + ///</summary> + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "2.0.0.0")] + public class NonceRowChangeEvent : global::System.EventArgs { + + private NonceRow eventRow; + + private global::System.Data.DataRowAction eventAction; + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public NonceRowChangeEvent(NonceRow row, global::System.Data.DataRowAction action) { + this.eventRow = row; + this.eventAction = action; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public NonceRow Row { + get { + return this.eventRow; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public global::System.Data.DataRowAction Action { + get { + return this.eventAction; + } + } + } + } +} + +#pragma warning restore 1591
\ No newline at end of file diff --git a/samples/OpenIdRelyingPartyWebForms/Code/CustomStoreDataSet.cs b/samples/OpenIdRelyingPartyWebForms/Code/CustomStoreDataSet.cs new file mode 100644 index 0000000..abc77e9 --- /dev/null +++ b/samples/OpenIdRelyingPartyWebForms/Code/CustomStoreDataSet.cs @@ -0,0 +1,4 @@ +namespace OpenIdRelyingPartyWebForms.Code { + public partial class CustomStoreDataSet { + } +} diff --git a/samples/OpenIdRelyingPartyWebForms/Code/CustomStoreDataSet.xsc b/samples/OpenIdRelyingPartyWebForms/Code/CustomStoreDataSet.xsc new file mode 100644 index 0000000..05b0199 --- /dev/null +++ b/samples/OpenIdRelyingPartyWebForms/Code/CustomStoreDataSet.xsc @@ -0,0 +1,9 @@ +<?xml version="1.0" encoding="utf-8"?> +<!--<autogenerated> + This code was generated by a tool. + Changes to this file may cause incorrect behavior and will be lost if + the code is regenerated. +</autogenerated>--> +<DataSetUISetting Version="1.00" xmlns="urn:schemas-microsoft-com:xml-msdatasource"> + <TableUISettings /> +</DataSetUISetting>
\ No newline at end of file diff --git a/samples/OpenIdRelyingPartyWebForms/Code/CustomStoreDataSet.xsd b/samples/OpenIdRelyingPartyWebForms/Code/CustomStoreDataSet.xsd new file mode 100644 index 0000000..b80310e --- /dev/null +++ b/samples/OpenIdRelyingPartyWebForms/Code/CustomStoreDataSet.xsd @@ -0,0 +1,48 @@ +<?xml version="1.0" encoding="utf-8"?> +<xs:schema id="CustomStoreDataSet" targetNamespace="http://tempuri.org/CustomStoreDataSet.xsd" xmlns:mstns="http://tempuri.org/CustomStoreDataSet.xsd" xmlns="http://tempuri.org/CustomStoreDataSet.xsd" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" xmlns:msprop="urn:schemas-microsoft-com:xml-msprop" attributeFormDefault="qualified" elementFormDefault="qualified"> + <xs:annotation> + <xs:appinfo source="urn:schemas-microsoft-com:xml-msdatasource"> + <DataSource DefaultConnectionIndex="0" FunctionsComponentName="QueriesTableAdapter" Modifier="AutoLayout, AnsiClass, Class, Public" SchemaSerializationMode="IncludeSchema" xmlns="urn:schemas-microsoft-com:xml-msdatasource"> + <Connections /> + <Tables /> + <Sources /> + </DataSource> + </xs:appinfo> + </xs:annotation> + <xs:element name="CustomStoreDataSet" msdata:IsDataSet="true" msdata:UseCurrentLocale="true" msprop:Generator_UserDSName="CustomStoreDataSet" msprop:Generator_DataSetName="CustomStoreDataSet" msprop:EnableTableAdapterManager="true"> + <xs:complexType> + <xs:choice minOccurs="0" maxOccurs="unbounded"> + <xs:element name="Association" msprop:Generator_UserTableName="Association" msprop:Generator_RowDeletedName="AssociationRowDeleted" msprop:Generator_RowChangedName="AssociationRowChanged" msprop:Generator_RowClassName="AssociationRow" msprop:Generator_RowChangingName="AssociationRowChanging" msprop:Generator_RowEvArgName="AssociationRowChangeEvent" msprop:Generator_RowEvHandlerName="AssociationRowChangeEventHandler" msprop:Generator_TableClassName="AssociationDataTable" msprop:Generator_TableVarName="tableAssociation" msprop:Generator_RowDeletingName="AssociationRowDeleting" msprop:Generator_TablePropName="Association"> + <xs:complexType> + <xs:sequence> + <xs:element name="DistinguishingFactor" msprop:Generator_UserColumnName="DistinguishingFactor" msprop:Generator_ColumnVarNameInTable="columnDistinguishingFactor" msprop:Generator_ColumnPropNameInRow="DistinguishingFactor" msprop:Generator_ColumnPropNameInTable="DistinguishingFactorColumn" type="xs:string" /> + <xs:element name="Handle" msprop:Generator_UserColumnName="Handle" msprop:Generator_ColumnVarNameInTable="columnHandle" msprop:Generator_ColumnPropNameInRow="Handle" msprop:Generator_ColumnPropNameInTable="HandleColumn" type="xs:string" /> + <xs:element name="Expires" msprop:Generator_UserColumnName="Expires" msprop:Generator_ColumnVarNameInTable="columnExpires" msprop:Generator_ColumnPropNameInRow="Expires" msprop:Generator_ColumnPropNameInTable="ExpiresColumn" type="xs:dateTime" /> + <xs:element name="PrivateData" msprop:Generator_UserColumnName="PrivateData" msprop:Generator_ColumnVarNameInTable="columnPrivateData" msprop:Generator_ColumnPropNameInRow="PrivateData" msprop:Generator_ColumnPropNameInTable="PrivateDataColumn" type="xs:base64Binary" /> + </xs:sequence> + </xs:complexType> + </xs:element> + <xs:element name="Nonce" msprop:Generator_UserTableName="Nonce" msprop:Generator_RowDeletedName="NonceRowDeleted" msprop:Generator_RowChangedName="NonceRowChanged" msprop:Generator_RowClassName="NonceRow" msprop:Generator_RowChangingName="NonceRowChanging" msprop:Generator_RowEvArgName="NonceRowChangeEvent" msprop:Generator_RowEvHandlerName="NonceRowChangeEventHandler" msprop:Generator_TableClassName="NonceDataTable" msprop:Generator_TableVarName="tableNonce" msprop:Generator_RowDeletingName="NonceRowDeleting" msprop:Generator_TablePropName="Nonce"> + <xs:complexType> + <xs:sequence> + <xs:element name="Context" msprop:Generator_UserColumnName="Context" msprop:Generator_ColumnPropNameInRow="Context" msprop:Generator_ColumnVarNameInTable="columnContext" msprop:Generator_ColumnPropNameInTable="ContextColumn" type="xs:string" /> + <xs:element name="Code" msprop:Generator_UserColumnName="Code" msprop:Generator_ColumnPropNameInRow="Code" msprop:Generator_ColumnVarNameInTable="columnCode" msprop:Generator_ColumnPropNameInTable="CodeColumn" type="xs:string" /> + <xs:element name="Issued" msprop:Generator_UserColumnName="Issued" msprop:Generator_ColumnPropNameInRow="Issued" msprop:Generator_ColumnVarNameInTable="columnIssued" msprop:Generator_ColumnPropNameInTable="IssuedColumn" type="xs:dateTime" /> + <xs:element name="Expires" msprop:Generator_UserColumnName="Expires" msprop:Generator_ColumnVarNameInTable="columnExpires" msprop:Generator_ColumnPropNameInRow="Expires" msprop:Generator_ColumnPropNameInTable="ExpiresColumn" type="xs:dateTime" /> + </xs:sequence> + </xs:complexType> + </xs:element> + </xs:choice> + </xs:complexType> + <xs:unique name="PrimaryKey" msdata:PrimaryKey="true"> + <xs:selector xpath=".//mstns:Association" /> + <xs:field xpath="mstns:DistinguishingFactor" /> + <xs:field xpath="mstns:Handle" /> + </xs:unique> + <xs:unique name="Constraint1" msdata:PrimaryKey="true"> + <xs:selector xpath=".//mstns:Nonce" /> + <xs:field xpath="mstns:Code" /> + <xs:field xpath="mstns:Context" /> + </xs:unique> + </xs:element> +</xs:schema>
\ No newline at end of file diff --git a/samples/OpenIdRelyingPartyWebForms/Code/CustomStoreDataSet.xss b/samples/OpenIdRelyingPartyWebForms/Code/CustomStoreDataSet.xss new file mode 100644 index 0000000..483a137 --- /dev/null +++ b/samples/OpenIdRelyingPartyWebForms/Code/CustomStoreDataSet.xss @@ -0,0 +1,13 @@ +<?xml version="1.0" encoding="utf-8"?> +<!--<autogenerated> + This code was generated by a tool to store the dataset designer's layout information. + Changes to this file may cause incorrect behavior and will be lost if + the code is regenerated. +</autogenerated>--> +<DiagramLayout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" ex:showrelationlabel="False" ViewPortX="0" ViewPortY="0" xmlns:ex="urn:schemas-microsoft-com:xml-msdatasource-layout-extended" xmlns="urn:schemas-microsoft-com:xml-msdatasource-layout"> + <Shapes> + <Shape ID="DesignTable:Association" ZOrder="2" X="349" Y="83" Height="105" Width="154" AdapterExpanded="true" DataTableExpanded="true" OldAdapterHeight="0" OldDataTableHeight="0" SplitterPosition="101" /> + <Shape ID="DesignTable:Nonce" ZOrder="1" X="604" Y="86" Height="86" Width="150" AdapterExpanded="true" DataTableExpanded="true" OldAdapterHeight="0" OldDataTableHeight="0" SplitterPosition="82" /> + </Shapes> + <Connectors /> +</DiagramLayout>
\ No newline at end of file diff --git a/samples/OpenIdRelyingPartyWebForms/Code/CustomStoreDataSet1.Designer.cs b/samples/OpenIdRelyingPartyWebForms/Code/CustomStoreDataSet1.Designer.cs new file mode 100644 index 0000000..580b1fa --- /dev/null +++ b/samples/OpenIdRelyingPartyWebForms/Code/CustomStoreDataSet1.Designer.cs @@ -0,0 +1,1015 @@ +//------------------------------------------------------------------------------ +// <auto-generated> +// This code was generated by a tool. +// Runtime Version:2.0.50727.4912 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// </auto-generated> +//------------------------------------------------------------------------------ + +#pragma warning disable 1591 + +namespace OpenIdRelyingPartyWebForms.Code { + + + /// <summary> + ///Represents a strongly typed in-memory cache of data. + ///</summary> + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "2.0.0.0")] + [global::System.Serializable()] + [global::System.ComponentModel.DesignerCategoryAttribute("code")] + [global::System.ComponentModel.ToolboxItem(true)] + [global::System.Xml.Serialization.XmlSchemaProviderAttribute("GetTypedDataSetSchema")] + [global::System.Xml.Serialization.XmlRootAttribute("CustomStoreDataSet")] + [global::System.ComponentModel.Design.HelpKeywordAttribute("vs.data.DataSet")] + public partial class CustomStoreDataSet : global::System.Data.DataSet { + + private AssociationDataTable tableAssociation; + + private NonceDataTable tableNonce; + + private global::System.Data.SchemaSerializationMode _schemaSerializationMode = global::System.Data.SchemaSerializationMode.IncludeSchema; + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public CustomStoreDataSet() { + this.BeginInit(); + this.InitClass(); + global::System.ComponentModel.CollectionChangeEventHandler schemaChangedHandler = new global::System.ComponentModel.CollectionChangeEventHandler(this.SchemaChanged); + base.Tables.CollectionChanged += schemaChangedHandler; + base.Relations.CollectionChanged += schemaChangedHandler; + this.EndInit(); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + protected CustomStoreDataSet(global::System.Runtime.Serialization.SerializationInfo info, global::System.Runtime.Serialization.StreamingContext context) : + base(info, context, false) { + if ((this.IsBinarySerialized(info, context) == true)) { + this.InitVars(false); + global::System.ComponentModel.CollectionChangeEventHandler schemaChangedHandler1 = new global::System.ComponentModel.CollectionChangeEventHandler(this.SchemaChanged); + this.Tables.CollectionChanged += schemaChangedHandler1; + this.Relations.CollectionChanged += schemaChangedHandler1; + return; + } + string strSchema = ((string)(info.GetValue("XmlSchema", typeof(string)))); + if ((this.DetermineSchemaSerializationMode(info, context) == global::System.Data.SchemaSerializationMode.IncludeSchema)) { + global::System.Data.DataSet ds = new global::System.Data.DataSet(); + ds.ReadXmlSchema(new global::System.Xml.XmlTextReader(new global::System.IO.StringReader(strSchema))); + if ((ds.Tables["Association"] != null)) { + base.Tables.Add(new AssociationDataTable(ds.Tables["Association"])); + } + if ((ds.Tables["Nonce"] != null)) { + base.Tables.Add(new NonceDataTable(ds.Tables["Nonce"])); + } + this.DataSetName = ds.DataSetName; + this.Prefix = ds.Prefix; + this.Namespace = ds.Namespace; + this.Locale = ds.Locale; + this.CaseSensitive = ds.CaseSensitive; + this.EnforceConstraints = ds.EnforceConstraints; + this.Merge(ds, false, global::System.Data.MissingSchemaAction.Add); + this.InitVars(); + } + else { + this.ReadXmlSchema(new global::System.Xml.XmlTextReader(new global::System.IO.StringReader(strSchema))); + } + this.GetSerializationData(info, context); + global::System.ComponentModel.CollectionChangeEventHandler schemaChangedHandler = new global::System.ComponentModel.CollectionChangeEventHandler(this.SchemaChanged); + base.Tables.CollectionChanged += schemaChangedHandler; + this.Relations.CollectionChanged += schemaChangedHandler; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.ComponentModel.Browsable(false)] + [global::System.ComponentModel.DesignerSerializationVisibility(global::System.ComponentModel.DesignerSerializationVisibility.Content)] + public AssociationDataTable Association { + get { + return this.tableAssociation; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.ComponentModel.Browsable(false)] + [global::System.ComponentModel.DesignerSerializationVisibility(global::System.ComponentModel.DesignerSerializationVisibility.Content)] + public NonceDataTable Nonce { + get { + return this.tableNonce; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.ComponentModel.BrowsableAttribute(true)] + [global::System.ComponentModel.DesignerSerializationVisibilityAttribute(global::System.ComponentModel.DesignerSerializationVisibility.Visible)] + public override global::System.Data.SchemaSerializationMode SchemaSerializationMode { + get { + return this._schemaSerializationMode; + } + set { + this._schemaSerializationMode = value; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.ComponentModel.DesignerSerializationVisibilityAttribute(global::System.ComponentModel.DesignerSerializationVisibility.Hidden)] + public new global::System.Data.DataTableCollection Tables { + get { + return base.Tables; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.ComponentModel.DesignerSerializationVisibilityAttribute(global::System.ComponentModel.DesignerSerializationVisibility.Hidden)] + public new global::System.Data.DataRelationCollection Relations { + get { + return base.Relations; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + protected override void InitializeDerivedDataSet() { + this.BeginInit(); + this.InitClass(); + this.EndInit(); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public override global::System.Data.DataSet Clone() { + CustomStoreDataSet cln = ((CustomStoreDataSet)(base.Clone())); + cln.InitVars(); + cln.SchemaSerializationMode = this.SchemaSerializationMode; + return cln; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + protected override bool ShouldSerializeTables() { + return false; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + protected override bool ShouldSerializeRelations() { + return false; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + protected override void ReadXmlSerializable(global::System.Xml.XmlReader reader) { + if ((this.DetermineSchemaSerializationMode(reader) == global::System.Data.SchemaSerializationMode.IncludeSchema)) { + this.Reset(); + global::System.Data.DataSet ds = new global::System.Data.DataSet(); + ds.ReadXml(reader); + if ((ds.Tables["Association"] != null)) { + base.Tables.Add(new AssociationDataTable(ds.Tables["Association"])); + } + if ((ds.Tables["Nonce"] != null)) { + base.Tables.Add(new NonceDataTable(ds.Tables["Nonce"])); + } + this.DataSetName = ds.DataSetName; + this.Prefix = ds.Prefix; + this.Namespace = ds.Namespace; + this.Locale = ds.Locale; + this.CaseSensitive = ds.CaseSensitive; + this.EnforceConstraints = ds.EnforceConstraints; + this.Merge(ds, false, global::System.Data.MissingSchemaAction.Add); + this.InitVars(); + } + else { + this.ReadXml(reader); + this.InitVars(); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + protected override global::System.Xml.Schema.XmlSchema GetSchemaSerializable() { + global::System.IO.MemoryStream stream = new global::System.IO.MemoryStream(); + this.WriteXmlSchema(new global::System.Xml.XmlTextWriter(stream, null)); + stream.Position = 0; + return global::System.Xml.Schema.XmlSchema.Read(new global::System.Xml.XmlTextReader(stream), null); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + internal void InitVars() { + this.InitVars(true); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + internal void InitVars(bool initTable) { + this.tableAssociation = ((AssociationDataTable)(base.Tables["Association"])); + if ((initTable == true)) { + if ((this.tableAssociation != null)) { + this.tableAssociation.InitVars(); + } + } + this.tableNonce = ((NonceDataTable)(base.Tables["Nonce"])); + if ((initTable == true)) { + if ((this.tableNonce != null)) { + this.tableNonce.InitVars(); + } + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + private void InitClass() { + this.DataSetName = "CustomStoreDataSet"; + this.Prefix = ""; + this.Namespace = "http://tempuri.org/CustomStoreDataSet.xsd"; + this.EnforceConstraints = true; + this.SchemaSerializationMode = global::System.Data.SchemaSerializationMode.IncludeSchema; + this.tableAssociation = new AssociationDataTable(); + base.Tables.Add(this.tableAssociation); + this.tableNonce = new NonceDataTable(); + base.Tables.Add(this.tableNonce); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + private bool ShouldSerializeAssociation() { + return false; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + private bool ShouldSerializeNonce() { + return false; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + private void SchemaChanged(object sender, global::System.ComponentModel.CollectionChangeEventArgs e) { + if ((e.Action == global::System.ComponentModel.CollectionChangeAction.Remove)) { + this.InitVars(); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public static global::System.Xml.Schema.XmlSchemaComplexType GetTypedDataSetSchema(global::System.Xml.Schema.XmlSchemaSet xs) { + CustomStoreDataSet ds = new CustomStoreDataSet(); + global::System.Xml.Schema.XmlSchemaComplexType type = new global::System.Xml.Schema.XmlSchemaComplexType(); + global::System.Xml.Schema.XmlSchemaSequence sequence = new global::System.Xml.Schema.XmlSchemaSequence(); + global::System.Xml.Schema.XmlSchemaAny any = new global::System.Xml.Schema.XmlSchemaAny(); + any.Namespace = ds.Namespace; + sequence.Items.Add(any); + type.Particle = sequence; + global::System.Xml.Schema.XmlSchema dsSchema = ds.GetSchemaSerializable(); + if (xs.Contains(dsSchema.TargetNamespace)) { + global::System.IO.MemoryStream s1 = new global::System.IO.MemoryStream(); + global::System.IO.MemoryStream s2 = new global::System.IO.MemoryStream(); + try { + global::System.Xml.Schema.XmlSchema schema = null; + dsSchema.Write(s1); + for (global::System.Collections.IEnumerator schemas = xs.Schemas(dsSchema.TargetNamespace).GetEnumerator(); schemas.MoveNext(); ) { + schema = ((global::System.Xml.Schema.XmlSchema)(schemas.Current)); + s2.SetLength(0); + schema.Write(s2); + if ((s1.Length == s2.Length)) { + s1.Position = 0; + s2.Position = 0; + for (; ((s1.Position != s1.Length) + && (s1.ReadByte() == s2.ReadByte())); ) { + ; + } + if ((s1.Position == s1.Length)) { + return type; + } + } + } + } + finally { + if ((s1 != null)) { + s1.Close(); + } + if ((s2 != null)) { + s2.Close(); + } + } + } + xs.Add(dsSchema); + return type; + } + + public delegate void AssociationRowChangeEventHandler(object sender, AssociationRowChangeEvent e); + + public delegate void NonceRowChangeEventHandler(object sender, NonceRowChangeEvent e); + + /// <summary> + ///Represents the strongly named DataTable class. + ///</summary> + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "2.0.0.0")] + [global::System.Serializable()] + [global::System.Xml.Serialization.XmlSchemaProviderAttribute("GetTypedTableSchema")] + public partial class AssociationDataTable : global::System.Data.TypedTableBase<AssociationRow> { + + private global::System.Data.DataColumn columnDistinguishingFactor; + + private global::System.Data.DataColumn columnHandle; + + private global::System.Data.DataColumn columnExpires; + + private global::System.Data.DataColumn columnPrivateData; + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public AssociationDataTable() { + this.TableName = "Association"; + this.BeginInit(); + this.InitClass(); + this.EndInit(); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + internal AssociationDataTable(global::System.Data.DataTable table) { + this.TableName = table.TableName; + if ((table.CaseSensitive != table.DataSet.CaseSensitive)) { + this.CaseSensitive = table.CaseSensitive; + } + if ((table.Locale.ToString() != table.DataSet.Locale.ToString())) { + this.Locale = table.Locale; + } + if ((table.Namespace != table.DataSet.Namespace)) { + this.Namespace = table.Namespace; + } + this.Prefix = table.Prefix; + this.MinimumCapacity = table.MinimumCapacity; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + protected AssociationDataTable(global::System.Runtime.Serialization.SerializationInfo info, global::System.Runtime.Serialization.StreamingContext context) : + base(info, context) { + this.InitVars(); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public global::System.Data.DataColumn DistinguishingFactorColumn { + get { + return this.columnDistinguishingFactor; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public global::System.Data.DataColumn HandleColumn { + get { + return this.columnHandle; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public global::System.Data.DataColumn ExpiresColumn { + get { + return this.columnExpires; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public global::System.Data.DataColumn PrivateDataColumn { + get { + return this.columnPrivateData; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.ComponentModel.Browsable(false)] + public int Count { + get { + return this.Rows.Count; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public AssociationRow this[int index] { + get { + return ((AssociationRow)(this.Rows[index])); + } + } + + public event AssociationRowChangeEventHandler AssociationRowChanging; + + public event AssociationRowChangeEventHandler AssociationRowChanged; + + public event AssociationRowChangeEventHandler AssociationRowDeleting; + + public event AssociationRowChangeEventHandler AssociationRowDeleted; + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public void AddAssociationRow(AssociationRow row) { + this.Rows.Add(row); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public AssociationRow AddAssociationRow(string DistinguishingFactor, string Handle, System.DateTime Expires, byte[] PrivateData) { + AssociationRow rowAssociationRow = ((AssociationRow)(this.NewRow())); + object[] columnValuesArray = new object[] { + DistinguishingFactor, + Handle, + Expires, + PrivateData}; + rowAssociationRow.ItemArray = columnValuesArray; + this.Rows.Add(rowAssociationRow); + return rowAssociationRow; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public AssociationRow FindByDistinguishingFactorHandle(string DistinguishingFactor, string Handle) { + return ((AssociationRow)(this.Rows.Find(new object[] { + DistinguishingFactor, + Handle}))); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public override global::System.Data.DataTable Clone() { + AssociationDataTable cln = ((AssociationDataTable)(base.Clone())); + cln.InitVars(); + return cln; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + protected override global::System.Data.DataTable CreateInstance() { + return new AssociationDataTable(); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + internal void InitVars() { + this.columnDistinguishingFactor = base.Columns["DistinguishingFactor"]; + this.columnHandle = base.Columns["Handle"]; + this.columnExpires = base.Columns["Expires"]; + this.columnPrivateData = base.Columns["PrivateData"]; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + private void InitClass() { + this.columnDistinguishingFactor = new global::System.Data.DataColumn("DistinguishingFactor", typeof(string), null, global::System.Data.MappingType.Element); + base.Columns.Add(this.columnDistinguishingFactor); + this.columnHandle = new global::System.Data.DataColumn("Handle", typeof(string), null, global::System.Data.MappingType.Element); + base.Columns.Add(this.columnHandle); + this.columnExpires = new global::System.Data.DataColumn("Expires", typeof(global::System.DateTime), null, global::System.Data.MappingType.Element); + base.Columns.Add(this.columnExpires); + this.columnPrivateData = new global::System.Data.DataColumn("PrivateData", typeof(byte[]), null, global::System.Data.MappingType.Element); + base.Columns.Add(this.columnPrivateData); + this.Constraints.Add(new global::System.Data.UniqueConstraint("PrimaryKey", new global::System.Data.DataColumn[] { + this.columnDistinguishingFactor, + this.columnHandle}, true)); + this.columnDistinguishingFactor.AllowDBNull = false; + this.columnHandle.AllowDBNull = false; + this.columnExpires.AllowDBNull = false; + this.columnPrivateData.AllowDBNull = false; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public AssociationRow NewAssociationRow() { + return ((AssociationRow)(this.NewRow())); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + protected override global::System.Data.DataRow NewRowFromBuilder(global::System.Data.DataRowBuilder builder) { + return new AssociationRow(builder); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + protected override global::System.Type GetRowType() { + return typeof(AssociationRow); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + protected override void OnRowChanged(global::System.Data.DataRowChangeEventArgs e) { + base.OnRowChanged(e); + if ((this.AssociationRowChanged != null)) { + this.AssociationRowChanged(this, new AssociationRowChangeEvent(((AssociationRow)(e.Row)), e.Action)); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + protected override void OnRowChanging(global::System.Data.DataRowChangeEventArgs e) { + base.OnRowChanging(e); + if ((this.AssociationRowChanging != null)) { + this.AssociationRowChanging(this, new AssociationRowChangeEvent(((AssociationRow)(e.Row)), e.Action)); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + protected override void OnRowDeleted(global::System.Data.DataRowChangeEventArgs e) { + base.OnRowDeleted(e); + if ((this.AssociationRowDeleted != null)) { + this.AssociationRowDeleted(this, new AssociationRowChangeEvent(((AssociationRow)(e.Row)), e.Action)); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + protected override void OnRowDeleting(global::System.Data.DataRowChangeEventArgs e) { + base.OnRowDeleting(e); + if ((this.AssociationRowDeleting != null)) { + this.AssociationRowDeleting(this, new AssociationRowChangeEvent(((AssociationRow)(e.Row)), e.Action)); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public void RemoveAssociationRow(AssociationRow row) { + this.Rows.Remove(row); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public static global::System.Xml.Schema.XmlSchemaComplexType GetTypedTableSchema(global::System.Xml.Schema.XmlSchemaSet xs) { + global::System.Xml.Schema.XmlSchemaComplexType type = new global::System.Xml.Schema.XmlSchemaComplexType(); + global::System.Xml.Schema.XmlSchemaSequence sequence = new global::System.Xml.Schema.XmlSchemaSequence(); + CustomStoreDataSet ds = new CustomStoreDataSet(); + global::System.Xml.Schema.XmlSchemaAny any1 = new global::System.Xml.Schema.XmlSchemaAny(); + any1.Namespace = "http://www.w3.org/2001/XMLSchema"; + any1.MinOccurs = new decimal(0); + any1.MaxOccurs = decimal.MaxValue; + any1.ProcessContents = global::System.Xml.Schema.XmlSchemaContentProcessing.Lax; + sequence.Items.Add(any1); + global::System.Xml.Schema.XmlSchemaAny any2 = new global::System.Xml.Schema.XmlSchemaAny(); + any2.Namespace = "urn:schemas-microsoft-com:xml-diffgram-v1"; + any2.MinOccurs = new decimal(1); + any2.ProcessContents = global::System.Xml.Schema.XmlSchemaContentProcessing.Lax; + sequence.Items.Add(any2); + global::System.Xml.Schema.XmlSchemaAttribute attribute1 = new global::System.Xml.Schema.XmlSchemaAttribute(); + attribute1.Name = "namespace"; + attribute1.FixedValue = ds.Namespace; + type.Attributes.Add(attribute1); + global::System.Xml.Schema.XmlSchemaAttribute attribute2 = new global::System.Xml.Schema.XmlSchemaAttribute(); + attribute2.Name = "tableTypeName"; + attribute2.FixedValue = "AssociationDataTable"; + type.Attributes.Add(attribute2); + type.Particle = sequence; + global::System.Xml.Schema.XmlSchema dsSchema = ds.GetSchemaSerializable(); + if (xs.Contains(dsSchema.TargetNamespace)) { + global::System.IO.MemoryStream s1 = new global::System.IO.MemoryStream(); + global::System.IO.MemoryStream s2 = new global::System.IO.MemoryStream(); + try { + global::System.Xml.Schema.XmlSchema schema = null; + dsSchema.Write(s1); + for (global::System.Collections.IEnumerator schemas = xs.Schemas(dsSchema.TargetNamespace).GetEnumerator(); schemas.MoveNext(); ) { + schema = ((global::System.Xml.Schema.XmlSchema)(schemas.Current)); + s2.SetLength(0); + schema.Write(s2); + if ((s1.Length == s2.Length)) { + s1.Position = 0; + s2.Position = 0; + for (; ((s1.Position != s1.Length) + && (s1.ReadByte() == s2.ReadByte())); ) { + ; + } + if ((s1.Position == s1.Length)) { + return type; + } + } + } + } + finally { + if ((s1 != null)) { + s1.Close(); + } + if ((s2 != null)) { + s2.Close(); + } + } + } + xs.Add(dsSchema); + return type; + } + } + + /// <summary> + ///Represents the strongly named DataTable class. + ///</summary> + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "2.0.0.0")] + [global::System.Serializable()] + [global::System.Xml.Serialization.XmlSchemaProviderAttribute("GetTypedTableSchema")] + public partial class NonceDataTable : global::System.Data.TypedTableBase<NonceRow> { + + private global::System.Data.DataColumn columnContext; + + private global::System.Data.DataColumn columnCode; + + private global::System.Data.DataColumn columnIssued; + + private global::System.Data.DataColumn columnExpires; + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public NonceDataTable() { + this.TableName = "Nonce"; + this.BeginInit(); + this.InitClass(); + this.EndInit(); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + internal NonceDataTable(global::System.Data.DataTable table) { + this.TableName = table.TableName; + if ((table.CaseSensitive != table.DataSet.CaseSensitive)) { + this.CaseSensitive = table.CaseSensitive; + } + if ((table.Locale.ToString() != table.DataSet.Locale.ToString())) { + this.Locale = table.Locale; + } + if ((table.Namespace != table.DataSet.Namespace)) { + this.Namespace = table.Namespace; + } + this.Prefix = table.Prefix; + this.MinimumCapacity = table.MinimumCapacity; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + protected NonceDataTable(global::System.Runtime.Serialization.SerializationInfo info, global::System.Runtime.Serialization.StreamingContext context) : + base(info, context) { + this.InitVars(); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public global::System.Data.DataColumn ContextColumn { + get { + return this.columnContext; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public global::System.Data.DataColumn CodeColumn { + get { + return this.columnCode; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public global::System.Data.DataColumn IssuedColumn { + get { + return this.columnIssued; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public global::System.Data.DataColumn ExpiresColumn { + get { + return this.columnExpires; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.ComponentModel.Browsable(false)] + public int Count { + get { + return this.Rows.Count; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public NonceRow this[int index] { + get { + return ((NonceRow)(this.Rows[index])); + } + } + + public event NonceRowChangeEventHandler NonceRowChanging; + + public event NonceRowChangeEventHandler NonceRowChanged; + + public event NonceRowChangeEventHandler NonceRowDeleting; + + public event NonceRowChangeEventHandler NonceRowDeleted; + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public void AddNonceRow(NonceRow row) { + this.Rows.Add(row); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public NonceRow AddNonceRow(string Context, string Code, System.DateTime Issued, System.DateTime Expires) { + NonceRow rowNonceRow = ((NonceRow)(this.NewRow())); + object[] columnValuesArray = new object[] { + Context, + Code, + Issued, + Expires}; + rowNonceRow.ItemArray = columnValuesArray; + this.Rows.Add(rowNonceRow); + return rowNonceRow; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public NonceRow FindByCodeContext(string Code, string Context) { + return ((NonceRow)(this.Rows.Find(new object[] { + Code, + Context}))); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public override global::System.Data.DataTable Clone() { + NonceDataTable cln = ((NonceDataTable)(base.Clone())); + cln.InitVars(); + return cln; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + protected override global::System.Data.DataTable CreateInstance() { + return new NonceDataTable(); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + internal void InitVars() { + this.columnContext = base.Columns["Context"]; + this.columnCode = base.Columns["Code"]; + this.columnIssued = base.Columns["Issued"]; + this.columnExpires = base.Columns["Expires"]; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + private void InitClass() { + this.columnContext = new global::System.Data.DataColumn("Context", typeof(string), null, global::System.Data.MappingType.Element); + base.Columns.Add(this.columnContext); + this.columnCode = new global::System.Data.DataColumn("Code", typeof(string), null, global::System.Data.MappingType.Element); + base.Columns.Add(this.columnCode); + this.columnIssued = new global::System.Data.DataColumn("Issued", typeof(global::System.DateTime), null, global::System.Data.MappingType.Element); + base.Columns.Add(this.columnIssued); + this.columnExpires = new global::System.Data.DataColumn("Expires", typeof(global::System.DateTime), null, global::System.Data.MappingType.Element); + base.Columns.Add(this.columnExpires); + this.Constraints.Add(new global::System.Data.UniqueConstraint("Constraint1", new global::System.Data.DataColumn[] { + this.columnCode, + this.columnContext}, true)); + this.columnContext.AllowDBNull = false; + this.columnCode.AllowDBNull = false; + this.columnIssued.AllowDBNull = false; + this.columnExpires.AllowDBNull = false; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public NonceRow NewNonceRow() { + return ((NonceRow)(this.NewRow())); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + protected override global::System.Data.DataRow NewRowFromBuilder(global::System.Data.DataRowBuilder builder) { + return new NonceRow(builder); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + protected override global::System.Type GetRowType() { + return typeof(NonceRow); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + protected override void OnRowChanged(global::System.Data.DataRowChangeEventArgs e) { + base.OnRowChanged(e); + if ((this.NonceRowChanged != null)) { + this.NonceRowChanged(this, new NonceRowChangeEvent(((NonceRow)(e.Row)), e.Action)); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + protected override void OnRowChanging(global::System.Data.DataRowChangeEventArgs e) { + base.OnRowChanging(e); + if ((this.NonceRowChanging != null)) { + this.NonceRowChanging(this, new NonceRowChangeEvent(((NonceRow)(e.Row)), e.Action)); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + protected override void OnRowDeleted(global::System.Data.DataRowChangeEventArgs e) { + base.OnRowDeleted(e); + if ((this.NonceRowDeleted != null)) { + this.NonceRowDeleted(this, new NonceRowChangeEvent(((NonceRow)(e.Row)), e.Action)); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + protected override void OnRowDeleting(global::System.Data.DataRowChangeEventArgs e) { + base.OnRowDeleting(e); + if ((this.NonceRowDeleting != null)) { + this.NonceRowDeleting(this, new NonceRowChangeEvent(((NonceRow)(e.Row)), e.Action)); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public void RemoveNonceRow(NonceRow row) { + this.Rows.Remove(row); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public static global::System.Xml.Schema.XmlSchemaComplexType GetTypedTableSchema(global::System.Xml.Schema.XmlSchemaSet xs) { + global::System.Xml.Schema.XmlSchemaComplexType type = new global::System.Xml.Schema.XmlSchemaComplexType(); + global::System.Xml.Schema.XmlSchemaSequence sequence = new global::System.Xml.Schema.XmlSchemaSequence(); + CustomStoreDataSet ds = new CustomStoreDataSet(); + global::System.Xml.Schema.XmlSchemaAny any1 = new global::System.Xml.Schema.XmlSchemaAny(); + any1.Namespace = "http://www.w3.org/2001/XMLSchema"; + any1.MinOccurs = new decimal(0); + any1.MaxOccurs = decimal.MaxValue; + any1.ProcessContents = global::System.Xml.Schema.XmlSchemaContentProcessing.Lax; + sequence.Items.Add(any1); + global::System.Xml.Schema.XmlSchemaAny any2 = new global::System.Xml.Schema.XmlSchemaAny(); + any2.Namespace = "urn:schemas-microsoft-com:xml-diffgram-v1"; + any2.MinOccurs = new decimal(1); + any2.ProcessContents = global::System.Xml.Schema.XmlSchemaContentProcessing.Lax; + sequence.Items.Add(any2); + global::System.Xml.Schema.XmlSchemaAttribute attribute1 = new global::System.Xml.Schema.XmlSchemaAttribute(); + attribute1.Name = "namespace"; + attribute1.FixedValue = ds.Namespace; + type.Attributes.Add(attribute1); + global::System.Xml.Schema.XmlSchemaAttribute attribute2 = new global::System.Xml.Schema.XmlSchemaAttribute(); + attribute2.Name = "tableTypeName"; + attribute2.FixedValue = "NonceDataTable"; + type.Attributes.Add(attribute2); + type.Particle = sequence; + global::System.Xml.Schema.XmlSchema dsSchema = ds.GetSchemaSerializable(); + if (xs.Contains(dsSchema.TargetNamespace)) { + global::System.IO.MemoryStream s1 = new global::System.IO.MemoryStream(); + global::System.IO.MemoryStream s2 = new global::System.IO.MemoryStream(); + try { + global::System.Xml.Schema.XmlSchema schema = null; + dsSchema.Write(s1); + for (global::System.Collections.IEnumerator schemas = xs.Schemas(dsSchema.TargetNamespace).GetEnumerator(); schemas.MoveNext(); ) { + schema = ((global::System.Xml.Schema.XmlSchema)(schemas.Current)); + s2.SetLength(0); + schema.Write(s2); + if ((s1.Length == s2.Length)) { + s1.Position = 0; + s2.Position = 0; + for (; ((s1.Position != s1.Length) + && (s1.ReadByte() == s2.ReadByte())); ) { + ; + } + if ((s1.Position == s1.Length)) { + return type; + } + } + } + } + finally { + if ((s1 != null)) { + s1.Close(); + } + if ((s2 != null)) { + s2.Close(); + } + } + } + xs.Add(dsSchema); + return type; + } + } + + /// <summary> + ///Represents strongly named DataRow class. + ///</summary> + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "2.0.0.0")] + public partial class AssociationRow : global::System.Data.DataRow { + + private AssociationDataTable tableAssociation; + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + internal AssociationRow(global::System.Data.DataRowBuilder rb) : + base(rb) { + this.tableAssociation = ((AssociationDataTable)(this.Table)); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public string DistinguishingFactor { + get { + return ((string)(this[this.tableAssociation.DistinguishingFactorColumn])); + } + set { + this[this.tableAssociation.DistinguishingFactorColumn] = value; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public string Handle { + get { + return ((string)(this[this.tableAssociation.HandleColumn])); + } + set { + this[this.tableAssociation.HandleColumn] = value; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public System.DateTime Expires { + get { + return ((global::System.DateTime)(this[this.tableAssociation.ExpiresColumn])); + } + set { + this[this.tableAssociation.ExpiresColumn] = value; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public byte[] PrivateData { + get { + return ((byte[])(this[this.tableAssociation.PrivateDataColumn])); + } + set { + this[this.tableAssociation.PrivateDataColumn] = value; + } + } + } + + /// <summary> + ///Represents strongly named DataRow class. + ///</summary> + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "2.0.0.0")] + public partial class NonceRow : global::System.Data.DataRow { + + private NonceDataTable tableNonce; + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + internal NonceRow(global::System.Data.DataRowBuilder rb) : + base(rb) { + this.tableNonce = ((NonceDataTable)(this.Table)); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public string Context { + get { + return ((string)(this[this.tableNonce.ContextColumn])); + } + set { + this[this.tableNonce.ContextColumn] = value; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public string Code { + get { + return ((string)(this[this.tableNonce.CodeColumn])); + } + set { + this[this.tableNonce.CodeColumn] = value; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public System.DateTime Issued { + get { + return ((global::System.DateTime)(this[this.tableNonce.IssuedColumn])); + } + set { + this[this.tableNonce.IssuedColumn] = value; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public System.DateTime Expires { + get { + return ((global::System.DateTime)(this[this.tableNonce.ExpiresColumn])); + } + set { + this[this.tableNonce.ExpiresColumn] = value; + } + } + } + + /// <summary> + ///Row event argument class + ///</summary> + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "2.0.0.0")] + public class AssociationRowChangeEvent : global::System.EventArgs { + + private AssociationRow eventRow; + + private global::System.Data.DataRowAction eventAction; + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public AssociationRowChangeEvent(AssociationRow row, global::System.Data.DataRowAction action) { + this.eventRow = row; + this.eventAction = action; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public AssociationRow Row { + get { + return this.eventRow; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public global::System.Data.DataRowAction Action { + get { + return this.eventAction; + } + } + } + + /// <summary> + ///Row event argument class + ///</summary> + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "2.0.0.0")] + public class NonceRowChangeEvent : global::System.EventArgs { + + private NonceRow eventRow; + + private global::System.Data.DataRowAction eventAction; + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public NonceRowChangeEvent(NonceRow row, global::System.Data.DataRowAction action) { + this.eventRow = row; + this.eventAction = action; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public NonceRow Row { + get { + return this.eventRow; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public global::System.Data.DataRowAction Action { + get { + return this.eventAction; + } + } + } + } +} + +#pragma warning restore 1591
\ No newline at end of file diff --git a/samples/OpenIdRelyingPartyWebForms/Code/State.cs b/samples/OpenIdRelyingPartyWebForms/Code/State.cs new file mode 100644 index 0000000..4861a34 --- /dev/null +++ b/samples/OpenIdRelyingPartyWebForms/Code/State.cs @@ -0,0 +1,32 @@ +namespace OpenIdRelyingPartyWebForms { + using System.Collections.Generic; + using System.Web; + using DotNetOpenAuth.OpenId.Extensions.ProviderAuthenticationPolicy; + using DotNetOpenAuth.OpenId.Extensions.SimpleRegistration; + + /// <summary> + /// Strong-typed bag of session state. + /// </summary> + public class State { + public static ClaimsResponse ProfileFields { + get { return HttpContext.Current.Session["ProfileFields"] as ClaimsResponse; } + set { HttpContext.Current.Session["ProfileFields"] = value; } + } + + public static string FriendlyLoginName { + get { return HttpContext.Current.Session["FriendlyUsername"] as string; } + set { HttpContext.Current.Session["FriendlyUsername"] = value; } + } + + public static PolicyResponse PapePolicies { + get { return HttpContext.Current.Session["PapePolicies"] as PolicyResponse; } + set { HttpContext.Current.Session["PapePolicies"] = value; } + } + + public static void Clear() { + ProfileFields = null; + FriendlyLoginName = null; + PapePolicies = null; + } + } +}
\ No newline at end of file diff --git a/samples/OpenIdRelyingPartyWebForms/Code/TracePageAppender.cs b/samples/OpenIdRelyingPartyWebForms/Code/TracePageAppender.cs new file mode 100644 index 0000000..9848bb3 --- /dev/null +++ b/samples/OpenIdRelyingPartyWebForms/Code/TracePageAppender.cs @@ -0,0 +1,13 @@ +namespace OpenIdRelyingPartyWebForms { + using System; + using System.Collections.Generic; + using System.IO; + using System.Web; + + public class TracePageAppender : log4net.Appender.AppenderSkeleton { + protected override void Append(log4net.Core.LoggingEvent loggingEvent) { + StringWriter sw = new StringWriter(Global.LogMessages); + Layout.Format(sw, loggingEvent); + } + } +} diff --git a/samples/OpenIdRelyingPartyWebForms/Default.aspx b/samples/OpenIdRelyingPartyWebForms/Default.aspx new file mode 100644 index 0000000..602d5ed --- /dev/null +++ b/samples/OpenIdRelyingPartyWebForms/Default.aspx @@ -0,0 +1,13 @@ +<%@ Page Language="C#" AutoEventWireup="true" MasterPageFile="~/Site.Master" %> + +<%@ Register Assembly="DotNetOpenAuth" Namespace="DotNetOpenAuth" TagPrefix="openid" %> +<asp:Content runat="server" ContentPlaceHolderID="head"> + <openid:XrdsPublisher ID="XrdsPublisher1" runat="server" XrdsUrl="~/xrds.aspx" /> +</asp:Content> +<asp:Content runat="server" ContentPlaceHolderID="main"> + <h2>Relying Party </h2> + <p>Visit the + <asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl="~/MembersOnly/Default.aspx" + Text="Members Only" /> + area. (This will trigger a login demo). </p> +</asp:Content> diff --git a/samples/OpenIdRelyingPartyWebForms/Global.asax b/samples/OpenIdRelyingPartyWebForms/Global.asax new file mode 100644 index 0000000..8be3cd1 --- /dev/null +++ b/samples/OpenIdRelyingPartyWebForms/Global.asax @@ -0,0 +1 @@ +<%@ Application Codebehind="Global.asax.cs" Inherits="OpenIdRelyingPartyWebForms.Global" Language="C#" %> diff --git a/samples/OpenIdRelyingPartyWebForms/Global.asax.cs b/samples/OpenIdRelyingPartyWebForms/Global.asax.cs new file mode 100644 index 0000000..c7d1e8b --- /dev/null +++ b/samples/OpenIdRelyingPartyWebForms/Global.asax.cs @@ -0,0 +1,62 @@ +namespace OpenIdRelyingPartyWebForms { + using System; + using System.Collections.Specialized; + using System.IO; + using System.Text; + using System.Web; + + public class Global : HttpApplication { + public static log4net.ILog Logger = log4net.LogManager.GetLogger(typeof(Global)); + + internal static StringBuilder LogMessages = new StringBuilder(); + + public static string ToString(NameValueCollection collection) { + using (StringWriter sw = new StringWriter()) { + foreach (string key in collection.Keys) { + sw.WriteLine("{0} = '{1}'", key, collection[key]); + } + return sw.ToString(); + } + } + + protected void Application_Start(object sender, EventArgs e) { + log4net.Config.XmlConfigurator.Configure(); + Logger.Info("Sample starting..."); + } + + protected void Application_End(object sender, EventArgs e) { + Logger.Info("Sample shutting down..."); + + // this would be automatic, but in partial trust scenarios it is not. + log4net.LogManager.Shutdown(); + } + + protected void Application_BeginRequest(object sender, EventArgs e) { + // System.Diagnostics.Debugger.Launch(); + Logger.DebugFormat("Processing {0} on {1} ", Request.HttpMethod, stripQueryString(Request.Url)); + if (Request.QueryString.Count > 0) { + Logger.DebugFormat("Querystring follows: \n{0}", ToString(Request.QueryString)); + } + if (Request.Form.Count > 0) { + Logger.DebugFormat("Posted form follows: \n{0}", ToString(Request.Form)); + } + } + + protected void Application_AuthenticateRequest(object sender, EventArgs e) { + Logger.DebugFormat("User {0} authenticated.", HttpContext.Current.User != null ? "IS" : "is NOT"); + } + + protected void Application_EndRequest(object sender, EventArgs e) { + } + + protected void Application_Error(object sender, EventArgs e) { + Logger.ErrorFormat("An unhandled exception was raised. Details follow: {0}", HttpContext.Current.Server.GetLastError()); + } + + private static string stripQueryString(Uri uri) { + UriBuilder builder = new UriBuilder(uri); + builder.Query = null; + return builder.ToString(); + } + } +}
\ No newline at end of file diff --git a/samples/OpenIdRelyingPartyWebForms/MembersOnly/Default.aspx b/samples/OpenIdRelyingPartyWebForms/MembersOnly/Default.aspx new file mode 100644 index 0000000..46458e8 --- /dev/null +++ b/samples/OpenIdRelyingPartyWebForms/MembersOnly/Default.aspx @@ -0,0 +1,106 @@ +<%@ Page Language="C#" AutoEventWireup="true" MasterPageFile="~/Site.Master" %> +<%@ Import Namespace="OpenIdRelyingPartyWebForms" %> + +<asp:Content ID="Content1" runat="server" ContentPlaceHolderID="Main"> + <h2> + Members Only Area + </h2> + <p> + Congratulations, <b><asp:LoginName ID="LoginName1" runat="server" /></b>. + You have completed the OpenID login process. + </p> + +<% if (State.PapePolicies != null) { %> + <p>A PAPE extension was included in the authentication with this content: </p> + <ul> + <% if (State.PapePolicies.NistAssuranceLevel != null) {%> + <li>Nist: <%=HttpUtility.HtmlEncode(State.PapePolicies.NistAssuranceLevel.Value.ToString())%></li> + <% } + foreach (string policy in State.PapePolicies.ActualPolicies) { %> + <li><%=HttpUtility.HtmlEncode(policy) %></li> + <% } %> + </ul> +<% } %> + +<% if (State.ProfileFields != null) { %> + <p> + In addition to authenticating you, your OpenID Provider may + have told us something about you using the + Simple Registration extension: + </p> + <table id="profileFieldsTable" runat="server"> + <tr> + <td> + Nickname + </td> + <td> + <%=State.ProfileFields.Nickname %> + </td> + </tr> + <tr> + <td> + Email + </td> + <td> + <%=State.ProfileFields.Email%> + </td> + </tr> + <tr> + <td> + FullName + </td> + <td> + <%=State.ProfileFields.FullName%> + </td> + </tr> + <tr> + <td> + Date of Birth + </td> + <td> + <%=State.ProfileFields.BirthDate.ToString()%> + </td> + </tr> + <tr> + <td> + Gender + </td> + <td> + <%=State.ProfileFields.Gender.ToString()%> + </td> + </tr> + <tr> + <td> + Post Code + </td> + <td> + <%=State.ProfileFields.PostalCode%> + </td> + </tr> + <tr> + <td> + Country + </td> + <td> + <%=State.ProfileFields.Country%> + </td> + </tr> + <tr> + <td> + Language + </td> + <td> + <%=State.ProfileFields.Language%> + </td> + </tr> + <tr> + <td> + Timezone + </td> + <td> + <%=State.ProfileFields.TimeZone%> + </td> + </tr> + </table> +<% } %> +</asp:Content> diff --git a/samples/OpenIdRelyingPartyWebForms/MembersOnly/Web.config b/samples/OpenIdRelyingPartyWebForms/MembersOnly/Web.config new file mode 100644 index 0000000..3cfad05 --- /dev/null +++ b/samples/OpenIdRelyingPartyWebForms/MembersOnly/Web.config @@ -0,0 +1,18 @@ +<?xml version="1.0"?> +<!-- + Note: As an alternative to hand editing this file you can use the + web admin tool to configure settings for your application. Use + the Website->Asp.Net Configuration option in Visual Studio. + A full list of settings and comments can be found in + machine.config.comments usually located in + \Windows\Microsoft.Net\Framework\v2.x\Config +--> +<configuration> + <appSettings/> + <connectionStrings/> + <system.web> + <authorization> + <deny users="?"/> + </authorization> + </system.web> +</configuration> diff --git a/samples/OpenIdRelyingPartyWebForms/OpenIdRelyingPartyWebForms.csproj b/samples/OpenIdRelyingPartyWebForms/OpenIdRelyingPartyWebForms.csproj new file mode 100644 index 0000000..cf40440 --- /dev/null +++ b/samples/OpenIdRelyingPartyWebForms/OpenIdRelyingPartyWebForms.csproj @@ -0,0 +1,197 @@ +<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <ProductVersion>9.0.30729</ProductVersion> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{1E8AEA89-BF69-47A1-B290-E8B0FE588700}</ProjectGuid> + <ProjectTypeGuids>{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids> + <OutputType>Library</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <RootNamespace>OpenIdRelyingPartyWebForms</RootNamespace> + <AssemblyName>OpenIdRelyingPartyWebForms</AssemblyName> + <TargetFrameworkVersion>v3.5</TargetFrameworkVersion> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + <DebugSymbols>true</DebugSymbols> + <DebugType>full</DebugType> + <Optimize>false</Optimize> + <OutputPath>bin\</OutputPath> + <DefineConstants>DEBUG;TRACE</DefineConstants> + <ErrorReport>prompt</ErrorReport> + <WarningLevel>4</WarningLevel> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + <DebugType>pdbonly</DebugType> + <Optimize>true</Optimize> + <OutputPath>bin\</OutputPath> + <DefineConstants>TRACE</DefineConstants> + <ErrorReport>prompt</ErrorReport> + <WarningLevel>4</WarningLevel> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'CodeAnalysis|AnyCPU' "> + <DebugSymbols>true</DebugSymbols> + <OutputPath>bin\</OutputPath> + <DefineConstants>DEBUG;TRACE</DefineConstants> + <DebugType>full</DebugType> + <PlatformTarget>AnyCPU</PlatformTarget> + <CodeAnalysisUseTypeNameInSuppression>true</CodeAnalysisUseTypeNameInSuppression> + <CodeAnalysisModuleSuppressionsFile>GlobalSuppressions.cs</CodeAnalysisModuleSuppressionsFile> + <ErrorReport>prompt</ErrorReport> + </PropertyGroup> + <ItemGroup> + <Reference Include="log4net, Version=1.2.10.0, Culture=neutral, PublicKeyToken=1b44e1d426115821, processorArchitecture=MSIL"> + <SpecificVersion>False</SpecificVersion> + <HintPath>..\..\lib\log4net.dll</HintPath> + </Reference> + <Reference Include="System" /> + <Reference Include="System.Data" /> + <Reference Include="System.Core"> + <RequiredTargetFramework>3.5</RequiredTargetFramework> + </Reference> + <Reference Include="System.Data.DataSetExtensions"> + <RequiredTargetFramework>3.5</RequiredTargetFramework> + </Reference> + <Reference Include="System.Web.Extensions"> + <RequiredTargetFramework>3.5</RequiredTargetFramework> + </Reference> + <Reference Include="System.Xml.Linq"> + <RequiredTargetFramework>3.5</RequiredTargetFramework> + </Reference> + <Reference Include="System.Drawing" /> + <Reference Include="System.Web" /> + <Reference Include="System.Xml" /> + <Reference Include="System.Configuration" /> + <Reference Include="System.Web.Services" /> + <Reference Include="System.EnterpriseServices" /> + <Reference Include="System.Web.Mobile" /> + </ItemGroup> + <ItemGroup> + <Content Include="Default.aspx" /> + <Content Include="Global.asax" /> + <Content Include="login.aspx" /> + <Content Include="loginProgrammatic.aspx" /> + <Content Include="logout.aspx" /> + <Content Include="PrivacyPolicy.aspx" /> + <Content Include="styles.css" /> + <Content Include="TracePage.aspx" /> + <Content Include="Web.config" /> + </ItemGroup> + <ItemGroup> + <Compile Include="ajaxlogin.aspx.cs"> + <DependentUpon>ajaxlogin.aspx</DependentUpon> + <SubType>ASPXCodeBehind</SubType> + </Compile> + <Compile Include="ajaxlogin.aspx.designer.cs"> + <DependentUpon>ajaxlogin.aspx</DependentUpon> + </Compile> + <Compile Include="Code\CustomStore.cs" /> + <Compile Include="Code\CustomStoreDataSet.cs"> + <DependentUpon>CustomStoreDataSet.xsd</DependentUpon> + <SubType>Component</SubType> + </Compile> + <Compile Include="Code\CustomStoreDataSet.Designer.cs"> + <DependentUpon>CustomStoreDataSet.cs</DependentUpon> + </Compile> + <Compile Include="Code\CustomStoreDataSet1.Designer.cs"> + <AutoGen>True</AutoGen> + <DesignTime>True</DesignTime> + <DependentUpon>CustomStoreDataSet.xsd</DependentUpon> + </Compile> + <Compile Include="Code\State.cs" /> + <Compile Include="Code\TracePageAppender.cs" /> + <Compile Include="Global.asax.cs"> + <DependentUpon>Global.asax</DependentUpon> + </Compile> + <Compile Include="login.aspx.cs"> + <DependentUpon>login.aspx</DependentUpon> + <SubType>ASPXCodeBehind</SubType> + </Compile> + <Compile Include="login.aspx.designer.cs"> + <DependentUpon>login.aspx</DependentUpon> + </Compile> + <Compile Include="loginProgrammatic.aspx.cs"> + <DependentUpon>loginProgrammatic.aspx</DependentUpon> + <SubType>ASPXCodeBehind</SubType> + </Compile> + <Compile Include="loginProgrammatic.aspx.designer.cs"> + <DependentUpon>loginProgrammatic.aspx</DependentUpon> + </Compile> + <Compile Include="m\Login.aspx.cs"> + <DependentUpon>Login.aspx</DependentUpon> + <SubType>ASPXCodeBehind</SubType> + </Compile> + <Compile Include="m\Login.aspx.designer.cs"> + <DependentUpon>Login.aspx</DependentUpon> + </Compile> + <Compile Include="Properties\AssemblyInfo.cs" /> + <Compile Include="TracePage.aspx.cs"> + <DependentUpon>TracePage.aspx</DependentUpon> + <SubType>ASPXCodeBehind</SubType> + </Compile> + <Compile Include="TracePage.aspx.designer.cs"> + <DependentUpon>TracePage.aspx</DependentUpon> + </Compile> + </ItemGroup> + <ItemGroup> + <Content Include="ajaxlogin.aspx" /> + <Content Include="MembersOnly\Default.aspx" /> + <Content Include="Site.Master" /> + <Content Include="xrds.aspx" /> + </ItemGroup> + <ItemGroup> + <Content Include="images\attention.png" /> + <Content Include="images\dotnetopenid_tiny.gif" /> + <Content Include="images\openid_login.gif" /> + <Content Include="images\yahoo.png" /> + <Content Include="MembersOnly\Web.config" /> + <Content Include="m\Login.aspx" /> + </ItemGroup> + <ItemGroup> + <None Include="Code\CustomStoreDataSet.xsc"> + <DependentUpon>CustomStoreDataSet.xsd</DependentUpon> + </None> + <None Include="Code\CustomStoreDataSet.xsd"> + <Generator>MSDataSetGenerator</Generator> + <LastGenOutput>CustomStoreDataSet1.Designer.cs</LastGenOutput> + <SubType>Designer</SubType> + </None> + <None Include="Code\CustomStoreDataSet.xss"> + <DependentUpon>CustomStoreDataSet.xsd</DependentUpon> + </None> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="..\..\src\DotNetOpenAuth\DotNetOpenAuth.csproj"> + <Project>{3191B653-F76D-4C1A-9A5A-347BC3AAAAB7}</Project> + <Name>DotNetOpenAuth</Name> + </ProjectReference> + </ItemGroup> + <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> + <Import Project="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v9.0\WebApplications\Microsoft.WebApplication.targets" /> + <!-- To modify your build process, add your task inside one of the targets below and uncomment it. + Other similar extension points exist, see Microsoft.Common.targets. + <Target Name="BeforeBuild"> + </Target> + <Target Name="AfterBuild"> + </Target> + --> + <ProjectExtensions> + <VisualStudio> + <FlavorProperties GUID="{349c5851-65df-11da-9384-00065b846f21}"> + <WebProjectProperties> + <UseIIS>False</UseIIS> + <AutoAssignPort>True</AutoAssignPort> + <DevelopmentServerPort>4856</DevelopmentServerPort> + <DevelopmentServerVPath>/</DevelopmentServerVPath> + <IISUrl> + </IISUrl> + <NTLMAuthentication>False</NTLMAuthentication> + <UseCustomServer>False</UseCustomServer> + <CustomServerUrl> + </CustomServerUrl> + <SaveServerSettingsInUserFile>False</SaveServerSettingsInUserFile> + </WebProjectProperties> + </FlavorProperties> + </VisualStudio> + </ProjectExtensions> +</Project>
\ No newline at end of file diff --git a/samples/OpenIdRelyingPartyWebForms/PrivacyPolicy.aspx b/samples/OpenIdRelyingPartyWebForms/PrivacyPolicy.aspx new file mode 100644 index 0000000..e99112e --- /dev/null +++ b/samples/OpenIdRelyingPartyWebForms/PrivacyPolicy.aspx @@ -0,0 +1,7 @@ +<%@ Page Language="C#" AutoEventWireup="true" MasterPageFile="~/Site.Master" %> +<asp:Content ID="Content1" runat="server" ContentPlaceHolderID="Main"> + <h2>Privacy Policy</h2> + <p> + Some privacy policy would go here. + </p> +</asp:Content>
\ No newline at end of file diff --git a/samples/OpenIdRelyingPartyWebForms/Properties/AssemblyInfo.cs b/samples/OpenIdRelyingPartyWebForms/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..ea71bfc --- /dev/null +++ b/samples/OpenIdRelyingPartyWebForms/Properties/AssemblyInfo.cs @@ -0,0 +1,35 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("OpenIdRelyingPartyWebForms sample")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("DotNetOpenAuth")] +[assembly: AssemblyCopyright("Copyright © 2009")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("3d5900ae-111a-45be-96b3-d9e4606ca793")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Revision and Build Numbers +// by using the '*' as shown below: +[assembly: AssemblyVersion("0.2.0.0")] +[assembly: AssemblyFileVersion("0.2.0.0")] diff --git a/samples/OpenIdRelyingPartyWebForms/Settings.StyleCop b/samples/OpenIdRelyingPartyWebForms/Settings.StyleCop new file mode 100644 index 0000000..7f55ce6 --- /dev/null +++ b/samples/OpenIdRelyingPartyWebForms/Settings.StyleCop @@ -0,0 +1 @@ +<StyleCopSettings Version="4.3" />
\ No newline at end of file diff --git a/samples/OpenIdRelyingPartyWebForms/Site.Master b/samples/OpenIdRelyingPartyWebForms/Site.Master new file mode 100644 index 0000000..9630f78 --- /dev/null +++ b/samples/OpenIdRelyingPartyWebForms/Site.Master @@ -0,0 +1,39 @@ +<%@ Master Language="C#" AutoEventWireup="true" %> +<%@ Import Namespace="OpenIdRelyingPartyWebForms" %> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> + +<script runat="server"> + protected void Page_Load(object sender, EventArgs e) { + friendlyUsername.Text = State.FriendlyLoginName; + } + + protected void LoginStatus1_LoggedOut(object sender, EventArgs e) { + State.Clear(); + } +</script> + +<html xmlns="http://www.w3.org/1999/xhtml"> +<head runat="server"> + <title>OpenID Relying Party, by DotNetOpenAuth</title> + <link href="styles.css" rel="stylesheet" type="text/css" /> + <asp:ContentPlaceHolder ID="head" runat="server" /> +</head> +<body> + <form id="form1" runat="server"> + <span style="float: right"> + <asp:Image runat="server" ID="openIdUsernameImage" ImageUrl="~/images/openid_login.gif" + EnableViewState="false" /> + <asp:Label runat="server" ID="friendlyUsername" Text="" EnableViewState="false" /> + <asp:LoginStatus ID="LoginStatus1" runat="server" OnLoggedOut="LoginStatus1_LoggedOut" /> + </span> + <div> + <a href="http://dotnetopenid.googlecode.com"> + <img runat="server" src="~/images/dotnetopenid_tiny.gif" title="Jump to the project web site." + alt="DotNetOpenId" border='0' /></a> + </div> + <div> + <asp:ContentPlaceHolder ID="Main" runat="server" /> + </div> + </form> +</body> +</html> diff --git a/samples/OpenIdRelyingPartyWebForms/TracePage.aspx b/samples/OpenIdRelyingPartyWebForms/TracePage.aspx new file mode 100644 index 0000000..b115298 --- /dev/null +++ b/samples/OpenIdRelyingPartyWebForms/TracePage.aspx @@ -0,0 +1,16 @@ +<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="TracePage.aspx.cs" Inherits="OpenIdRelyingPartyWebForms.TracePage" %> + +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml"> +<head runat="server"> + <title></title> +</head> +<body> + <form id="form1" runat="server"> + <p align="right"> + <asp:Button runat="server" Text="Clear log" ID="clearLogButton" OnClick="clearLogButton_Click" /> + </p> + <pre><asp:PlaceHolder runat="server" ID="placeHolder1" /></pre> + </form> +</body> +</html> diff --git a/samples/OpenIdRelyingPartyWebForms/TracePage.aspx.cs b/samples/OpenIdRelyingPartyWebForms/TracePage.aspx.cs new file mode 100644 index 0000000..171bb67 --- /dev/null +++ b/samples/OpenIdRelyingPartyWebForms/TracePage.aspx.cs @@ -0,0 +1,20 @@ +namespace OpenIdRelyingPartyWebForms { + using System; + using System.Collections.Generic; + using System.Web; + using System.Web.UI; + using System.Web.UI.WebControls; + + public partial class TracePage : System.Web.UI.Page { + protected void Page_Load(object sender, EventArgs e) { + this.placeHolder1.Controls.Add(new Label { Text = HttpUtility.HtmlEncode(Global.LogMessages.ToString()) }); + } + + protected void clearLogButton_Click(object sender, EventArgs e) { + Global.LogMessages.Length = 0; + + // clear the page immediately, and allow for F5 without a Postback warning. + this.Response.Redirect(this.Request.Url.AbsoluteUri); + } + } +} diff --git a/samples/OpenIdRelyingPartyWebForms/TracePage.aspx.designer.cs b/samples/OpenIdRelyingPartyWebForms/TracePage.aspx.designer.cs new file mode 100644 index 0000000..8d8720d --- /dev/null +++ b/samples/OpenIdRelyingPartyWebForms/TracePage.aspx.designer.cs @@ -0,0 +1,43 @@ +//------------------------------------------------------------------------------ +// <auto-generated> +// This code was generated by a tool. +// Runtime Version:2.0.50727.4912 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// </auto-generated> +//------------------------------------------------------------------------------ + +namespace OpenIdRelyingPartyWebForms { + + + public partial class TracePage { + + /// <summary> + /// form1 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.HtmlForm form1; + + /// <summary> + /// clearLogButton 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 clearLogButton; + + /// <summary> + /// placeHolder1 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.PlaceHolder placeHolder1; + } +} diff --git a/samples/OpenIdRelyingPartyWebForms/Web.config b/samples/OpenIdRelyingPartyWebForms/Web.config new file mode 100644 index 0000000..10cc266 --- /dev/null +++ b/samples/OpenIdRelyingPartyWebForms/Web.config @@ -0,0 +1,90 @@ +<?xml version="1.0"?> +<configuration> + <configSections> + <section name="uri" type="System.Configuration.UriSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" /> + <section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler" requirePermission="false" /> + <section name="dotNetOpenAuth" type="DotNetOpenAuth.Configuration.DotNetOpenAuthSection" requirePermission="false" allowLocation="true"/> + </configSections> + + <!-- this is an optional configuration section where aspects of dotnetopenauth can be customized --> + <dotNetOpenAuth> + <openid> + <relyingParty> + <security requireSsl="false" /> + <!-- Uncomment the following to activate the sample custom store. --> + <!--<store type="OpenIdRelyingPartyWebForms.CustomStore, OpenIdRelyingPartyWebForms" />--> + </relyingParty> + </openid> + <messaging> + <untrustedWebRequest> + <whitelistHosts> + <!-- since this is a sample, and will often be used with localhost --> + <add name="localhost" /> + </whitelistHosts> + </untrustedWebRequest> + </messaging> + </dotNetOpenAuth> + + <!-- The uri section is necessary to turn on .NET 3.5 support for IDN (international domain names), + which is necessary for OpenID urls with unicode characters in the domain/host name. --> + <uri> + <idn enabled="All" /> + <iriParsing enabled="true" /> + </uri> + + <!-- This setting causes .NET to check certificate revocation lists (CRL) + before trusting HTTPS certificates. But this setting tends to not + be allowed in shared hosting environments. --> + <system.net> + <settings> + <servicePointManager checkCertificateRevocationList="true"/> + </settings> + </system.net> + + <system.web> + <!--<sessionState cookieless="true" />--> + <compilation debug="true"/> + <customErrors mode="RemoteOnly"/> + <authentication mode="Forms"> + <forms name="OpenIdRelyingPartySession"/> <!-- named cookie prevents conflicts with other samples --> + </authentication> + <trace enabled="false" writeToDiagnosticsTrace="true" /> + <!-- Trust level discussion: + Full: everything works + High: TRACE compilation symbol must NOT be defined + Medium/Low: doesn't work on default machine.config, because WebPermission.Connect is denied. + --> + <trust level="High" originUrl=""/> + </system.web> + + <!-- log4net is a 3rd party (free) logger library that dotnetopenid will use if present but does not require. --> + <log4net> + <appender name="RollingFileAppender" type="log4net.Appender.RollingFileAppender"> + <file value="RelyingParty.log" /> + <appendToFile value="true" /> + <rollingStyle value="Size" /> + <maxSizeRollBackups value="10" /> + <maximumFileSize value="100KB" /> + <staticLogFileName value="true" /> + <layout type="log4net.Layout.PatternLayout"> + <conversionPattern value="%date (GMT%date{%z}) [%thread] %-5level %logger - %message%newline" /> + </layout> + </appender> + <appender name="TracePageAppender" type="OpenIdRelyingPartyWebForms.TracePageAppender, OpenIdRelyingPartyWebForms"> + <layout type="log4net.Layout.PatternLayout"> + <conversionPattern value="%date (GMT%date{%z}) [%thread] %-5level %logger - %message%newline" /> + </layout> + </appender> + <!-- Setup the root category, add the appenders and set the default level --> + <root> + <level value="INFO" /> + <!--<appender-ref ref="RollingFileAppender" />--> + <appender-ref ref="TracePageAppender" /> + </root> + <!-- Specify the level for some specific categories --> + <logger name="DotNetOpenAuth"> + <level value="INFO" /> + </logger> + </log4net> + +</configuration> diff --git a/samples/OpenIdRelyingPartyWebForms/ajaxlogin.aspx b/samples/OpenIdRelyingPartyWebForms/ajaxlogin.aspx new file mode 100644 index 0000000..de82304 --- /dev/null +++ b/samples/OpenIdRelyingPartyWebForms/ajaxlogin.aspx @@ -0,0 +1,91 @@ +<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ajaxlogin.aspx.cs" Inherits="OpenIdRelyingPartyWebForms.ajaxlogin" + ValidateRequest="false" MasterPageFile="~/Site.Master" %> + +<%@ Register Assembly="DotNetOpenAuth" Namespace="DotNetOpenAuth.OpenId.RelyingParty" TagPrefix="openid" %> +<asp:Content runat="server" ContentPlaceHolderID="head"> +<style type="text/css"> +.textbox +{ + width: 200px; +} +.openidtextbox +{ + width: 185px; +} +td +{ + vertical-align: top; +} +</style> +</asp:Content> + +<asp:Content runat="server" ContentPlaceHolderID="Main"> +<script type="text/javascript"> + function onauthenticated(sender) { + var emailBox = document.getElementById('<%= emailAddressBox.ClientID %>'); + emailBox.disabled = false; + emailBox.title = null; // remove tooltip describing why the box was disabled. + // the sreg response may not always be included. + if (sender.sreg) { + // and the email field may not always be included in the sreg response. + if (sender.sreg.email) { emailBox.value = sender.sreg.email; } + } + } +</script> + + <asp:MultiView runat="server" ID="multiView" ActiveViewIndex='0'> + <asp:View runat="server" ID="commentSubmission"> + <table> + <tr> + <td> + OpenID + </td> + <td> + <openid:OpenIdAjaxTextBox ID="OpenIdAjaxTextBox1" runat="server" CssClass="openidtextbox" + OnLoggingIn="OpenIdAjaxTextBox1_LoggingIn" + OnLoggedIn="OpenIdAjaxTextBox1_LoggedIn" + OnClientAssertionReceived="onauthenticated(sender)" + OnUnconfirmedPositiveAssertion="OpenIdAjaxTextBox1_UnconfirmedPositiveAssertion" /> + <asp:RequiredFieldValidator ID="openidRequiredValidator" runat="server" + ControlToValidate="OpenIdAjaxTextBox1" ValidationGroup="openidVG" + ErrorMessage="The OpenID field is required." SetFocusOnError="True"> + <asp:Image runat="server" ImageUrl="~/images/attention.png" ToolTip="This is a required field" /> + </asp:RequiredFieldValidator> + </td> + </tr> + <tr> + <td> + Email + </td> + <td> + <asp:TextBox runat="server" ID="emailAddressBox" Enabled="false" CssClass="textbox" ToolTip="This field will be enabled after you log in with your OpenID." /> + </td> + </tr> + <tr> + <td> + Comments + </td> + <td> + <asp:TextBox runat="server" ID="commentsBox" TextMode="MultiLine" Rows="5" CssClass="textbox" /> + </td> + </tr> + <tr> + <td /> + <td> + <asp:Button runat="server" Text="Submit" ID="submitButton" OnClick="submitButton_Click" /> + </td> + </tr> + </table> + </asp:View> + <asp:View runat="server" ID="commentSubmitted"> + <p>Congratulations, + <asp:Label runat="server" ID="emailLabel" />! Your comment was received (and discarded... + this is just a demo after all).</p> + <asp:LinkButton runat="server" Text="Go back and change something in the comment" + OnClick="editComment_Click" /> + </asp:View> + <asp:View runat="server" ID="commentFailed"> + <p>Your comment submission failed.</p> + </asp:View> + </asp:MultiView> +</asp:Content> diff --git a/samples/OpenIdRelyingPartyWebForms/ajaxlogin.aspx.cs b/samples/OpenIdRelyingPartyWebForms/ajaxlogin.aspx.cs new file mode 100644 index 0000000..ffaf6f0 --- /dev/null +++ b/samples/OpenIdRelyingPartyWebForms/ajaxlogin.aspx.cs @@ -0,0 +1,56 @@ +namespace OpenIdRelyingPartyWebForms { + using System; + using System.Web.UI.WebControls; + using DotNetOpenAuth.OpenId.Extensions.SimpleRegistration; + using DotNetOpenAuth.OpenId.RelyingParty; + + public partial class ajaxlogin : System.Web.UI.Page { + protected void Page_Load(object sender, EventArgs e) { + if (!IsPostBack) { + this.OpenIdAjaxTextBox1.Focus(); + } + } + + protected void OpenIdAjaxTextBox1_LoggingIn(object sender, OpenIdEventArgs e) { + e.Request.AddExtension(new ClaimsRequest { + Email = DemandLevel.Request, + }); + } + + protected void OpenIdAjaxTextBox1_LoggedIn(object sender, OpenIdEventArgs e) { + Label label = ((Label)this.commentSubmitted.FindControl("emailLabel")); + label.Text = e.Response.FriendlyIdentifierForDisplay; + + // We COULD get the sreg extension response here for the email, but since we let the user + // potentially change the email in the HTML form, we'll use that instead. + ////var claims = OpenIdAjaxTextBox1.AuthenticationResponse.GetExtension<ClaimsResponse>(); + if (this.emailAddressBox.Text.Length > 0) { + label.Text += " (" + this.emailAddressBox.Text + ")"; + } + } + + protected void submitButton_Click(object sender, EventArgs e) { + if (!Page.IsValid) { + return; + } + if (this.OpenIdAjaxTextBox1.AuthenticationResponse != null) { + if (this.OpenIdAjaxTextBox1.AuthenticationResponse.Status == AuthenticationStatus.Authenticated) { + // Save comment here! + this.multiView.ActiveViewIndex = 1; + } else { + this.multiView.ActiveViewIndex = 2; + } + } + } + + protected void editComment_Click(object sender, EventArgs e) { + this.multiView.ActiveViewIndex = 0; + } + + 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. + this.OpenIdAjaxTextBox1.RegisterClientScriptExtension<ClaimsResponse>("sreg"); + } + } +} diff --git a/samples/OpenIdRelyingPartyWebForms/ajaxlogin.aspx.designer.cs b/samples/OpenIdRelyingPartyWebForms/ajaxlogin.aspx.designer.cs new file mode 100644 index 0000000..7e8f83c --- /dev/null +++ b/samples/OpenIdRelyingPartyWebForms/ajaxlogin.aspx.designer.cs @@ -0,0 +1,106 @@ +//------------------------------------------------------------------------------ +// <auto-generated> +// This code was generated by a tool. +// Runtime Version:2.0.50727.4912 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// </auto-generated> +//------------------------------------------------------------------------------ + +namespace OpenIdRelyingPartyWebForms { + + + public partial class ajaxlogin { + + /// <summary> + /// multiView 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.MultiView multiView; + + /// <summary> + /// commentSubmission 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.View commentSubmission; + + /// <summary> + /// OpenIdAjaxTextBox1 control. + /// </summary> + /// <remarks> + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// </remarks> + protected global::DotNetOpenAuth.OpenId.RelyingParty.OpenIdAjaxTextBox OpenIdAjaxTextBox1; + + /// <summary> + /// openidRequiredValidator 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.RequiredFieldValidator openidRequiredValidator; + + /// <summary> + /// emailAddressBox 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 emailAddressBox; + + /// <summary> + /// commentsBox 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 commentsBox; + + /// <summary> + /// submitButton 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 submitButton; + + /// <summary> + /// commentSubmitted 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.View commentSubmitted; + + /// <summary> + /// emailLabel 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 emailLabel; + + /// <summary> + /// commentFailed 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.View commentFailed; + } +} diff --git a/samples/OpenIdRelyingPartyWebForms/images/attention.png b/samples/OpenIdRelyingPartyWebForms/images/attention.png Binary files differnew file mode 100644 index 0000000..8003700 --- /dev/null +++ b/samples/OpenIdRelyingPartyWebForms/images/attention.png diff --git a/samples/OpenIdRelyingPartyWebForms/images/dotnetopenid_tiny.gif b/samples/OpenIdRelyingPartyWebForms/images/dotnetopenid_tiny.gif Binary files differnew file mode 100644 index 0000000..c4ed4f5 --- /dev/null +++ b/samples/OpenIdRelyingPartyWebForms/images/dotnetopenid_tiny.gif diff --git a/samples/OpenIdRelyingPartyWebForms/images/openid_login.gif b/samples/OpenIdRelyingPartyWebForms/images/openid_login.gif Binary files differnew file mode 100644 index 0000000..cde836c --- /dev/null +++ b/samples/OpenIdRelyingPartyWebForms/images/openid_login.gif diff --git a/samples/OpenIdRelyingPartyWebForms/images/yahoo.png b/samples/OpenIdRelyingPartyWebForms/images/yahoo.png Binary files differnew file mode 100644 index 0000000..3129217 --- /dev/null +++ b/samples/OpenIdRelyingPartyWebForms/images/yahoo.png diff --git a/samples/OpenIdRelyingPartyWebForms/login.aspx b/samples/OpenIdRelyingPartyWebForms/login.aspx new file mode 100644 index 0000000..6e66fd3 --- /dev/null +++ b/samples/OpenIdRelyingPartyWebForms/login.aspx @@ -0,0 +1,30 @@ +<%@ Page Language="C#" AutoEventWireup="True" CodeBehind="login.aspx.cs" Inherits="OpenIdRelyingPartyWebForms.login" + ValidateRequest="false" MasterPageFile="~/Site.Master" %> + +<%@ Register Assembly="DotNetOpenAuth" Namespace="DotNetOpenAuth.OpenId.RelyingParty" TagPrefix="rp" %> +<asp:Content runat="server" ContentPlaceHolderID="Main"> + <h2>Login Page </h2> + <rp:OpenIdLogin ID="OpenIdLogin1" runat="server" CssClass="openid_login" RequestCountry="Request" + RequestEmail="Request" RequestGender="Require" RequestPostalCode="Require" RequestTimeZone="Require" + RememberMeVisible="True" PolicyUrl="~/PrivacyPolicy.aspx" TabIndex="1" + OnLoggedIn="OpenIdLogin1_LoggedIn" OnLoggingIn="OpenIdLogin1_LoggingIn" + OnSetupRequired="OpenIdLogin1_SetupRequired" /> + <fieldset title="Knobs"> + <asp:CheckBox ID="requireSslCheckBox" runat="server" + Text="RequireSsl (high security) mode" + oncheckedchanged="requireSslCheckBox_CheckedChanged" /><br /> + <asp:CheckBox ID="immediateCheckBox" runat="server" Text="Immediate mode" /><br /> + <asp:CheckBoxList runat="server" ID="papePolicies"> + <asp:ListItem Text="Request phishing resistant authentication" Value="http://schemas.openid.net/pape/policies/2007/06/phishing-resistant" /> + <asp:ListItem Text="Request multi-factor authentication" Value="http://schemas.openid.net/pape/policies/2007/06/multi-factor" /> + <asp:ListItem Text="Request physical multi-factor authentication" Value="http://schemas.openid.net/pape/policies/2007/06/multi-factor-physical" /> + </asp:CheckBoxList> + </fieldset> + <br /> + <asp:Label ID="setupRequiredLabel" runat="server" EnableViewState="False" Text="You must log into your Provider first to use Immediate mode." + Visible="False" /> + <p> + <asp:ImageButton runat="server" ImageUrl="~/images/yahoo.png" ID="yahooLoginButton" + OnClick="yahooLoginButton_Click" /> + </p> +</asp:Content> diff --git a/samples/OpenIdRelyingPartyWebForms/login.aspx.cs b/samples/OpenIdRelyingPartyWebForms/login.aspx.cs new file mode 100644 index 0000000..37a714c --- /dev/null +++ b/samples/OpenIdRelyingPartyWebForms/login.aspx.cs @@ -0,0 +1,75 @@ +namespace OpenIdRelyingPartyWebForms { + using System; + using System.Collections.Generic; + using System.Web.UI; + using System.Web.UI.WebControls; + using DotNetOpenAuth.OpenId.Extensions.ProviderAuthenticationPolicy; + using DotNetOpenAuth.OpenId.Extensions.SimpleRegistration; + using DotNetOpenAuth.OpenId.RelyingParty; + + public partial class login : System.Web.UI.Page { + protected void Page_Load(object sender, EventArgs e) { + this.OpenIdLogin1.Focus(); + } + + protected void requireSslCheckBox_CheckedChanged(object sender, EventArgs e) { + this.OpenIdLogin1.RequireSsl = this.requireSslCheckBox.Checked; + } + + protected void OpenIdLogin1_LoggingIn(object sender, OpenIdEventArgs e) { + this.prepareRequest(e.Request); + } + + /// <summary> + /// Fired upon login. + /// </summary> + /// <param name="sender">The source of the event.</param> + /// <param name="e">The <see cref="DotNetOpenAuth.OpenId.RelyingParty.OpenIdEventArgs"/> instance containing the event data.</param> + /// <remarks> + /// Note, that straight after login, forms auth will redirect the user + /// to their original page. So this page may never be rendererd. + /// </remarks> + protected void OpenIdLogin1_LoggedIn(object sender, OpenIdEventArgs e) { + State.FriendlyLoginName = e.Response.FriendlyIdentifierForDisplay; + State.ProfileFields = e.Response.GetExtension<ClaimsResponse>(); + State.PapePolicies = e.Response.GetExtension<PolicyResponse>(); + } + + protected void OpenIdLogin1_SetupRequired(object sender, OpenIdEventArgs e) { + this.setupRequiredLabel.Visible = true; + } + + protected void yahooLoginButton_Click(object sender, ImageClickEventArgs e) { + OpenIdRelyingParty openid = new OpenIdRelyingParty(); + var req = openid.CreateRequest("yahoo.com"); + this.prepareRequest(req); + req.RedirectToProvider(); + + // We don't listen for the response from the provider explicitly + // because the OpenIdLogin control is already doing that for us. + } + + private void prepareRequest(IAuthenticationRequest request) { + // Setup is the default for the login control. But the user may have checked the box to override that. + request.Mode = this.immediateCheckBox.Checked ? AuthenticationRequestMode.Immediate : AuthenticationRequestMode.Setup; + + // Collect the PAPE policies requested by the user. + List<string> policies = new List<string>(); + foreach (ListItem item in this.papePolicies.Items) { + if (item.Selected) { + policies.Add(item.Value); + } + } + + // Add the PAPE extension if any policy was requested. + if (policies.Count > 0) { + var pape = new PolicyRequest(); + foreach (string policy in policies) { + pape.PreferredPolicies.Add(policy); + } + + request.AddExtension(pape); + } + } + } +}
\ No newline at end of file diff --git a/samples/OpenIdRelyingPartyWebForms/login.aspx.designer.cs b/samples/OpenIdRelyingPartyWebForms/login.aspx.designer.cs new file mode 100644 index 0000000..436ef7b --- /dev/null +++ b/samples/OpenIdRelyingPartyWebForms/login.aspx.designer.cs @@ -0,0 +1,70 @@ +//------------------------------------------------------------------------------ +// <auto-generated> +// This code was generated by a tool. +// Runtime Version:2.0.50727.4912 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// </auto-generated> +//------------------------------------------------------------------------------ + +namespace OpenIdRelyingPartyWebForms { + + + public partial class login { + + /// <summary> + /// OpenIdLogin1 control. + /// </summary> + /// <remarks> + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// </remarks> + protected global::DotNetOpenAuth.OpenId.RelyingParty.OpenIdLogin OpenIdLogin1; + + /// <summary> + /// requireSslCheckBox 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 requireSslCheckBox; + + /// <summary> + /// immediateCheckBox 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 immediateCheckBox; + + /// <summary> + /// papePolicies 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.CheckBoxList papePolicies; + + /// <summary> + /// setupRequiredLabel 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 setupRequiredLabel; + + /// <summary> + /// yahooLoginButton 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.ImageButton yahooLoginButton; + } +} diff --git a/samples/OpenIdRelyingPartyWebForms/loginProgrammatic.aspx b/samples/OpenIdRelyingPartyWebForms/loginProgrammatic.aspx new file mode 100644 index 0000000..a00eccd --- /dev/null +++ b/samples/OpenIdRelyingPartyWebForms/loginProgrammatic.aspx @@ -0,0 +1,15 @@ +<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="loginProgrammatic.aspx.cs" + Inherits="OpenIdRelyingPartyWebForms.loginProgrammatic" MasterPageFile="~/Site.Master" %> +<asp:Content ID="Content1" runat="server" ContentPlaceHolderID="Main"> + <h2>Login Page </h2> + <asp:Label ID="Label1" runat="server" Text="OpenID Login" /> + <asp:TextBox ID="openIdBox" runat="server" /> + <asp:Button ID="loginButton" runat="server" Text="Login" OnClick="loginButton_Click" /> + <asp:CustomValidator runat="server" ID="openidValidator" ErrorMessage="Invalid OpenID Identifier" + ControlToValidate="openIdBox" EnableViewState="false" OnServerValidate="openidValidator_ServerValidate" /> + <br /> + <asp:Label ID="loginFailedLabel" runat="server" EnableViewState="False" Text="Login failed" + Visible="False" /> + <asp:Label ID="loginCanceledLabel" runat="server" EnableViewState="False" Text="Login canceled" + Visible="False" /> +</asp:Content>
\ No newline at end of file diff --git a/samples/OpenIdRelyingPartyWebForms/loginProgrammatic.aspx.cs b/samples/OpenIdRelyingPartyWebForms/loginProgrammatic.aspx.cs new file mode 100644 index 0000000..fe73b7e --- /dev/null +++ b/samples/OpenIdRelyingPartyWebForms/loginProgrammatic.aspx.cs @@ -0,0 +1,118 @@ +namespace OpenIdRelyingPartyWebForms { + using System; + using System.Net; + using System.Web.Security; + using System.Web.UI; + using System.Web.UI.WebControls; + using DotNetOpenAuth.Messaging; + using DotNetOpenAuth.OpenId; + using DotNetOpenAuth.OpenId.Extensions.SimpleRegistration; + using DotNetOpenAuth.OpenId.RelyingParty; + + public partial class loginProgrammatic : System.Web.UI.Page { + 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); + } + + protected void loginButton_Click(object sender, EventArgs e) { + if (!this.Page.IsValid) { + return; // don't login if custom validation failed. + } + try { + using (OpenIdRelyingParty openid = this.createRelyingParty()) { + IAuthenticationRequest request = openid.CreateRequest(this.openIdBox.Text); + + // This is where you would add any OpenID extensions you wanted + // to include in the authentication request. + request.AddExtension(new ClaimsRequest { + Country = DemandLevel.Request, + Email = DemandLevel.Request, + Gender = DemandLevel.Require, + PostalCode = DemandLevel.Require, + TimeZone = DemandLevel.Require, + }); + + // Send your visitor to their Provider for authentication. + 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; + } 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; + } + } + + protected void Page_Load(object sender, EventArgs e) { + this.openIdBox.Focus(); + + // For debugging/testing, we allow remote clearing of all associations... + // NOT a good idea on a production site. + if (Request.QueryString["clearAssociations"] == "1") { + Application.Remove("DotNetOpenAuth.OpenId.RelyingParty.OpenIdRelyingParty.ApplicationStore"); + + // Force a redirect now to prevent the user from logging in while associations + // are constantly being cleared. + UriBuilder builder = new UriBuilder(Request.Url); + builder.Query = null; + Response.Redirect(builder.Uri.AbsoluteUri); + } + + OpenIdRelyingParty openid = this.createRelyingParty(); + var response = openid.GetResponse(); + if (response != null) { + switch (response.Status) { + case AuthenticationStatus.Authenticated: + // This is where you would look for any OpenID extension responses included + // in the authentication assertion. + var claimsResponse = response.GetExtension<ClaimsResponse>(); + State.ProfileFields = claimsResponse; + + // Store off the "friendly" username to display -- NOT for username lookup + State.FriendlyLoginName = response.FriendlyIdentifierForDisplay; + + // Use FormsAuthentication to tell ASP.NET that the user is now logged in, + // with the OpenID Claimed Identifier as their username. + FormsAuthentication.RedirectFromLoginPage(response.ClaimedIdentifier, false); + break; + case AuthenticationStatus.Canceled: + this.loginCanceledLabel.Visible = true; + break; + case AuthenticationStatus.Failed: + this.loginFailedLabel.Visible = true; + break; + + // We don't need to handle SetupRequired because we're not setting + // IAuthenticationRequest.Mode to immediate mode. + ////case AuthenticationStatus.SetupRequired: + //// break; + } + } + } + + private OpenIdRelyingParty createRelyingParty() { + OpenIdRelyingParty openid = new OpenIdRelyingParty(); + int minsha, maxsha, minversion; + if (int.TryParse(Request.QueryString["minsha"], out minsha)) { + openid.SecuritySettings.MinimumHashBitLength = minsha; + } + if (int.TryParse(Request.QueryString["maxsha"], out maxsha)) { + openid.SecuritySettings.MaximumHashBitLength = maxsha; + } + if (int.TryParse(Request.QueryString["minversion"], out minversion)) { + switch (minversion) { + case 1: openid.SecuritySettings.MinimumRequiredOpenIdVersion = ProtocolVersion.V10; break; + case 2: openid.SecuritySettings.MinimumRequiredOpenIdVersion = ProtocolVersion.V20; break; + default: throw new ArgumentOutOfRangeException("minversion"); + } + } + return openid; + } + } +}
\ No newline at end of file diff --git a/samples/OpenIdRelyingPartyWebForms/loginProgrammatic.aspx.designer.cs b/samples/OpenIdRelyingPartyWebForms/loginProgrammatic.aspx.designer.cs new file mode 100644 index 0000000..0363be7 --- /dev/null +++ b/samples/OpenIdRelyingPartyWebForms/loginProgrammatic.aspx.designer.cs @@ -0,0 +1,70 @@ +//------------------------------------------------------------------------------ +// <auto-generated> +// This code was generated by a tool. +// Runtime Version:2.0.50727.4912 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// </auto-generated> +//------------------------------------------------------------------------------ + +namespace OpenIdRelyingPartyWebForms { + + + public partial class loginProgrammatic { + + /// <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> + /// loginButton 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 loginButton; + + /// <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> + /// loginFailedLabel 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 loginFailedLabel; + + /// <summary> + /// loginCanceledLabel 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 loginCanceledLabel; + } +} diff --git a/samples/OpenIdRelyingPartyWebForms/logout.aspx b/samples/OpenIdRelyingPartyWebForms/logout.aspx new file mode 100644 index 0000000..71c0433 --- /dev/null +++ b/samples/OpenIdRelyingPartyWebForms/logout.aspx @@ -0,0 +1,13 @@ +<%@ Page Language="C#" %> +<%@ Import Namespace="OpenIdRelyingPartyWebForms" %> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> + +<script runat="server"> + protected void Page_Load(object sender, EventArgs e) { + State.FriendlyLoginName = null; + State.ProfileFields = null; + System.Web.Security.FormsAuthentication.SignOut(); + Response.Redirect("~/"); + } +</script> + diff --git a/samples/OpenIdRelyingPartyWebForms/m/Login.aspx b/samples/OpenIdRelyingPartyWebForms/m/Login.aspx new file mode 100644 index 0000000..dda8c85 --- /dev/null +++ b/samples/OpenIdRelyingPartyWebForms/m/Login.aspx @@ -0,0 +1,17 @@ +<%@ Page Language="C#" CodeBehind="Login.aspx.cs" Inherits="OpenIdRelyingPartyWebForms.m.Login" %> + +<%@ Register Assembly="DotNetOpenAuth" Namespace="DotNetOpenAuth.OpenId.RelyingParty" + TagPrefix="RP" %> +<%@ Register Assembly="System.Web.Mobile" Namespace="System.Web.UI.MobileControls" + TagPrefix="MC" %> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml"> +<head> +</head> +<body> + <MC:Form id="form1" runat="server"> + <RP:OpenIdMobileTextBox ID="openIdTextBox" runat="server" /> + <MC:Command runat="server" ID="loginButton" OnClick="loginButton_Click" Text="Login" /> + </MC:Form> +</body> +</html> diff --git a/samples/OpenIdRelyingPartyWebForms/m/Login.aspx.cs b/samples/OpenIdRelyingPartyWebForms/m/Login.aspx.cs new file mode 100644 index 0000000..86cd5c1 --- /dev/null +++ b/samples/OpenIdRelyingPartyWebForms/m/Login.aspx.cs @@ -0,0 +1,13 @@ +namespace OpenIdRelyingPartyWebForms.m { + using System; + using System.Web.UI.MobileControls; + + public partial class Login : MobilePage { + protected void Page_Load(object sender, EventArgs e) { + } + + protected void loginButton_Click(object sender, EventArgs e) { + this.openIdTextBox.LogOn(); + } + } +} diff --git a/samples/OpenIdRelyingPartyWebForms/m/Login.aspx.designer.cs b/samples/OpenIdRelyingPartyWebForms/m/Login.aspx.designer.cs new file mode 100644 index 0000000..e55b802 --- /dev/null +++ b/samples/OpenIdRelyingPartyWebForms/m/Login.aspx.designer.cs @@ -0,0 +1,43 @@ +//------------------------------------------------------------------------------ +// <auto-generated> +// This code was generated by a tool. +// Runtime Version:2.0.50727.4912 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// </auto-generated> +//------------------------------------------------------------------------------ + +namespace OpenIdRelyingPartyWebForms.m { + + + public partial class Login { + + /// <summary> + /// form1 control. + /// </summary> + /// <remarks> + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// </remarks> + protected global::System.Web.UI.MobileControls.Form form1; + + /// <summary> + /// openIdTextBox control. + /// </summary> + /// <remarks> + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// </remarks> + protected global::DotNetOpenAuth.OpenId.RelyingParty.OpenIdMobileTextBox openIdTextBox; + + /// <summary> + /// loginButton control. + /// </summary> + /// <remarks> + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// </remarks> + protected global::System.Web.UI.MobileControls.Command loginButton; + } +} diff --git a/samples/OpenIdRelyingPartyWebForms/styles.css b/samples/OpenIdRelyingPartyWebForms/styles.css new file mode 100644 index 0000000..2e4d3db --- /dev/null +++ b/samples/OpenIdRelyingPartyWebForms/styles.css @@ -0,0 +1,10 @@ +h2 +{ + font-style: italic; +} + +body +{ + font-family: Cambria, Arial, Times New Roman; + font-size: 12pt; +}
\ No newline at end of file diff --git a/samples/OpenIdRelyingPartyWebForms/xrds.aspx b/samples/OpenIdRelyingPartyWebForms/xrds.aspx new file mode 100644 index 0000000..e169bc7 --- /dev/null +++ b/samples/OpenIdRelyingPartyWebForms/xrds.aspx @@ -0,0 +1,22 @@ +<%@ Page Language="C#" AutoEventWireup="true" ContentType="application/xrds+xml" %><?xml version="1.0" encoding="UTF-8"?> +<%-- +This page is a required for relying party discovery per OpenID 2.0. +It allows Providers to call back to the relying party site to confirm the +identity that it is claiming in the realm and return_to URLs. +This page should be pointed to by the 'realm' home page, which in this sample +is default.aspx. +--%> +<xrds:XRDS + xmlns:xrds="xri://$xrds" + xmlns:openid="http://openid.net/xmlns/1.0" + xmlns="xri://$xrd*($v*2.0)"> + <XRD> + <Service priority="1"> + <Type>http://specs.openid.net/auth/2.0/return_to</Type> + <%-- Every page with an OpenID login should be listed here. --%> + <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> + </Service> + </XRD> +</xrds:XRDS> |