summaryrefslogtreecommitdiffstats
path: root/samples/OAuthServiceProvider/App_Code/DatabaseTokenManager.cs
diff options
context:
space:
mode:
Diffstat (limited to 'samples/OAuthServiceProvider/App_Code/DatabaseTokenManager.cs')
-rw-r--r--samples/OAuthServiceProvider/App_Code/DatabaseTokenManager.cs15
1 files changed, 12 insertions, 3 deletions
diff --git a/samples/OAuthServiceProvider/App_Code/DatabaseTokenManager.cs b/samples/OAuthServiceProvider/App_Code/DatabaseTokenManager.cs
index 275a7c9..8ca4539 100644
--- a/samples/OAuthServiceProvider/App_Code/DatabaseTokenManager.cs
+++ b/samples/OAuthServiceProvider/App_Code/DatabaseTokenManager.cs
@@ -14,14 +14,22 @@ using DotNetOpenAuth.OAuth.Messages;
public class DatabaseTokenManager : IServiceProviderTokenManager {
#region IServiceProviderTokenManager
- public string GetConsumerSecret(string consumerKey) {
+ public IConsumerDescription GetConsumer(string consumerKey) {
var consumerRow = Global.DataContext.OAuthConsumers.SingleOrDefault(
consumerCandidate => consumerCandidate.ConsumerKey == consumerKey);
if (consumerRow == null) {
- throw new ArgumentException();
+ throw new KeyNotFoundException();
}
- return consumerRow.ConsumerSecret;
+ return consumerRow;
+ }
+
+ public IServiceProviderRequestToken GetRequestToken(string token) {
+ try {
+ return Global.DataContext.OAuthTokens.First(t => t.Token == token);
+ } catch (InvalidOperationException ex) {
+ throw new KeyNotFoundException("Unrecognized token", ex);
+ }
}
#endregion
@@ -51,6 +59,7 @@ public class DatabaseTokenManager : IServiceProviderTokenManager {
};
Global.DataContext.OAuthTokens.InsertOnSubmit(newToken);
+ Global.DataContext.SubmitChanges();
}
/// <summary>