diff options
author | Andrew Arnott <andrewarnott@gmail.com> | 2013-01-27 16:59:56 -0800 |
---|---|---|
committer | Andrew Arnott <andrewarnott@gmail.com> | 2013-01-27 16:59:56 -0800 |
commit | a1dea3a8fed9581b85245421425849981e9d97c0 (patch) | |
tree | 416eb7144f580268c1b48af3fe2e7008b2cdd10e /projecttemplates/RelyingPartyLogic/OAuthAuthenticationModule.cs | |
parent | e146cfee1b56de1eab711eba984081b3e542fb98 (diff) | |
download | DotNetOpenAuth-a1dea3a8fed9581b85245421425849981e9d97c0.zip DotNetOpenAuth-a1dea3a8fed9581b85245421425849981e9d97c0.tar.gz DotNetOpenAuth-a1dea3a8fed9581b85245421425849981e9d97c0.tar.bz2 |
projecttemplates now build.
Diffstat (limited to 'projecttemplates/RelyingPartyLogic/OAuthAuthenticationModule.cs')
-rw-r--r-- | projecttemplates/RelyingPartyLogic/OAuthAuthenticationModule.cs | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/projecttemplates/RelyingPartyLogic/OAuthAuthenticationModule.cs b/projecttemplates/RelyingPartyLogic/OAuthAuthenticationModule.cs index 254f77d..452a898 100644 --- a/projecttemplates/RelyingPartyLogic/OAuthAuthenticationModule.cs +++ b/projecttemplates/RelyingPartyLogic/OAuthAuthenticationModule.cs @@ -9,6 +9,8 @@ namespace RelyingPartyLogic { using System.Collections.Generic; using System.Linq; using System.Security.Principal; + using System.Threading; + using System.Threading.Tasks; using System.Web; using System.Web.Security; using DotNetOpenAuth.Messaging; @@ -52,13 +54,21 @@ namespace RelyingPartyLogic { using (var crypto = OAuthResourceServer.CreateRSA()) { var tokenAnalyzer = new SpecialAccessTokenAnalyzer(crypto, crypto); var resourceServer = new ResourceServer(tokenAnalyzer); + var context = this.application.Context; + Task.Run( + async delegate { + ProtocolFaultResponseException exception = null; + try { + IPrincipal principal = await resourceServer.GetPrincipalAsync(new HttpRequestWrapper(context.Request)); + context.User = principal; + return; + } catch (ProtocolFaultResponseException ex) { + exception = ex; + } - try { - IPrincipal principal = resourceServer.GetPrincipal(new HttpRequestWrapper(this.application.Context.Request)); - this.application.Context.User = principal; - } catch (ProtocolFaultResponseException ex) { - ex.CreateErrorResponseAsync().Send(); - } + var errorResponse = await exception.CreateErrorResponseAsync(CancellationToken.None); + await errorResponse.SendAsync(); + }).Wait(); } } |