summaryrefslogtreecommitdiffstats
path: root/src/OAuth/OAuthServiceProvider/Code/OAuthToken.cs
diff options
context:
space:
mode:
authorDavid Christiansen <coding@davedoes.net>2012-03-15 22:10:55 +0000
committerDavid Christiansen <coding@davedoes.net>2012-03-15 22:10:55 +0000
commita5bfa2bb8a614b1932ec8b7bbc6a0cc6bca3051f (patch)
treea3057157fa3287e0c0c4cc49be1854f9aa63d321 /src/OAuth/OAuthServiceProvider/Code/OAuthToken.cs
parent02ce959db12fec57e846e5ebfa662cd0327ce69c (diff)
downloadDotNetOpenAuth.Samples-a5bfa2bb8a614b1932ec8b7bbc6a0cc6bca3051f.zip
DotNetOpenAuth.Samples-a5bfa2bb8a614b1932ec8b7bbc6a0cc6bca3051f.tar.gz
DotNetOpenAuth.Samples-a5bfa2bb8a614b1932ec8b7bbc6a0cc6bca3051f.tar.bz2
W.I.P.
* Initial migration and reference to DNOA Nuget packages (From teamcity.dotnetopenauth.net) * Awaiting fix to DotNetOpenAuth.OpenIdOAuth.nuspec in order to complete migration.
Diffstat (limited to 'src/OAuth/OAuthServiceProvider/Code/OAuthToken.cs')
-rw-r--r--src/OAuth/OAuthServiceProvider/Code/OAuthToken.cs95
1 files changed, 95 insertions, 0 deletions
diff --git a/src/OAuth/OAuthServiceProvider/Code/OAuthToken.cs b/src/OAuth/OAuthServiceProvider/Code/OAuthToken.cs
new file mode 100644
index 0000000..709b139
--- /dev/null
+++ b/src/OAuth/OAuthServiceProvider/Code/OAuthToken.cs
@@ -0,0 +1,95 @@
+//-----------------------------------------------------------------------
+// <copyright file="OAuthToken.cs" company="Outercurve Foundation">
+// Copyright (c) Outercurve Foundation. All rights reserved.
+// </copyright>
+//-----------------------------------------------------------------------
+
+namespace OAuthServiceProvider.Code {
+ using System;
+ using System.Collections.Generic;
+ using System.Linq;
+ using System.Web;
+ using DotNetOpenAuth.OAuth.ChannelElements;
+
+ public partial class OAuthToken : IServiceProviderRequestToken, IServiceProviderAccessToken {
+ #region IServiceProviderRequestToken Members
+
+ string IServiceProviderRequestToken.Token {
+ get { return this.Token; }
+ }
+
+ string IServiceProviderRequestToken.ConsumerKey {
+ get { return this.OAuthConsumer.ConsumerKey; }
+ }
+
+ DateTime IServiceProviderRequestToken.CreatedOn {
+ get { return this.IssueDate; }
+ }
+
+ Uri IServiceProviderRequestToken.Callback {
+ get { return string.IsNullOrEmpty(this.RequestTokenCallback) ? null : new Uri(this.RequestTokenCallback); }
+ set { this.RequestTokenCallback = value.AbsoluteUri; }
+ }
+
+ string IServiceProviderRequestToken.VerificationCode {
+ get { return this.RequestTokenVerifier; }
+ set { this.RequestTokenVerifier = value; }
+ }
+
+ Version IServiceProviderRequestToken.ConsumerVersion {
+ get { return new Version(this.ConsumerVersion); }
+ set { this.ConsumerVersion = value.ToString(); }
+ }
+
+ #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
+
+ /// <summary>
+ /// Called by LinqToSql when the <see cref="IssueDate"/> property is about to change.
+ /// </summary>
+ /// <param name="value">The value.</param>
+ partial void OnIssueDateChanging(DateTime value) {
+ if (value.Kind == DateTimeKind.Unspecified) {
+ throw new ArgumentException("The DateTime.Kind cannot be Unspecified to ensure accurate timestamp checks.");
+ }
+ }
+
+ /// <summary>
+ /// Called by LinqToSql when <see cref="IssueDate"/> has changed.
+ /// </summary>
+ partial void OnIssueDateChanged() {
+ if (this.IssueDate.Kind == DateTimeKind.Local) {
+ this._IssueDate = this.IssueDate.ToUniversalTime();
+ }
+ }
+
+ /// <summary>
+ /// Called by LinqToSql when a token instance is deserialized.
+ /// </summary>
+ partial void OnLoaded() {
+ if (this.IssueDate.Kind == DateTimeKind.Unspecified) {
+ // this detail gets lost in db storage, but must be reaffirmed so that expiratoin checks succeed.
+ this._IssueDate = DateTime.SpecifyKind(this.IssueDate, DateTimeKind.Utc);
+ }
+ }
+ }
+} \ No newline at end of file