summaryrefslogtreecommitdiffstats
path: root/samples/OpenIdRelyingPartyWebForms/Global.asax.cs
diff options
context:
space:
mode:
Diffstat (limited to 'samples/OpenIdRelyingPartyWebForms/Global.asax.cs')
-rw-r--r--samples/OpenIdRelyingPartyWebForms/Global.asax.cs32
1 files changed, 32 insertions, 0 deletions
diff --git a/samples/OpenIdRelyingPartyWebForms/Global.asax.cs b/samples/OpenIdRelyingPartyWebForms/Global.asax.cs
index c7d1e8b..ac74853 100644
--- a/samples/OpenIdRelyingPartyWebForms/Global.asax.cs
+++ b/samples/OpenIdRelyingPartyWebForms/Global.asax.cs
@@ -1,15 +1,47 @@
namespace OpenIdRelyingPartyWebForms {
using System;
using System.Collections.Specialized;
+ using System.Configuration;
using System.IO;
using System.Text;
using System.Web;
+ using DotNetOpenAuth.ApplicationBlock;
+ using DotNetOpenAuth.OAuth;
+ using OpenIdRelyingPartyWebForms.Code;
public class Global : HttpApplication {
public static log4net.ILog Logger = log4net.LogManager.GetLogger(typeof(Global));
internal static StringBuilder LogMessages = new StringBuilder();
+ internal static WebConsumer GoogleWebConsumer {
+ get {
+ var googleWebConsumer = (WebConsumer)HttpContext.Current.Application["GoogleWebConsumer"];
+ if (googleWebConsumer == null) {
+ googleWebConsumer = new WebConsumer(GoogleConsumer.ServiceDescription, GoogleTokenManager);
+ HttpContext.Current.Application["GoogleWebConsumer"] = googleWebConsumer;
+ }
+
+ return googleWebConsumer;
+ }
+ }
+
+ internal static InMemoryTokenManager GoogleTokenManager {
+ get {
+ var tokenManager = (InMemoryTokenManager)HttpContext.Current.Application["GoogleTokenManager"];
+ if (tokenManager == null) {
+ string consumerKey = ConfigurationManager.AppSettings["googleConsumerKey"];
+ string consumerSecret = ConfigurationManager.AppSettings["googleConsumerSecret"];
+ if (!string.IsNullOrEmpty(consumerKey)) {
+ tokenManager = new InMemoryTokenManager(consumerKey, consumerSecret);
+ HttpContext.Current.Application["GoogleTokenManager"] = tokenManager;
+ }
+ }
+
+ return tokenManager;
+ }
+ }
+
public static string ToString(NameValueCollection collection) {
using (StringWriter sw = new StringWriter()) {
foreach (string key in collection.Keys) {