summaryrefslogtreecommitdiffstats
path: root/samples/OAuthServiceProvider/App_Code
diff options
context:
space:
mode:
Diffstat (limited to 'samples/OAuthServiceProvider/App_Code')
-rw-r--r--samples/OAuthServiceProvider/App_Code/DatabaseTokenManager.cs10
-rw-r--r--samples/OAuthServiceProvider/App_Code/OAuthToken.cs22
2 files changed, 30 insertions, 2 deletions
diff --git a/samples/OAuthServiceProvider/App_Code/DatabaseTokenManager.cs b/samples/OAuthServiceProvider/App_Code/DatabaseTokenManager.cs
index 8ca4539..710508d 100644
--- a/samples/OAuthServiceProvider/App_Code/DatabaseTokenManager.cs
+++ b/samples/OAuthServiceProvider/App_Code/DatabaseTokenManager.cs
@@ -26,7 +26,15 @@ public class DatabaseTokenManager : IServiceProviderTokenManager {
public IServiceProviderRequestToken GetRequestToken(string token) {
try {
- return Global.DataContext.OAuthTokens.First(t => t.Token == token);
+ 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);
}
diff --git a/samples/OAuthServiceProvider/App_Code/OAuthToken.cs b/samples/OAuthServiceProvider/App_Code/OAuthToken.cs
index ec9b31e..fc1d6c5 100644
--- a/samples/OAuthServiceProvider/App_Code/OAuthToken.cs
+++ b/samples/OAuthServiceProvider/App_Code/OAuthToken.cs
@@ -10,7 +10,7 @@ using System.Linq;
using System.Web;
using DotNetOpenAuth.OAuth.ChannelElements;
-public partial class OAuthToken : IServiceProviderRequestToken {
+public partial class OAuthToken : IServiceProviderRequestToken, IServiceProviderAccessToken {
#region IServiceProviderRequestToken Members
string IServiceProviderRequestToken.Token {
@@ -41,4 +41,24 @@ public partial class OAuthToken : IServiceProviderRequestToken {
}
#endregion
+
+ #region IServiceProviderAccessToken Members
+
+ string IServiceProviderAccessToken.Token {
+ get { return this.Token; }
+ }
+
+ DateTime? IServiceProviderAccessToken.ExpirationDate {
+ get { return null; }
+ }
+
+ string IServiceProviderAccessToken.Username {
+ get { return this.User.OpenIDClaimedIdentifier; }
+ }
+
+ string[] IServiceProviderAccessToken.Roles {
+ get { return this.Scope.Split('|'); }
+ }
+
+ #endregion
}