summaryrefslogtreecommitdiffstats
path: root/samples/OAuthServiceProvider
diff options
context:
space:
mode:
authorAndrew Arnott <andrewarnott@gmail.com>2010-06-07 21:29:29 -0700
committerAndrew Arnott <andrewarnott@gmail.com>2010-06-07 21:29:29 -0700
commitb3a35b9ae0823dda35bb07b404c9c09fec09402a (patch)
treeb58aaf62cf23c1e2c06a0f1d5f13ab899fff6a04 /samples/OAuthServiceProvider
parent8ed398b9151c8fc140379756bd3bd546a46daf05 (diff)
downloadDotNetOpenAuth-b3a35b9ae0823dda35bb07b404c9c09fec09402a.zip
DotNetOpenAuth-b3a35b9ae0823dda35bb07b404c9c09fec09402a.tar.gz
DotNetOpenAuth-b3a35b9ae0823dda35bb07b404c9c09fec09402a.tar.bz2
Lots of StyleCop work, and one bug fix (can you find it? <g>)
Diffstat (limited to 'samples/OAuthServiceProvider')
-rw-r--r--samples/OAuthServiceProvider/Code/Global.cs4
-rw-r--r--samples/OAuthServiceProvider/Code/OAuth2AuthorizationServer.cs8
-rw-r--r--samples/OAuthServiceProvider/Code/OAuthAuthorizationManager.cs9
-rw-r--r--samples/OAuthServiceProvider/Members/Authorize.aspx.cs6
-rw-r--r--samples/OAuthServiceProvider/Members/Authorize2.aspx.cs2
-rw-r--r--samples/OAuthServiceProvider/OAuth2.ashx.cs23
6 files changed, 24 insertions, 28 deletions
diff --git a/samples/OAuthServiceProvider/Code/Global.cs b/samples/OAuthServiceProvider/Code/Global.cs
index a43cf57..fd7d475 100644
--- a/samples/OAuthServiceProvider/Code/Global.cs
+++ b/samples/OAuthServiceProvider/Code/Global.cs
@@ -22,6 +22,8 @@
/// </summary>
public static log4net.ILog Logger = log4net.LogManager.GetLogger("DotNetOpenAuth.OAuthServiceProvider");
+ public static WebServerAuthorizationServer AuthorizationServer = new WebServerAuthorizationServer(new OAuth2AuthorizationServer());
+
/// <summary>
/// Gets the transaction-protected database connection for the current request.
/// </summary>
@@ -58,8 +60,6 @@
set { HttpContext.Current.Session["authrequest"] = value; }
}
- public static WebServerAuthorizationServer AuthorizationServer = new WebServerAuthorizationServer(new OAuth2AuthorizationServer());
-
private static DataClassesDataContext dataContextSimple {
get {
if (HttpContext.Current != null) {
diff --git a/samples/OAuthServiceProvider/Code/OAuth2AuthorizationServer.cs b/samples/OAuthServiceProvider/Code/OAuth2AuthorizationServer.cs
index 75778f5..e281b07 100644
--- a/samples/OAuthServiceProvider/Code/OAuth2AuthorizationServer.cs
+++ b/samples/OAuthServiceProvider/Code/OAuth2AuthorizationServer.cs
@@ -11,9 +11,9 @@
using DotNetOpenAuth.OAuthWrap.ChannelElements;
internal class OAuth2AuthorizationServer : IAuthorizationServer {
- private static readonly byte[] secret;
+ internal static readonly RSAParameters AsymmetricKey;
- internal static readonly RSAParameters asymmetricKey;
+ private static readonly byte[] secret;
private readonly INonceStore nonceStore = new DatabaseNonceStore();
@@ -23,7 +23,7 @@
secret = new byte[16];
crypto.GetBytes(secret);
- asymmetricKey = new RSACryptoServiceProvider().ExportParameters(true);
+ AsymmetricKey = new RSACryptoServiceProvider().ExportParameters(true);
}
#region Implementation of IAuthorizationServer
@@ -37,7 +37,7 @@
}
public RSAParameters AccessTokenSigningPrivateKey {
- get { return asymmetricKey; }
+ get { return AsymmetricKey; }
}
public IConsumerDescription GetClient(string clientIdentifier) {
diff --git a/samples/OAuthServiceProvider/Code/OAuthAuthorizationManager.cs b/samples/OAuthServiceProvider/Code/OAuthAuthorizationManager.cs
index a48288a..92038bd 100644
--- a/samples/OAuthServiceProvider/Code/OAuthAuthorizationManager.cs
+++ b/samples/OAuthServiceProvider/Code/OAuthAuthorizationManager.cs
@@ -7,10 +7,9 @@
using System.ServiceModel;
using System.ServiceModel.Channels;
using System.ServiceModel.Security;
- using DotNetOpenAuth;
using DotNetOpenAuth.OAuth;
- using DotNetOpenAuth.OAuthWrap;
using DotNetOpenAuth.OAuth.ChannelElements;
+ using DotNetOpenAuth.OAuthWrap;
/// <summary>
/// A WCF extension to authenticate incoming messages using OAuth.
@@ -28,7 +27,7 @@
Uri requestUri = operationContext.RequestContext.RequestMessage.Properties["OriginalHttpRequestUri"] as Uri;
try {
- var principal = VerifyOAuth2(httpDetails, requestUri);
+ var principal = this.VerifyOAuth2(httpDetails, requestUri);
if (principal != null) {
var policy = new OAuthPrincipalAuthorizationPolicy(principal);
var policies = new List<IAuthorizationPolicy> {
@@ -77,8 +76,8 @@
// we use the same public/private key.
var resourceServer = new ResourceServer(
new StandardAccessTokenAnalyzer(
- OAuth2AuthorizationServer.asymmetricKey,
- OAuth2AuthorizationServer.asymmetricKey));
+ OAuth2AuthorizationServer.AsymmetricKey,
+ OAuth2AuthorizationServer.AsymmetricKey));
string username, scope;
var error = resourceServer.VerifyAccess(new DotNetOpenAuth.Messaging.HttpRequestInfo(httpDetails, requestUri), out username, out scope);
diff --git a/samples/OAuthServiceProvider/Members/Authorize.aspx.cs b/samples/OAuthServiceProvider/Members/Authorize.aspx.cs
index 74b44c5..faa2147 100644
--- a/samples/OAuthServiceProvider/Members/Authorize.aspx.cs
+++ b/samples/OAuthServiceProvider/Members/Authorize.aspx.cs
@@ -29,8 +29,8 @@
} else {
ITokenContainingMessage pendingToken = Global.PendingOAuthAuthorization;
var token = Global.DataContext.OAuthTokens.Single(t => t.Token == pendingToken.Token);
- desiredAccessLabel.Text = token.Scope;
- consumerLabel.Text = Global.TokenManager.GetConsumerForToken(token.Token).ConsumerKey;
+ this.desiredAccessLabel.Text = token.Scope;
+ this.consumerLabel.Text = Global.TokenManager.GetConsumerForToken(token.Token).ConsumerKey;
// Generate an unpredictable secret that goes to the user agent and must come back
// with authorization to guarantee the user interacted with this page rather than
@@ -52,7 +52,7 @@
this.AuthorizationSecret = null; // clear one time use secret
var pending = Global.PendingOAuthAuthorization;
Global.AuthorizePendingRequestToken();
- multiView.ActiveViewIndex = 1;
+ this.multiView.ActiveViewIndex = 1;
ServiceProvider sp = new ServiceProvider(Constants.SelfDescription, Global.TokenManager);
var response = sp.PrepareAuthorizationResponse(pending);
diff --git a/samples/OAuthServiceProvider/Members/Authorize2.aspx.cs b/samples/OAuthServiceProvider/Members/Authorize2.aspx.cs
index 9e33573..0c14bfd 100644
--- a/samples/OAuthServiceProvider/Members/Authorize2.aspx.cs
+++ b/samples/OAuthServiceProvider/Members/Authorize2.aspx.cs
@@ -2,10 +2,10 @@
using System;
using System.Collections.Generic;
using System.Linq;
+ using System.Security.Cryptography;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
- using System.Security.Cryptography;
using Code;
public partial class Authorize2 : System.Web.UI.Page {
diff --git a/samples/OAuthServiceProvider/OAuth2.ashx.cs b/samples/OAuthServiceProvider/OAuth2.ashx.cs
index cd76254..272502c 100644
--- a/samples/OAuthServiceProvider/OAuth2.ashx.cs
+++ b/samples/OAuthServiceProvider/OAuth2.ashx.cs
@@ -9,11 +9,18 @@
using DotNetOpenAuth.Messaging;
using DotNetOpenAuth.OAuthWrap;
- /// <summary>
- /// Summary description for OAuth2
- /// </summary>
public class OAuth2 : IHttpHandler, IRequiresSessionState {
/// <summary>
+ /// Gets a value indicating whether another request can use the <see cref="T:System.Web.IHttpHandler"/> instance.
+ /// </summary>
+ /// <value>Always <c>true</c></value>
+ /// <returns>true if the <see cref="T:System.Web.IHttpHandler"/> instance is reusable; otherwise, false.
+ /// </returns>
+ public bool IsReusable {
+ get { return true; }
+ }
+
+ /// <summary>
/// Enables processing of HTTP Web requests by a custom HttpHandler that implements the <see cref="T:System.Web.IHttpHandler"/> interface.
/// </summary>
/// <param name="context">An <see cref="T:System.Web.HttpContext"/> object that provides references to the intrinsic server objects (for example, Request, Response, Session, and Server) used to service HTTP requests.</param>
@@ -42,15 +49,5 @@
break;
}
}
-
- /// <summary>
- /// Gets a value indicating whether another request can use the <see cref="T:System.Web.IHttpHandler"/> instance.
- /// </summary>
- /// <value>Always <c>true</c></value>
- /// <returns>true if the <see cref="T:System.Web.IHttpHandler"/> instance is reusable; otherwise, false.
- /// </returns>
- public bool IsReusable {
- get { return true; }
- }
}
} \ No newline at end of file