summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew Arnott <andrewarnott@gmail.com>2010-03-07 20:44:05 -0800
committerAndrew Arnott <andrewarnott@gmail.com>2010-03-07 20:44:05 -0800
commitd197a28a898228296600c8b87b4f37301004c195 (patch)
treece073ee537d54849f3eb32d819e917831d0f21e0
parent3b33bb048edf2dfcea9f7e9a4b9094ecc509f4e7 (diff)
downloadDotNetOpenAuth-d197a28a898228296600c8b87b4f37301004c195.zip
DotNetOpenAuth-d197a28a898228296600c8b87b4f37301004c195.tar.gz
DotNetOpenAuth-d197a28a898228296600c8b87b4f37301004c195.tar.bz2
StyleCop fixes.
-rw-r--r--samples/DotNetOpenAuth.ApplicationBlock/TwitterConsumer.cs73
-rw-r--r--samples/OpenIdWebRingSsoProvider/Code/Util.cs22
-rw-r--r--samples/OpenIdWebRingSsoProvider/Login.aspx.cs2
3 files changed, 55 insertions, 42 deletions
diff --git a/samples/DotNetOpenAuth.ApplicationBlock/TwitterConsumer.cs b/samples/DotNetOpenAuth.ApplicationBlock/TwitterConsumer.cs
index 120061b..0ebb1db 100644
--- a/samples/DotNetOpenAuth.ApplicationBlock/TwitterConsumer.cs
+++ b/samples/DotNetOpenAuth.ApplicationBlock/TwitterConsumer.cs
@@ -60,29 +60,38 @@ namespace DotNetOpenAuth.ApplicationBlock {
private static readonly MessageReceivingEndpoint VerifyCredentialsEndpoint = new MessageReceivingEndpoint("http://api.twitter.com/1/account/verify_credentials.xml", HttpDeliveryMethods.GetRequest | HttpDeliveryMethods.AuthorizationHeaderRequest);
- private static InMemoryTokenManager ShortTermUserSessionTokenManager {
- get {
- var store = HttpContext.Current.Session;
- var tokenManager = (InMemoryTokenManager)store["TwitterShortTermUserSessionTokenManager"];
- if (tokenManager == null) {
- string consumerKey = ConfigurationManager.AppSettings["twitterConsumerKey"];
- string consumerSecret = ConfigurationManager.AppSettings["twitterConsumerSecret"];
- if (IsTwitterConsumerConfigured) {
- tokenManager = new InMemoryTokenManager(consumerKey, consumerSecret);
- store["TwitterShortTermUserSessionTokenManager"] = tokenManager;
- } else {
- throw new InvalidOperationException("No Twitter OAuth consumer key and secret could be found in web.config AppSettings.");
- }
- }
-
- return tokenManager;
- }
- }
-
+ /// <summary>
+ /// The consumer used for the Sign in to Twitter feature.
+ /// </summary>
private static WebConsumer signInConsumer;
+ /// <summary>
+ /// The lock acquired to initialize the <see cref="signInConsumer"/> field.
+ /// </summary>
private static object signInConsumerInitLock = new object();
+ /// <summary>
+ /// Initializes static members of the <see cref="TwitterConsumer"/> class.
+ /// </summary>
+ static TwitterConsumer() {
+ // Twitter can't handle the Expect 100 Continue HTTP header.
+ ServicePointManager.FindServicePoint(GetFavoritesEndpoint.Location).Expect100Continue = false;
+ }
+
+ /// <summary>
+ /// Gets a value indicating whether the Twitter consumer key and secret are set in the web.config file.
+ /// </summary>
+ public static bool IsTwitterConsumerConfigured {
+ get {
+ return !string.IsNullOrEmpty(ConfigurationManager.AppSettings["twitterConsumerKey"]) &&
+ !string.IsNullOrEmpty(ConfigurationManager.AppSettings["twitterConsumerSecret"]);
+ }
+ }
+
+ /// <summary>
+ /// Gets the consumer to use for the Sign in to Twitter feature.
+ /// </summary>
+ /// <value>The twitter sign in.</value>
private static WebConsumer TwitterSignIn {
get {
if (signInConsumer == null) {
@@ -97,18 +106,22 @@ namespace DotNetOpenAuth.ApplicationBlock {
}
}
- /// <summary>
- /// Initializes static members of the <see cref="TwitterConsumer"/> class.
- /// </summary>
- static TwitterConsumer() {
- // Twitter can't handle the Expect 100 Continue HTTP header.
- ServicePointManager.FindServicePoint(GetFavoritesEndpoint.Location).Expect100Continue = false;
- }
-
- public static bool IsTwitterConsumerConfigured {
+ private static InMemoryTokenManager ShortTermUserSessionTokenManager {
get {
- return !string.IsNullOrEmpty(ConfigurationManager.AppSettings["twitterConsumerKey"]) &&
- !string.IsNullOrEmpty(ConfigurationManager.AppSettings["twitterConsumerSecret"]);
+ var store = HttpContext.Current.Session;
+ var tokenManager = (InMemoryTokenManager)store["TwitterShortTermUserSessionTokenManager"];
+ if (tokenManager == null) {
+ string consumerKey = ConfigurationManager.AppSettings["twitterConsumerKey"];
+ string consumerSecret = ConfigurationManager.AppSettings["twitterConsumerSecret"];
+ if (IsTwitterConsumerConfigured) {
+ tokenManager = new InMemoryTokenManager(consumerKey, consumerSecret);
+ store["TwitterShortTermUserSessionTokenManager"] = tokenManager;
+ } else {
+ throw new InvalidOperationException("No Twitter OAuth consumer key and secret could be found in web.config AppSettings.");
+ }
+ }
+
+ return tokenManager;
}
}
diff --git a/samples/OpenIdWebRingSsoProvider/Code/Util.cs b/samples/OpenIdWebRingSsoProvider/Code/Util.cs
index 8456d51..5a3a2fc 100644
--- a/samples/OpenIdWebRingSsoProvider/Code/Util.cs
+++ b/samples/OpenIdWebRingSsoProvider/Code/Util.cs
@@ -15,6 +15,17 @@ namespace OpenIdWebRingSsoProvider.Code {
public class Util {
private const string RolesAttribute = "http://samples.dotnetopenauth.net/sso/roles";
+ /// <summary>
+ /// Gets a value indicating whether the authentication system used by the OP requires
+ /// no user interaction (an HTTP header based authentication protocol).
+ /// </summary>
+ internal static bool ImplicitAuth {
+ get {
+ // This should return false if using FormsAuthentication.
+ return bool.Parse(ConfigurationManager.AppSettings["ImplicitAuth"]);
+ }
+ }
+
public static string ExtractUserName(Uri url) {
return url.Segments[url.Segments.Length - 1];
}
@@ -100,16 +111,5 @@ namespace OpenIdWebRingSsoProvider.Code {
}
}
}
-
- /// <summary>
- /// Gets a value indicating whether the authentication system used by the OP requires
- /// no user interaction (an HTTP header based authentication protocol).
- /// </summary>
- internal static bool ImplicitAuth {
- get {
- // This should return false if using FormsAuthentication.
- return bool.Parse(ConfigurationManager.AppSettings["ImplicitAuth"]);
- }
- }
}
} \ No newline at end of file
diff --git a/samples/OpenIdWebRingSsoProvider/Login.aspx.cs b/samples/OpenIdWebRingSsoProvider/Login.aspx.cs
index 0ef1d7f..584cff7 100644
--- a/samples/OpenIdWebRingSsoProvider/Login.aspx.cs
+++ b/samples/OpenIdWebRingSsoProvider/Login.aspx.cs
@@ -30,7 +30,7 @@
this.login1.FindControl("Password").Focus();
}
}
- cancelButton.Visible = ProviderEndpoint.PendingAuthenticationRequest != null;
+ this.cancelButton.Visible = ProviderEndpoint.PendingAuthenticationRequest != null;
}
}