Skip to content
This repository was archived by the owner on Mar 20, 2019. It is now read-only.

Commit e865ec7

Browse files
committed
Added OpenID sample sites: RP MVC, RP WebForms, RP Classic ASP, OP WebForms.
1 parent f6d5493 commit e865ec7

120 files changed

Lines changed: 11725 additions & 80 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

lib/System.Web.Abstractions.dll

-2.18 KB
Binary file not shown.

lib/System.Web.Mvc.dll

72.3 KB
Binary file not shown.

lib/System.Web.Mvc.xml

Lines changed: 3136 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/System.Web.Routing.dll

-2.18 KB
Binary file not shown.

samples/ConsumerWpf/ConsumerWpf.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@
101101
</ProjectReference>
102102
<ProjectReference Include="..\DotNetOpenAuth.ApplicationBlock\DotNetOpenAuth.ApplicationBlock.csproj">
103103
<Project>{AA78D112-D889-414B-A7D4-467B34C7B663}</Project>
104-
<Name>DotNetOAuth.ApplicationBlock</Name>
104+
<Name>DotNetOpenAuth.ApplicationBlock</Name>
105105
</ProjectReference>
106106
</ItemGroup>
107107
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />

samples/ProviderPortal/.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Bin
2+
obj
3+
*.user
4+
*.log
5+
StyleCop.Cache
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*.LDF
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<Users>
3+
<User>
4+
<UserName>bob</UserName>
5+
<Password>test</Password>
6+
</User>
7+
<User>
8+
<UserName>bob1</UserName>
9+
<Password>test</Password>
10+
</User>
11+
<User>
12+
<UserName>bob2</UserName>
13+
<Password>test</Password>
14+
</User>
15+
<User>
16+
<UserName>bob3</UserName>
17+
<Password>test</Password>
18+
</User>
19+
<User>
20+
<UserName>bob4</UserName>
21+
<Password>test</Password>
22+
</User>
23+
</Users>
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
//-----------------------------------------------------------------------
2+
// <copyright file="CustomStore.cs" company="Andrew Arnott">
3+
// Copyright (c) Andrew Arnott. All rights reserved.
4+
// </copyright>
5+
//-----------------------------------------------------------------------
6+
7+
namespace OpenIdProviderWebForms.Code {
8+
using System;
9+
using System.Data;
10+
using System.Globalization;
11+
using System.Security.Cryptography;
12+
using DotNetOpenAuth.OpenId;
13+
using IProviderAssociationStore = DotNetOpenAuth.OpenId.IAssociationStore<DotNetOpenAuth.OpenId.AssociationRelyingPartyType>;
14+
15+
/// <summary>
16+
/// This custom store serializes all elements to demonstrate peristent and/or shared storage.
17+
/// This is common in a web farm, for example.
18+
/// </summary>
19+
/// <remarks>
20+
/// This doesn't actually serialize anything to a persistent store, so restarting the web server
21+
/// will still clear everything this store is supposed to remember.
22+
/// But we "persist" all associations and nonces into a DataTable to demonstrate
23+
/// that using a database is possible.
24+
/// </remarks>
25+
public class CustomStore : IProviderAssociationStore {
26+
private static CustomStoreDataSet dataSet = new CustomStoreDataSet();
27+
28+
#region IAssociationStore<AssociationRelyingPartyType> Members
29+
30+
public void StoreAssociation(AssociationRelyingPartyType distinguishingFactor, Association assoc) {
31+
var assocRow = dataSet.Association.NewAssociationRow();
32+
assocRow.DistinguishingFactor = distinguishingFactor.ToString();
33+
assocRow.Handle = assoc.Handle;
34+
assocRow.Expires = assoc.Expires.ToLocalTime();
35+
assocRow.PrivateData = assoc.SerializePrivateData();
36+
dataSet.Association.AddAssociationRow(assocRow);
37+
}
38+
39+
public Association GetAssociation(AssociationRelyingPartyType distinguishingFactor) {
40+
// properly escape the URL to prevent injection attacks.
41+
string value = distinguishingFactor.ToString();
42+
string filter = string.Format(
43+
CultureInfo.InvariantCulture,
44+
"{0} = '{1}'",
45+
dataSet.Association.DistinguishingFactorColumn.ColumnName,
46+
value);
47+
string sort = dataSet.Association.ExpiresColumn.ColumnName + " DESC";
48+
DataView view = new DataView(dataSet.Association, filter, sort, DataViewRowState.CurrentRows);
49+
if (view.Count == 0) {
50+
return null;
51+
}
52+
var row = (CustomStoreDataSet.AssociationRow)view[0].Row;
53+
return Association.Deserialize(row.Handle, row.Expires.ToUniversalTime(), row.PrivateData);
54+
}
55+
56+
public Association GetAssociation(AssociationRelyingPartyType distinguishingFactor, string handle) {
57+
var assocRow = dataSet.Association.FindByDistinguishingFactorHandle(distinguishingFactor.ToString(), handle);
58+
return Association.Deserialize(assocRow.Handle, assocRow.Expires, assocRow.PrivateData);
59+
}
60+
61+
public bool RemoveAssociation(AssociationRelyingPartyType distinguishingFactor, string handle) {
62+
var row = dataSet.Association.FindByDistinguishingFactorHandle(distinguishingFactor.ToString(), handle);
63+
if (row != null) {
64+
dataSet.Association.RemoveAssociationRow(row);
65+
return true;
66+
} else {
67+
return false;
68+
}
69+
}
70+
71+
public void ClearExpiredAssociations() {
72+
this.removeExpiredRows(dataSet.Association, dataSet.Association.ExpiresColumn.ColumnName);
73+
}
74+
75+
#endregion
76+
77+
private void removeExpiredRows(DataTable table, string expiredColumnName) {
78+
string filter = string.Format(
79+
CultureInfo.InvariantCulture,
80+
"{0} < #{1}#",
81+
expiredColumnName,
82+
DateTime.Now);
83+
DataView view = new DataView(table, filter, null, DataViewRowState.CurrentRows);
84+
for (int i = view.Count - 1; i >= 0; i--) {
85+
view.Delete(i);
86+
}
87+
}
88+
}
89+
}

0 commit comments

Comments
 (0)