summaryrefslogtreecommitdiffstats
path: root/samples/ProviderPortal
diff options
context:
space:
mode:
Diffstat (limited to 'samples/ProviderPortal')
-rw-r--r--samples/ProviderPortal/.gitignore3
-rw-r--r--samples/ProviderPortal/Code/CustomStore.cs76
-rw-r--r--samples/ProviderPortal/Code/CustomStoreDataSet.Designer.cs626
-rw-r--r--samples/ProviderPortal/Code/CustomStoreDataSet.xsc9
-rw-r--r--samples/ProviderPortal/Code/CustomStoreDataSet.xsd33
-rw-r--r--samples/ProviderPortal/Code/CustomStoreDataSet.xss12
-rw-r--r--samples/ProviderPortal/Code/TracePageAppender.cs13
-rw-r--r--samples/ProviderPortal/Code/URLRewriter.cs5
-rw-r--r--samples/ProviderPortal/Code/Util.cs25
-rw-r--r--samples/ProviderPortal/Default.aspx22
-rw-r--r--samples/ProviderPortal/Global.asax.cs28
-rw-r--r--samples/ProviderPortal/ProfileFields.ascx.cs51
-rw-r--r--samples/ProviderPortal/Provider.ashx1
-rw-r--r--samples/ProviderPortal/Provider.ashx.cs56
-rw-r--r--samples/ProviderPortal/ProviderPortal.csproj49
-rw-r--r--samples/ProviderPortal/Site.Master20
-rw-r--r--samples/ProviderPortal/TracePage.aspx16
-rw-r--r--samples/ProviderPortal/TracePage.aspx.cs19
-rw-r--r--samples/ProviderPortal/TracePage.aspx.designer.cs43
-rw-r--r--samples/ProviderPortal/Web.config76
-rw-r--r--samples/ProviderPortal/decide.aspx13
-rw-r--r--samples/ProviderPortal/decide.aspx.cs24
-rw-r--r--samples/ProviderPortal/decide.aspx.designer.cs9
-rw-r--r--samples/ProviderPortal/favicon.icobin0 -> 318 bytes
-rw-r--r--samples/ProviderPortal/images/dotnetopenid_tiny.gifbin0 -> 3548 bytes
-rw-r--r--samples/ProviderPortal/login.aspx17
-rw-r--r--samples/ProviderPortal/login.aspx.designer.cs9
-rw-r--r--samples/ProviderPortal/op_xrds.aspx2
-rw-r--r--samples/ProviderPortal/server.aspx7
-rw-r--r--samples/ProviderPortal/server.aspx.cs20
-rw-r--r--samples/ProviderPortal/server.aspx.designer.cs2
-rw-r--r--samples/ProviderPortal/styles.css10
-rw-r--r--samples/ProviderPortal/user.aspx15
-rw-r--r--samples/ProviderPortal/user.aspx.cs13
-rw-r--r--samples/ProviderPortal/user_xrds.aspx4
35 files changed, 1180 insertions, 148 deletions
diff --git a/samples/ProviderPortal/.gitignore b/samples/ProviderPortal/.gitignore
index f4e2383..b086a60 100644
--- a/samples/ProviderPortal/.gitignore
+++ b/samples/ProviderPortal/.gitignore
@@ -1,4 +1,5 @@
Bin
obj
*.user
-*Trace.txt
+*.log
+StyleCop.Cache
diff --git a/samples/ProviderPortal/Code/CustomStore.cs b/samples/ProviderPortal/Code/CustomStore.cs
new file mode 100644
index 0000000..de7043f
--- /dev/null
+++ b/samples/ProviderPortal/Code/CustomStore.cs
@@ -0,0 +1,76 @@
+using System;
+using System.Data;
+using System.Globalization;
+using System.Security.Cryptography;
+using DotNetOpenId;
+using DotNetOpenId.RelyingParty;
+using IProviderAssociationStore = DotNetOpenId.IAssociationStore<DotNetOpenId.AssociationRelyingPartyType>;
+
+namespace ProviderPortal.Code {
+ /// <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 : IProviderAssociationStore {
+ static CustomStoreDataSet dataSet = new CustomStoreDataSet();
+
+ #region IAssociationStore<AssociationRelyingPartyType> Members
+
+ public void StoreAssociation(AssociationRelyingPartyType distinguishingFactor, Association assoc) {
+ var assocRow = dataSet.Association.NewAssociationRow();
+ assocRow.DistinguishingFactor = distinguishingFactor.ToString();
+ assocRow.Handle = assoc.Handle;
+ assocRow.Expires = assoc.Expires.ToLocalTime();
+ assocRow.PrivateData = assoc.SerializePrivateData();
+ dataSet.Association.AddAssociationRow(assocRow);
+ }
+
+ public Association GetAssociation(AssociationRelyingPartyType distinguishingFactor) {
+ // properly escape the URL to prevent injection attacks.
+ string value = distinguishingFactor.ToString();
+ 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(AssociationRelyingPartyType distinguishingFactor, string handle) {
+ var assocRow = dataSet.Association.FindByDistinguishingFactorHandle(distinguishingFactor.ToString(), handle);
+ return Association.Deserialize(assocRow.Handle, assocRow.Expires, assocRow.PrivateData);
+ }
+
+ public bool RemoveAssociation(AssociationRelyingPartyType distinguishingFactor, string handle) {
+ var row = dataSet.Association.FindByDistinguishingFactorHandle(distinguishingFactor.ToString(), handle);
+ if (row != null) {
+ dataSet.Association.RemoveAssociationRow(row);
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ public void ClearExpiredAssociations() {
+ removeExpiredRows(dataSet.Association, dataSet.Association.ExpiresColumn.ColumnName);
+ }
+
+ #endregion
+
+ 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/ProviderPortal/Code/CustomStoreDataSet.Designer.cs b/samples/ProviderPortal/Code/CustomStoreDataSet.Designer.cs
new file mode 100644
index 0000000..6fbe114
--- /dev/null
+++ b/samples/ProviderPortal/Code/CustomStoreDataSet.Designer.cs
@@ -0,0 +1,626 @@
+//------------------------------------------------------------------------------
+// <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 ProviderPortal.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 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"]));
+ }
+ 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.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"]));
+ }
+ 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();
+ }
+ }
+ }
+
+ [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);
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ private bool ShouldSerializeAssociation() {
+ 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);
+
+ /// <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 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>
+ ///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;
+ }
+ }
+ }
+ }
+}
+
+#pragma warning restore 1591 \ No newline at end of file
diff --git a/samples/ProviderPortal/Code/CustomStoreDataSet.xsc b/samples/ProviderPortal/Code/CustomStoreDataSet.xsc
new file mode 100644
index 0000000..551fc56
--- /dev/null
+++ b/samples/ProviderPortal/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/ProviderPortal/Code/CustomStoreDataSet.xsd b/samples/ProviderPortal/Code/CustomStoreDataSet.xsd
new file mode 100644
index 0000000..47f68e8
--- /dev/null
+++ b/samples/ProviderPortal/Code/CustomStoreDataSet.xsd
@@ -0,0 +1,33 @@
+<?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_ColumnPropNameInRow="DistinguishingFactor" msprop:Generator_ColumnVarNameInTable="columnDistinguishingFactor" msprop:Generator_ColumnPropNameInTable="DistinguishingFactorColumn" type="xs:string" />
+ <xs:element name="Handle" msprop:Generator_UserColumnName="Handle" msprop:Generator_ColumnPropNameInRow="Handle" msprop:Generator_ColumnVarNameInTable="columnHandle" msprop:Generator_ColumnPropNameInTable="HandleColumn" type="xs:string" />
+ <xs:element name="Expires" msprop:Generator_UserColumnName="Expires" msprop:Generator_ColumnPropNameInRow="Expires" msprop:Generator_ColumnVarNameInTable="columnExpires" msprop:Generator_ColumnPropNameInTable="ExpiresColumn" type="xs:dateTime" />
+ <xs:element name="PrivateData" msprop:Generator_UserColumnName="PrivateData" msprop:Generator_ColumnPropNameInRow="PrivateData" msprop:Generator_ColumnVarNameInTable="columnPrivateData" msprop:Generator_ColumnPropNameInTable="PrivateDataColumn" type="xs:base64Binary" />
+ </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:element>
+</xs:schema> \ No newline at end of file
diff --git a/samples/ProviderPortal/Code/CustomStoreDataSet.xss b/samples/ProviderPortal/Code/CustomStoreDataSet.xss
new file mode 100644
index 0000000..d097e67
--- /dev/null
+++ b/samples/ProviderPortal/Code/CustomStoreDataSet.xss
@@ -0,0 +1,12 @@
+<?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="1" X="349" Y="83" Height="105" Width="154" AdapterExpanded="true" DataTableExpanded="true" OldAdapterHeight="0" OldDataTableHeight="0" SplitterPosition="101" />
+ </Shapes>
+ <Connectors />
+</DiagramLayout> \ No newline at end of file
diff --git a/samples/ProviderPortal/Code/TracePageAppender.cs b/samples/ProviderPortal/Code/TracePageAppender.cs
new file mode 100644
index 0000000..ac9b523
--- /dev/null
+++ b/samples/ProviderPortal/Code/TracePageAppender.cs
@@ -0,0 +1,13 @@
+using System;
+using System.Collections.Generic;
+using System.Web;
+using System.IO;
+
+namespace ProviderPortal.Code {
+ 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/ProviderPortal/Code/URLRewriter.cs b/samples/ProviderPortal/Code/URLRewriter.cs
index 5a56c99..78bf53e 100644
--- a/samples/ProviderPortal/Code/URLRewriter.cs
+++ b/samples/ProviderPortal/Code/URLRewriter.cs
@@ -7,6 +7,7 @@ using System.Xml;
// nicked from http://www.codeproject.com/aspnet/URLRewriter.asp
namespace ProviderPortal {
public class URLRewriter : IConfigurationSectionHandler {
+ public static log4net.ILog Logger = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
protected XmlNode _oRules = null;
protected URLRewriter() { }
@@ -22,7 +23,7 @@ namespace ProviderPortal {
// check validity of the values
if (oUrlNode == null || string.IsNullOrEmpty(oUrlNode.InnerText)
|| oRewriteNode == null || string.IsNullOrEmpty(oRewriteNode.InnerText)) {
- Trace.TraceWarning("Invalid urlrewrites rule discovered in web.config file.");
+ Logger.Warn("Invalid urlrewrites rule discovered in web.config file.");
continue;
}
@@ -44,7 +45,7 @@ namespace ProviderPortal {
string zSubst = oRewriter.GetSubstitution(HttpContext.Current.Request.Path);
if (!string.IsNullOrEmpty(zSubst)) {
- Trace.TraceInformation("Rewriting url '{0}' to '{1}' ", HttpContext.Current.Request.Path, zSubst);
+ Logger.InfoFormat("Rewriting url '{0}' to '{1}' ", HttpContext.Current.Request.Path, zSubst);
HttpContext.Current.RewritePath(zSubst);
}
}
diff --git a/samples/ProviderPortal/Code/Util.cs b/samples/ProviderPortal/Code/Util.cs
index 982748c..f864972 100644
--- a/samples/ProviderPortal/Code/Util.cs
+++ b/samples/ProviderPortal/Code/Util.cs
@@ -19,6 +19,29 @@ public class Util {
return ExtractUserName(new Uri(identifier.ToString()));
}
public static Identifier BuildIdentityUrl() {
- return new Uri(HttpContext.Current.Request.Url, "/user/" + HttpContext.Current.User.Identity.Name);
+ string username = HttpContext.Current.User.Identity.Name;
+ // be sure to normalize case the way the user's identity page does.
+ username = username.Substring(0, 1).ToUpperInvariant() + username.Substring(1).ToLowerInvariant();
+ return new Uri(HttpContext.Current.Request.Url, "/user/" + username);
+ }
+ internal static void ProcessAuthenticationChallenge(IAuthenticationRequest idrequest) {
+ if (idrequest.Immediate) {
+ if (idrequest.IsDirectedIdentity) {
+ if (HttpContext.Current.User.Identity.IsAuthenticated) {
+ idrequest.LocalIdentifier = Util.BuildIdentityUrl();
+ idrequest.IsAuthenticated = true;
+ } else {
+ idrequest.IsAuthenticated = false;
+ }
+ } else {
+ string userOwningOpenIdUrl = Util.ExtractUserName(idrequest.LocalIdentifier);
+ // NOTE: in a production provider site, you may want to only
+ // respond affirmatively if the user has already authorized this consumer
+ // to know the answer.
+ idrequest.IsAuthenticated = userOwningOpenIdUrl == HttpContext.Current.User.Identity.Name;
+ }
+ } else {
+ HttpContext.Current.Response.Redirect("~/decide.aspx", true);
+ }
}
}
diff --git a/samples/ProviderPortal/Default.aspx b/samples/ProviderPortal/Default.aspx
index a418748..53ba6c4 100644
--- a/samples/ProviderPortal/Default.aspx
+++ b/samples/ProviderPortal/Default.aspx
@@ -1,8 +1,7 @@
-<%@ Page Language="C#" AutoEventWireup="true" %>
+<%@ Page Language="C#" AutoEventWireup="true" MasterPageFile="~/Site.Master" %>
<%@ Import Namespace="DotNetOpenId.Provider" %>
<%@ Register Assembly="DotNetOpenId" Namespace="DotNetOpenId" TagPrefix="openid" %>
-<!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 sendAssertionButton_Click(object sender, EventArgs e) {
@@ -20,18 +19,13 @@
}
</script>
-<html xmlns="http://www.w3.org/1999/xhtml">
-<head runat="server">
+<asp:Content runat="server" ContentPlaceHolderID="head">
<openid:XrdsPublisher runat="server" XrdsUrl="~/op_xrds.aspx" />
- <title>OpenID Provider, by DotNetOpenId</title>
-</head>
-<body>
- <form id="form1" runat="server">
- <h1>
- OpenID Provider
- </h1>
+</asp:Content>
+
+<asp:Content runat="server" ContentPlaceHolderID="Main">
<h2>
- Provided by <a href="http://dotnetopenid.googlecode.com">DotNetOpenId</a>
+ Provider
</h2>
<p>
Welcome. This site doesn't do anything more than simple authentication of users.
@@ -59,6 +53,4 @@
</LoggedInTemplate>
</asp:LoginView>
<asp:LoginStatus runat="server" />
- </form>
-</body>
-</html>
+</asp:Content> \ No newline at end of file
diff --git a/samples/ProviderPortal/Global.asax.cs b/samples/ProviderPortal/Global.asax.cs
index dd17d38..091ea56 100644
--- a/samples/ProviderPortal/Global.asax.cs
+++ b/samples/ProviderPortal/Global.asax.cs
@@ -1,14 +1,24 @@
using System;
using System.Collections.Specialized;
-using System.Diagnostics;
using System.IO;
+using System.Text;
using System.Web;
namespace ProviderPortal {
public class Global : System.Web.HttpApplication {
- public Global() {
- // since this is a sample, and will often be used with localhost
- DotNetOpenId.UntrustedWebRequest.WhitelistHosts.Add("localhost");
+ internal static StringBuilder LogMessages = new StringBuilder();
+
+ public static log4net.ILog Logger = log4net.LogManager.GetLogger(typeof(Global));
+
+ 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();
}
string stripQueryString(Uri uri) {
@@ -25,17 +35,17 @@ namespace ProviderPortal {
* There is only one rule currenty defined. It rewrites urls like: user/john ->user.aspx?username=john
*/
// System.Diagnostics.Debugger.Launch();
- Trace.TraceInformation("Processing {0} on {1} ", Request.HttpMethod, stripQueryString(Request.Url));
+ Logger.DebugFormat("Processing {0} on {1} ", Request.HttpMethod, stripQueryString(Request.Url));
if (Request.QueryString.Count > 0)
- Trace.TraceInformation("Querystring follows: \n{0}", ToString(Request.QueryString));
+ Logger.DebugFormat("Querystring follows: \n{0}", ToString(Request.QueryString));
if (Request.Form.Count > 0)
- Trace.TraceInformation("Posted form follows: \n{0}", ToString(Request.Form));
+ Logger.DebugFormat("Posted form follows: \n{0}", ToString(Request.Form));
URLRewriter.Process();
}
protected void Application_AuthenticateRequest(Object sender, EventArgs e) {
- Trace.TraceInformation("User {0} authenticated.", HttpContext.Current.User != null ? "IS" : "is NOT");
+ Logger.DebugFormat("User {0} authenticated.", HttpContext.Current.User != null ? "IS" : "is NOT");
}
@@ -43,7 +53,7 @@ namespace ProviderPortal {
}
protected void Application_Error(Object sender, EventArgs e) {
- Trace.TraceError("An unhandled exception was raised. Details follow: {0}",
+ Logger.ErrorFormat("An unhandled exception was raised. Details follow: {0}",
HttpContext.Current.Server.GetLastError());
}
diff --git a/samples/ProviderPortal/ProfileFields.ascx.cs b/samples/ProviderPortal/ProfileFields.ascx.cs
index f898227..00f1834 100644
--- a/samples/ProviderPortal/ProfileFields.ascx.cs
+++ b/samples/ProviderPortal/ProfileFields.ascx.cs
@@ -97,31 +97,32 @@ public partial class ProfileFields : System.Web.UI.UserControl {
}
}
- public ClaimsResponse OpenIdProfileFields {
- get {
- ClaimsResponse fields = new ClaimsResponse();
- fields.BirthDate = DateOfBirth;
- fields.Country = countryDropdownList.SelectedValue;
- fields.Email = emailTextBox.Text;
- fields.FullName = fullnameTextBox.Text;
- fields.Gender = Gender;
- fields.Language = languageDropdownList.SelectedValue;
- fields.Nickname = nicknameTextBox.Text;
- fields.PostalCode = postcodeTextBox.Text;
- fields.TimeZone = timezoneDropdownList.SelectedValue;
- return fields;
- }
- set {
- DateOfBirth = value.BirthDate;
- countryDropdownList.SelectedValue = value.Country;
- emailTextBox.Text = value.Email;
- fullnameTextBox.Text = value.FullName;
- Gender = value.Gender;
- languageDropdownList.SelectedValue = value.Language;
- nicknameTextBox.Text = value.Nickname;
- postcodeTextBox.Text = value.PostalCode;
- timezoneDropdownList.SelectedValue = value.TimeZone;
- }
+ public ClaimsResponse GetOpenIdProfileFields(ClaimsRequest request) {
+ if (request == null) throw new ArgumentNullException("request");
+ ClaimsResponse fields = request.CreateResponse();
+ fields.BirthDate = DateOfBirth;
+ fields.Country = countryDropdownList.SelectedValue;
+ fields.Email = emailTextBox.Text;
+ fields.FullName = fullnameTextBox.Text;
+ fields.Gender = Gender;
+ fields.Language = languageDropdownList.SelectedValue;
+ fields.Nickname = nicknameTextBox.Text;
+ fields.PostalCode = postcodeTextBox.Text;
+ fields.TimeZone = timezoneDropdownList.SelectedValue;
+ return fields;
+ }
+
+ public void SetOpenIdProfileFields(ClaimsResponse value) {
+ if (value == null) throw new ArgumentNullException("value");
+ DateOfBirth = value.BirthDate;
+ countryDropdownList.SelectedValue = value.Country;
+ emailTextBox.Text = value.Email;
+ fullnameTextBox.Text = value.FullName;
+ Gender = value.Gender;
+ languageDropdownList.SelectedValue = value.Language;
+ nicknameTextBox.Text = value.Nickname;
+ postcodeTextBox.Text = value.PostalCode;
+ timezoneDropdownList.SelectedValue = value.TimeZone;
}
}
diff --git a/samples/ProviderPortal/Provider.ashx b/samples/ProviderPortal/Provider.ashx
new file mode 100644
index 0000000..27475cc
--- /dev/null
+++ b/samples/ProviderPortal/Provider.ashx
@@ -0,0 +1 @@
+<%@ WebHandler Language="C#" CodeBehind="Provider.ashx.cs" Class="ProviderPortal.Provider" %>
diff --git a/samples/ProviderPortal/Provider.ashx.cs b/samples/ProviderPortal/Provider.ashx.cs
new file mode 100644
index 0000000..ca1cc05
--- /dev/null
+++ b/samples/ProviderPortal/Provider.ashx.cs
@@ -0,0 +1,56 @@
+using System.Web;
+using System.Web.SessionState;
+using DotNetOpenId.Provider;
+
+namespace ProviderPortal {
+ /// <summary>
+ /// A fast OpenID message handler that responds to OpenID messages
+ /// directed at the Provider.
+ /// </summary>
+ /// <remarks>
+ /// This performs the same function as server.aspx, which uses the ProviderEndpoint
+ /// control to reduce the amount of source code in the web site. A typical Provider
+ /// site will have EITHER this .ashx handler OR the .aspx page -- NOT both.
+ /// </remarks>
+ public class Provider : IHttpHandler, IRequiresSessionState {
+ public void ProcessRequest(HttpContext context) {
+ OpenIdProvider provider = new OpenIdProvider();
+ if (provider.Request != null) {
+ // Some OpenID requests are automatable and can be responded to immediately.
+ if (!provider.Request.IsResponseReady) {
+ // But authentication requests cannot be responded to until something on
+ // this site decides whether to approve or disapprove the authentication.
+ var idrequest = (IAuthenticationRequest)provider.Request;
+ // We store the authentication request in the user's session so that
+ // redirects and user prompts can appear and eventually some page can decide
+ // to respond to the OpenID authentication request either affirmatively or
+ // negatively.
+ ProviderEndpoint.PendingAuthenticationRequest = idrequest;
+ // We delegate that approval process to our utility method that we share
+ // with our other Provider sample page server.aspx.
+ Util.ProcessAuthenticationChallenge(idrequest);
+ // As part of authentication approval, the user may need to authenticate
+ // to this Provider and/or decide whether to allow the requesting RP site
+ // to log this user in. If any UI needs to be presented to the user,
+ // the previous call to ProcessAuthenticationChallenge MAY not return
+ // due to a redirect to some ASPX page.
+ } else {
+ // Some other automatable OpenID request is coming down, so clear
+ // any previously session stored authentication request that might be
+ // stored for this user.
+ ProviderEndpoint.PendingAuthenticationRequest = null;
+ }
+ // Whether this was an automated message or an authentication message,
+ // if there is a response ready to send back immediately, do so.
+ if (provider.Request.IsResponseReady) {
+ provider.Request.Response.Send();
+ ProviderEndpoint.PendingAuthenticationRequest = null;
+ }
+ }
+ }
+
+ public bool IsReusable {
+ get { return true; }
+ }
+ }
+}
diff --git a/samples/ProviderPortal/ProviderPortal.csproj b/samples/ProviderPortal/ProviderPortal.csproj
index 25e9946..835d92d 100644
--- a/samples/ProviderPortal/ProviderPortal.csproj
+++ b/samples/ProviderPortal/ProviderPortal.csproj
@@ -2,7 +2,7 @@
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
- <ProductVersion>9.0.21022</ProductVersion>
+ <ProductVersion>9.0.30729</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{2A59DE0A-B76A-4B42-9A33-04D34548353D}</ProjectGuid>
<ProjectTypeGuids>{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>
@@ -17,7 +17,7 @@
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\</OutputPath>
- <DefineConstants>TRACE;DEBUG</DefineConstants>
+ <DefineConstants>DEBUG</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
@@ -30,6 +30,10 @@
<WarningLevel>4</WarningLevel>
</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.Drawing" />
@@ -54,7 +58,14 @@
<Content Include="user_xrds.aspx" />
</ItemGroup>
<ItemGroup>
+ <Compile Include="Code\CustomStore.cs" />
+ <Compile Include="Code\CustomStoreDataSet.Designer.cs">
+ <DependentUpon>CustomStoreDataSet.xsd</DependentUpon>
+ <AutoGen>True</AutoGen>
+ <DesignTime>True</DesignTime>
+ </Compile>
<Compile Include="Code\ReadOnlyXmlMembershipProvider.cs" />
+ <Compile Include="Code\TracePageAppender.cs" />
<Compile Include="Code\URLRewriter.cs" />
<Compile Include="Code\Util.cs" />
<Compile Include="decide.aspx.cs">
@@ -82,6 +93,9 @@
<DependentUpon>ProfileFields.ascx</DependentUpon>
</Compile>
<Compile Include="Properties\AssemblyInfo.cs" />
+ <Compile Include="Provider.ashx.cs">
+ <DependentUpon>Provider.ashx</DependentUpon>
+ </Compile>
<Compile Include="server.aspx.cs">
<DependentUpon>server.aspx</DependentUpon>
<SubType>ASPXCodeBehind</SubType>
@@ -89,6 +103,13 @@
<Compile Include="server.aspx.designer.cs">
<DependentUpon>server.aspx</DependentUpon>
</Compile>
+ <Compile Include="TracePage.aspx.cs">
+ <DependentUpon>TracePage.aspx</DependentUpon>
+ <SubType>ASPXCodeBehind</SubType>
+ </Compile>
+ <Compile Include="TracePage.aspx.designer.cs">
+ <DependentUpon>TracePage.aspx</DependentUpon>
+ </Compile>
<Compile Include="user.aspx.cs">
<DependentUpon>user.aspx</DependentUpon>
<SubType>ASPXCodeBehind</SubType>
@@ -104,6 +125,27 @@
<Private>True</Private>
</ProjectReference>
</ItemGroup>
+ <ItemGroup>
+ <Content Include="favicon.ico" />
+ <Content Include="images\dotnetopenid_tiny.gif" />
+ <Content Include="Site.Master" />
+ <Content Include="styles.css" />
+ <Content Include="TracePage.aspx" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="Code\CustomStoreDataSet.xsc">
+ <DependentUpon>CustomStoreDataSet.xsd</DependentUpon>
+ </None>
+ <None Include="Code\CustomStoreDataSet.xsd">
+ <Generator>MSDataSetGenerator</Generator>
+ <LastGenOutput>CustomStoreDataSet.Designer.cs</LastGenOutput>
+ <SubType>Designer</SubType>
+ </None>
+ <None Include="Code\CustomStoreDataSet.xss">
+ <DependentUpon>CustomStoreDataSet.xsd</DependentUpon>
+ </None>
+ <Content Include="Provider.ashx" />
+ </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.
@@ -124,6 +166,9 @@
<IISUrl>
</IISUrl>
<NTLMAuthentication>False</NTLMAuthentication>
+ <UseCustomServer>False</UseCustomServer>
+ <CustomServerUrl>
+ </CustomServerUrl>
<SaveServerSettingsInUserFile>False</SaveServerSettingsInUserFile>
</WebProjectProperties>
</FlavorProperties>
diff --git a/samples/ProviderPortal/Site.Master b/samples/ProviderPortal/Site.Master
new file mode 100644
index 0000000..df23ee5
--- /dev/null
+++ b/samples/ProviderPortal/Site.Master
@@ -0,0 +1,20 @@
+<%@ Master Language="C#" AutoEventWireup="true" %>
+
+<!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 id="Head1" runat="server">
+ <title>OpenID Provider, by DotNetOpenId</title>
+ <link href="/styles.css" rel="stylesheet" type="text/css" />
+ <asp:ContentPlaceHolder ID="head" runat="server" />
+</head>
+<body>
+ <form id="form1" runat="server">
+ <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/ProviderPortal/TracePage.aspx b/samples/ProviderPortal/TracePage.aspx
new file mode 100644
index 0000000..34eff79
--- /dev/null
+++ b/samples/ProviderPortal/TracePage.aspx
@@ -0,0 +1,16 @@
+<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="TracePage.aspx.cs" Inherits="ProviderPortal.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/ProviderPortal/TracePage.aspx.cs b/samples/ProviderPortal/TracePage.aspx.cs
new file mode 100644
index 0000000..6360289
--- /dev/null
+++ b/samples/ProviderPortal/TracePage.aspx.cs
@@ -0,0 +1,19 @@
+using System;
+using System.Collections.Generic;
+using System.Web;
+using System.Web.UI;
+using System.Web.UI.WebControls;
+
+namespace ProviderPortal {
+ public partial class TracePage : System.Web.UI.Page {
+ protected void Page_Load(object sender, EventArgs e) {
+ placeHolder1.Controls.Add(new Label { Text = 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.
+ Response.Redirect(Request.Url.AbsoluteUri);
+ }
+ }
+} \ No newline at end of file
diff --git a/samples/ProviderPortal/TracePage.aspx.designer.cs b/samples/ProviderPortal/TracePage.aspx.designer.cs
new file mode 100644
index 0000000..34daa82
--- /dev/null
+++ b/samples/ProviderPortal/TracePage.aspx.designer.cs
@@ -0,0 +1,43 @@
+//------------------------------------------------------------------------------
+// <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>
+//------------------------------------------------------------------------------
+
+namespace ProviderPortal {
+
+
+ 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/ProviderPortal/Web.config b/samples/ProviderPortal/Web.config
index daf5394..1c4649e 100644
--- a/samples/ProviderPortal/Web.config
+++ b/samples/ProviderPortal/Web.config
@@ -9,19 +9,37 @@
-->
<configuration>
<configSections>
- <section name="urlrewrites" type="ProviderPortal.URLRewriter"/>
+ <section name="uri" type="System.Configuration.UriSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
+ <section name="urlrewrites" type="ProviderPortal.URLRewriter" requirePermission="false"/>
+ <section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler" requirePermission="false" />
+ <sectionGroup name="dotNetOpenId">
+ <section name="relyingParty" type="DotNetOpenId.Configuration.RelyingPartySection" requirePermission="false" allowLocation="true"/>
+ <section name="provider" type="DotNetOpenId.Configuration.ProviderSection" requirePermission="false" allowLocation="true"/>
+ <section name="untrustedWebRequest" type="DotNetOpenId.Configuration.UntrustedWebRequestSection" requirePermission="false" allowLocation="false"/>
+ </sectionGroup>
</configSections>
- <system.diagnostics>
- <switches>
- <add name="OpenID" value="4"/>
- </switches>
- <trace autoflush="true" indentsize="4">
- <listeners>
- <add name="fileLogger" type="System.Diagnostics.TextWriterTraceListener"
- initializeData="openidServerTrace.txt"/>
- </listeners>
- </trace>
- </system.diagnostics>
+
+ <!-- this is an optional configuration section where aspects of dotnetopenid can be customized -->
+ <dotNetOpenId>
+ <provider>
+ <!-- Uncomment the following to activate the sample custom store. -->
+ <!--<store type="ProviderPortal.Code.CustomStore, ProviderPortal" />-->
+ </provider>
+ <untrustedWebRequest>
+ <whitelistHosts>
+ <!-- since this is a sample, and will often be used with localhost -->
+ <add name="localhost" />
+ </whitelistHosts>
+ </untrustedWebRequest>
+ </dotNetOpenId>
+
+ <!-- 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>
+
<connectionStrings/>
<!--
Original version created by Richard Birkby (2002-02-22, http://www.codeproject.com/aspnet/URLRewriter.asp)
@@ -61,9 +79,9 @@
<!-- Trust level discussion:
Full: everything works
High: TRACE compilation symbol must NOT be defined
- Medium/Low: doesn't work on default machine.config. ConfigurationPermission is denied (why is it needed?)
+ Medium/Low: doesn't work on default machine.config, because WebPermission.Connect is denied.
-->
- <trust level="Full" originUrl=""/>
+ <trust level="High" originUrl=""/>
</system.web>
<location path="decide.aspx">
<system.web>
@@ -72,4 +90,34 @@
</authorization>
</system.web>
</location>
+
+ <!-- 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="Provider.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="ProviderPortal.Code.TracePageAppender, ProviderPortal">
+ <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="DotNetOpenId">
+ <level value="ALL" />
+ </logger>
+ </log4net>
</configuration>
diff --git a/samples/ProviderPortal/decide.aspx b/samples/ProviderPortal/decide.aspx
index 31851ee..bd3f817 100644
--- a/samples/ProviderPortal/decide.aspx
+++ b/samples/ProviderPortal/decide.aspx
@@ -1,12 +1,7 @@
-<%@ Page Language="C#" AutoEventWireup="true" Inherits="decide" CodeBehind="decide.aspx.cs" %>
+<%@ Page Language="C#" AutoEventWireup="true" Inherits="decide" CodeBehind="decide.aspx.cs" MasterPageFile="~/Site.Master" %>
<%@ Register Src="ProfileFields.ascx" TagName="ProfileFields" TagPrefix="uc1" %>
-<html>
-<head>
- <title>Approve OpenID request?</title>
-</head>
-<body>
- <form id="Form1" runat="server">
+<asp:Content runat="server" ContentPlaceHolderID="Main">
<p>
A site has asked to authenticate that you own the identifier below.&nbsp; You should
only do this if you wish to log in to the site given by the Realm.</p>
@@ -36,6 +31,4 @@
<uc1:ProfileFields ID="profileFields" runat="server" Visible="false" />
<asp:Button ID="yes_button" OnClick="Yes_Click" Text=" yes " runat="Server" />
<asp:Button ID="no_button" OnClick="No_Click" Text=" no " runat="Server" />
- </form>
-</body>
-</html>
+</asp:Content> \ No newline at end of file
diff --git a/samples/ProviderPortal/decide.aspx.cs b/samples/ProviderPortal/decide.aspx.cs
index 882c320..2c563a6 100644
--- a/samples/ProviderPortal/decide.aspx.cs
+++ b/samples/ProviderPortal/decide.aspx.cs
@@ -4,6 +4,7 @@ using System.Web.Security;
using System.Web.UI;
using DotNetOpenId.Extensions.SimpleRegistration;
using DotNetOpenId.Provider;
+using DotNetOpenId.Extensions.ProviderAuthenticationPolicy;
/// <summary>
/// Page for giving the user the option to continue or cancel out of authentication with a consumer.
@@ -23,16 +24,16 @@ public partial class decide : Page {
realmLabel.Text = ProviderEndpoint.PendingAuthenticationRequest.Realm.ToString();
// check that the logged in user is the same as the user requesting authentication to the consumer. If not, then log them out.
- if (User.Identity.Name == Util.ExtractUserName(ProviderEndpoint.PendingAuthenticationRequest.LocalIdentifier)) {
+ if (String.Equals(User.Identity.Name, Util.ExtractUserName(ProviderEndpoint.PendingAuthenticationRequest.LocalIdentifier), StringComparison.OrdinalIgnoreCase)) {
// if simple registration fields were used, then prompt the user for them
var requestedFields = ProviderEndpoint.PendingAuthenticationRequest.GetExtension<ClaimsRequest>();
if (requestedFields != null) {
this.profileFields.Visible = true;
this.profileFields.SetRequiredFieldsFromRequest(requestedFields);
if (!IsPostBack) {
- this.profileFields.OpenIdProfileFields = new ClaimsResponse() {
- Email = Membership.GetUser().Email,
- };
+ var sregResponse = requestedFields.CreateResponse();
+ sregResponse.Email = Membership.GetUser().Email;
+ this.profileFields.SetOpenIdProfileFields(sregResponse);
}
}
} else {
@@ -42,8 +43,21 @@ public partial class decide : Page {
}
protected void Yes_Click(Object sender, EventArgs e) {
+ var sregRequest = ProviderEndpoint.PendingAuthenticationRequest.GetExtension<ClaimsRequest>();
+ ClaimsResponse sregResponse = null;
+ if (sregRequest != null) {
+ sregResponse = profileFields.GetOpenIdProfileFields(sregRequest);
+ ProviderEndpoint.PendingAuthenticationRequest.AddResponseExtension(sregResponse);
+ }
+ var papeRequest = ProviderEndpoint.PendingAuthenticationRequest.GetExtension<PolicyRequest>();
+ PolicyResponse papeResponse = null;
+ if (papeRequest != null) {
+ papeResponse = new PolicyResponse();
+ papeResponse.NistAssuranceLevel = NistAssuranceLevel.InsufficientForLevel1;
+ ProviderEndpoint.PendingAuthenticationRequest.AddResponseExtension(papeResponse);
+ }
+
ProviderEndpoint.PendingAuthenticationRequest.IsAuthenticated = true;
- ProviderEndpoint.PendingAuthenticationRequest.AddResponseExtension(profileFields.OpenIdProfileFields);
Debug.Assert(ProviderEndpoint.PendingAuthenticationRequest.IsResponseReady);
ProviderEndpoint.PendingAuthenticationRequest.Response.Send();
ProviderEndpoint.PendingAuthenticationRequest = null;
diff --git a/samples/ProviderPortal/decide.aspx.designer.cs b/samples/ProviderPortal/decide.aspx.designer.cs
index 46a5f6f..4b26c69 100644
--- a/samples/ProviderPortal/decide.aspx.designer.cs
+++ b/samples/ProviderPortal/decide.aspx.designer.cs
@@ -13,15 +13,6 @@
public partial class decide {
/// <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>
/// relyingPartyVerificationResultLabel control.
/// </summary>
/// <remarks>
diff --git a/samples/ProviderPortal/favicon.ico b/samples/ProviderPortal/favicon.ico
new file mode 100644
index 0000000..beb3cb5
--- /dev/null
+++ b/samples/ProviderPortal/favicon.ico
Binary files differ
diff --git a/samples/ProviderPortal/images/dotnetopenid_tiny.gif b/samples/ProviderPortal/images/dotnetopenid_tiny.gif
new file mode 100644
index 0000000..c4ed4f5
--- /dev/null
+++ b/samples/ProviderPortal/images/dotnetopenid_tiny.gif
Binary files differ
diff --git a/samples/ProviderPortal/login.aspx b/samples/ProviderPortal/login.aspx
index 9b37600..e8bf67b 100644
--- a/samples/ProviderPortal/login.aspx
+++ b/samples/ProviderPortal/login.aspx
@@ -1,14 +1,5 @@
-<%@ Page Language="C#" AutoEventWireup="true" Inherits="login" CodeBehind="login.aspx.cs" %>
-
-<html>
-<head>
- <title>Login</title>
-</head>
-<body>
- <form id="Form1" runat="server">
- <h1>
- OpenID Provider Login
- </h1>
+<%@ Page Language="C#" AutoEventWireup="true" Inherits="login" CodeBehind="login.aspx.cs" MasterPageFile="~/Site.Master" %>
+<asp:Content ID="Content1" runat="server" ContentPlaceHolderID="Main">
<p>
Usernames are defined in the App_Data\Users.xml file.
</p>
@@ -23,6 +14,4 @@
<tr><td>bob3</td><td>test</td></tr>
<tr><td>bob4</td><td>test</td></tr>
</table>
- </form>
-</body>
-</html>
+</asp:Content> \ No newline at end of file
diff --git a/samples/ProviderPortal/login.aspx.designer.cs b/samples/ProviderPortal/login.aspx.designer.cs
index e498e6a..0a6a122 100644
--- a/samples/ProviderPortal/login.aspx.designer.cs
+++ b/samples/ProviderPortal/login.aspx.designer.cs
@@ -13,15 +13,6 @@
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.HtmlControls.HtmlForm Form1;
-
- /// <summary>
/// login1 control.
/// </summary>
/// <remarks>
diff --git a/samples/ProviderPortal/op_xrds.aspx b/samples/ProviderPortal/op_xrds.aspx
index 7d0ca2c..b906bfe 100644
--- a/samples/ProviderPortal/op_xrds.aspx
+++ b/samples/ProviderPortal/op_xrds.aspx
@@ -12,7 +12,7 @@ This XRDS doc is discovered via the user.aspx page.
<XRD>
<Service priority="10">
<Type>http://specs.openid.net/auth/2.0/server</Type>
- <Type>http://openid.net/sreg/1.0</Type>
+ <Type>http://openid.net/extensions/sreg/1.1</Type>
<URI><%=new Uri(Request.Url, Response.ApplyAppPathModifier("~/server.aspx"))%></URI>
</Service>
</XRD>
diff --git a/samples/ProviderPortal/server.aspx b/samples/ProviderPortal/server.aspx
index 318df4a..e67a7ba 100644
--- a/samples/ProviderPortal/server.aspx
+++ b/samples/ProviderPortal/server.aspx
@@ -7,6 +7,13 @@
</head>
<body>
<form runat='server'>
+ <%-- This page provides an example of how to use the ProviderEndpoint control on an ASPX page
+ to host an OpenID Provider. Alternatively for greater performance an .ashx file can be used.
+ See Provider.ashx for an example. A typical web site will NOT use both .ashx and .aspx
+ provider endpoints.
+ This server.aspx page is the default provider endpoint to use. To switch to the .ashx handler,
+ change the user_xrds.aspx and op_xrds.aspx files to point to provider.ashx instead of server.aspx.
+ --%>
<openid:ProviderEndpoint runat="server" OnAuthenticationChallenge="provider_AuthenticationChallenge" />
<p>
<asp:Label ID="serverEndpointUrl" runat="server" EnableViewState="false" />
diff --git a/samples/ProviderPortal/server.aspx.cs b/samples/ProviderPortal/server.aspx.cs
index 8589f40..fbc9a6c 100644
--- a/samples/ProviderPortal/server.aspx.cs
+++ b/samples/ProviderPortal/server.aspx.cs
@@ -10,24 +10,6 @@ public partial class server : System.Web.UI.Page {
serverEndpointUrl.Text = Request.Url.ToString();
}
protected void provider_AuthenticationChallenge(object sender, AuthenticationChallengeEventArgs e) {
- var idrequest = e.Request;
- if (idrequest.Immediate) {
- if (idrequest.IsDirectedIdentity) {
- if (User.Identity.IsAuthenticated) {
- idrequest.LocalIdentifier = Util.BuildIdentityUrl();
- idrequest.IsAuthenticated = true;
- } else {
- idrequest.IsAuthenticated = false;
- }
- } else {
- string userOwningOpenIdUrl = Util.ExtractUserName(idrequest.LocalIdentifier);
- // NOTE: in a production provider site, you may want to only
- // respond affirmatively if the user has already authorized this consumer
- // to know the answer.
- idrequest.IsAuthenticated = userOwningOpenIdUrl == User.Identity.Name;
- }
- } else {
- Response.Redirect("~/decide.aspx", true); // This ends processing on this page.
- }
+ Util.ProcessAuthenticationChallenge(e.Request);
}
} \ No newline at end of file
diff --git a/samples/ProviderPortal/server.aspx.designer.cs b/samples/ProviderPortal/server.aspx.designer.cs
index 16dd628..90203b1 100644
--- a/samples/ProviderPortal/server.aspx.designer.cs
+++ b/samples/ProviderPortal/server.aspx.designer.cs
@@ -1,7 +1,7 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
-// Runtime Version:2.0.50727.1434
+// Runtime Version:2.0.50727.3053
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
diff --git a/samples/ProviderPortal/styles.css b/samples/ProviderPortal/styles.css
new file mode 100644
index 0000000..62605db
--- /dev/null
+++ b/samples/ProviderPortal/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/ProviderPortal/user.aspx b/samples/ProviderPortal/user.aspx
index 581e30f..fc3716f 100644
--- a/samples/ProviderPortal/user.aspx
+++ b/samples/ProviderPortal/user.aspx
@@ -1,18 +1,17 @@
-<%@ Page Language="C#" AutoEventWireup="true" Inherits="user" CodeBehind="user.aspx.cs" %>
+<%@ Page Language="C#" AutoEventWireup="true" Inherits="user" CodeBehind="user.aspx.cs" MasterPageFile="~/Site.Master" %>
<%@ Register Assembly="DotNetOpenId" Namespace="DotNetOpenId.Provider" TagPrefix="openid" %>
-<html>
-<head>
+<asp:Content ID="Content2" runat="server" ContentPlaceHolderID="head">
<openid:IdentityEndpoint ID="IdentityEndpoint20" runat="server" ProviderEndpointUrl="~/Server.aspx"
- XrdsUrl="~/user_xrds.aspx" ProviderVersion="V20" />
+ XrdsUrl="~/user_xrds.aspx" ProviderVersion="V20"
+ AutoNormalizeRequest="true" OnNormalizeUri="IdentityEndpoint20_NormalizeUri" />
<!-- and for backward compatibility with OpenID 1.x RPs... -->
<openid:IdentityEndpoint ID="IdentityEndpoint11" runat="server" ProviderEndpointUrl="~/Server.aspx"
ProviderVersion="V11" />
-</head>
-<body>
+</asp:Content>
+<asp:Content ID="Content1" runat="server" ContentPlaceHolderID="Main">
<p>
OpenID identity page for
<asp:Label runat="server" ID="usernameLabel" EnableViewState="false" />
</p>
-</body>
-</html>
+</asp:Content> \ No newline at end of file
diff --git a/samples/ProviderPortal/user.aspx.cs b/samples/ProviderPortal/user.aspx.cs
index 5400200..744cae5 100644
--- a/samples/ProviderPortal/user.aspx.cs
+++ b/samples/ProviderPortal/user.aspx.cs
@@ -1,5 +1,5 @@
using System;
-using System.Configuration;
+using DotNetOpenId.Provider;
/// <summary>
/// This page is a required as part of the service discovery phase of the openid protocol (step 1).
@@ -18,4 +18,15 @@ public partial class user : System.Web.UI.Page {
protected void Page_Load(object sender, EventArgs e) {
usernameLabel.Text = Request.QueryString["username"];
}
+
+ protected void IdentityEndpoint20_NormalizeUri(object sender, IdentityEndpointNormalizationEventArgs e) {
+ // This sample Provider has a custom policy for normalizing URIs, which is that the whole
+ // path of the URI be lowercase except for the first letter of the username.
+ UriBuilder normalized = new UriBuilder(e.UserSuppliedIdentifier);
+ string username = Request.QueryString["username"].TrimEnd('/').ToLowerInvariant();
+ username = username.Substring(0, 1).ToUpperInvariant() + username.Substring(1);
+ normalized.Path = "/user/" + username;
+ normalized.Scheme = "http"; // for a real Provider, this should be HTTPS if supported.
+ e.NormalizedIdentifier = normalized.Uri;
+ }
}
diff --git a/samples/ProviderPortal/user_xrds.aspx b/samples/ProviderPortal/user_xrds.aspx
index 4f3e446..56b1244 100644
--- a/samples/ProviderPortal/user_xrds.aspx
+++ b/samples/ProviderPortal/user_xrds.aspx
@@ -12,12 +12,12 @@ This XRDS doc is discovered via the user.aspx page.
<XRD>
<Service priority="10">
<Type>http://specs.openid.net/auth/2.0/signon</Type>
- <Type>http://openid.net/sreg/1.0</Type>
+ <Type>http://openid.net/extensions/sreg/1.1</Type>
<URI><%=new Uri(Request.Url, Response.ApplyAppPathModifier("~/server.aspx"))%></URI>
</Service>
<Service priority="20">
<Type>http://openid.net/signon/1.0</Type>
- <Type>http://openid.net/sreg/1.0</Type>
+ <Type>http://openid.net/extensions/sreg/1.1</Type>
<URI><%=new Uri(Request.Url, Response.ApplyAppPathModifier("~/server.aspx"))%></URI>
</Service>
</XRD>