diff options
author | Andrew Arnott <andrewarnott@gmail.com> | 2010-04-18 22:29:23 -0400 |
---|---|---|
committer | Andrew Arnott <andrewarnott@gmail.com> | 2010-04-18 22:29:23 -0400 |
commit | fef932af78eac2b775452c4a851e84a813027548 (patch) | |
tree | 7df395b2b795987d8ac4a7da231f30208916a88d /samples/OAuthServiceProvider/DataApi.cs | |
parent | 5b47cd88af9d7b1fc04e69a98a6f912624d275a6 (diff) | |
download | DotNetOpenAuth-fef932af78eac2b775452c4a851e84a813027548.zip DotNetOpenAuth-fef932af78eac2b775452c4a851e84a813027548.tar.gz DotNetOpenAuth-fef932af78eac2b775452c4a851e84a813027548.tar.bz2 |
Converted the OAuth consumer and SP sample web site projects to web application projects.
Diffstat (limited to 'samples/OAuthServiceProvider/DataApi.cs')
-rw-r--r-- | samples/OAuthServiceProvider/DataApi.cs | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/samples/OAuthServiceProvider/DataApi.cs b/samples/OAuthServiceProvider/DataApi.cs new file mode 100644 index 0000000..d5adb10 --- /dev/null +++ b/samples/OAuthServiceProvider/DataApi.cs @@ -0,0 +1,31 @@ +using System.Linq; +using System.ServiceModel; + +/// <summary> +/// The WCF service API. +/// </summary> +/// <remarks> +/// Note how there is no code here that is bound to OAuth or any other +/// credential/authorization scheme. That's all part of the channel/binding elsewhere. +/// And the reference to OperationContext.Current.ServiceSecurityContext.PrimaryIdentity +/// is the user being impersonated by the WCF client. +/// In the OAuth case, it is the user who authorized the OAuth access token that was used +/// to gain access to the service. +/// </remarks> +public class DataApi : IDataApi { + private User User { + get { return OperationContext.Current.ServiceSecurityContext.PrimaryIdentity.GetUser(); } + } + + public int? GetAge() { + return User.Age; + } + + public string GetName() { + return User.FullName; + } + + public string[] GetFavoriteSites() { + return User.FavoriteSites.Select(site => site.SiteUrl).ToArray(); + } +} |