summaryrefslogtreecommitdiffstats
path: root/samples/OAuthServiceProvider/App_Code/DatabaseTokenManager.cs
diff options
context:
space:
mode:
authorAndrew Arnott <andrewarnott@gmail.com>2009-12-01 22:37:17 -0800
committerAndrew Arnott <andrewarnott@gmail.com>2009-12-01 22:37:17 -0800
commit0a1042ae9ff54c5b3523e1cf4210c1fade4a9144 (patch)
tree2b9966e8bc51dfab2bf6e4c893177f2cadb34773 /samples/OAuthServiceProvider/App_Code/DatabaseTokenManager.cs
parent9a90c9cf0884ad7e69de90e9d4dd6a2e50ef86bd (diff)
parent8aa6439564b60e762e66e0055600a0f1a2348803 (diff)
downloadDotNetOpenAuth-0a1042ae9ff54c5b3523e1cf4210c1fade4a9144.zip
DotNetOpenAuth-0a1042ae9ff54c5b3523e1cf4210c1fade4a9144.tar.gz
DotNetOpenAuth-0a1042ae9ff54c5b3523e1cf4210c1fade4a9144.tar.bz2
Merge branch 'v3.2' into mono2
Diffstat (limited to 'samples/OAuthServiceProvider/App_Code/DatabaseTokenManager.cs')
-rw-r--r--samples/OAuthServiceProvider/App_Code/DatabaseTokenManager.cs23
1 files changed, 20 insertions, 3 deletions
diff --git a/samples/OAuthServiceProvider/App_Code/DatabaseTokenManager.cs b/samples/OAuthServiceProvider/App_Code/DatabaseTokenManager.cs
index 275a7c9..710508d 100644
--- a/samples/OAuthServiceProvider/App_Code/DatabaseTokenManager.cs
+++ b/samples/OAuthServiceProvider/App_Code/DatabaseTokenManager.cs
@@ -14,14 +14,30 @@ 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 && t.State != TokenAuthorizationState.AccessToken);
+ } catch (InvalidOperationException ex) {
+ throw new KeyNotFoundException("Unrecognized token", ex);
+ }
+ }
+
+ public IServiceProviderAccessToken GetAccessToken(string token) {
+ try {
+ return Global.DataContext.OAuthTokens.First(t => t.Token == token && t.State == TokenAuthorizationState.AccessToken);
+ } catch (InvalidOperationException ex) {
+ throw new KeyNotFoundException("Unrecognized token", ex);
+ }
}
#endregion
@@ -51,6 +67,7 @@ public class DatabaseTokenManager : IServiceProviderTokenManager {
};
Global.DataContext.OAuthTokens.InsertOnSubmit(newToken);
+ Global.DataContext.SubmitChanges();
}
/// <summary>