summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAndrew Arnott <andrewarnott@gmail.com>2009-06-23 20:33:54 -0700
committerAndrew Arnott <andrewarnott@gmail.com>2009-06-23 20:33:54 -0700
commit81672a6eb31990005c3e9e7ecabdb3efffdb0a78 (patch)
treec197074c7939b12b6ac777787c704846b244f08a /src
parent39dea3bfb16fd38b1f6aafb1324abcd006a358be (diff)
downloadDotNetOpenAuth-81672a6eb31990005c3e9e7ecabdb3efffdb0a78.zip
DotNetOpenAuth-81672a6eb31990005c3e9e7ecabdb3efffdb0a78.tar.gz
DotNetOpenAuth-81672a6eb31990005c3e9e7ecabdb3efffdb0a78.tar.bz2
OAuth WCF service sample now impersonates the original user in the thread's current principal.
Diffstat (limited to 'src')
-rw-r--r--src/DotNetOpenAuth/OAuth/ServiceProvider.cs14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/DotNetOpenAuth/OAuth/ServiceProvider.cs b/src/DotNetOpenAuth/OAuth/ServiceProvider.cs
index 45894c9..242e0db 100644
--- a/src/DotNetOpenAuth/OAuth/ServiceProvider.cs
+++ b/src/DotNetOpenAuth/OAuth/ServiceProvider.cs
@@ -10,6 +10,7 @@ namespace DotNetOpenAuth.OAuth {
using System.Diagnostics.CodeAnalysis;
using System.Diagnostics.Contracts;
using System.Globalization;
+ using System.Security.Principal;
using System.ServiceModel.Channels;
using System.Web;
using DotNetOpenAuth.Configuration;
@@ -469,6 +470,19 @@ namespace DotNetOpenAuth.OAuth {
return accessMessage;
}
+ /// <summary>
+ /// Creates a security principal that may be used.
+ /// </summary>
+ /// <param name="request">The request.</param>
+ /// <returns>The <see cref="IPrincipal"/> instance that can be used for access control of resources.</returns>
+ public OAuthPrincipal CreatePrincipal(AccessProtectedResourceRequest request) {
+ Contract.Requires(request != null);
+ ErrorUtilities.VerifyArgumentNotNull(request, "request");
+
+ IServiceProviderAccessToken accessToken = this.TokenManager.GetAccessToken(request.AccessToken);
+ return new OAuthPrincipal(accessToken);
+ }
+
#region IDisposable Members
/// <summary>