diff options
Diffstat (limited to 'samples')
-rw-r--r-- | samples/OAuthConsumer/SampleWcf2.aspx.cs | 22 | ||||
-rw-r--r-- | samples/OAuthConsumerWpf/Authorize2.xaml.cs | 14 | ||||
-rw-r--r-- | samples/OAuthServiceProvider/Members/Authorize.aspx.cs | 18 |
3 files changed, 27 insertions, 27 deletions
diff --git a/samples/OAuthConsumer/SampleWcf2.aspx.cs b/samples/OAuthConsumer/SampleWcf2.aspx.cs index 7978f91..9ff8c25 100644 --- a/samples/OAuthConsumer/SampleWcf2.aspx.cs +++ b/samples/OAuthConsumer/SampleWcf2.aspx.cs @@ -16,12 +16,9 @@ public partial class SampleWcf2 : System.Web.UI.Page { /// <summary> - /// The details about the sample OAuth-enabled WCF service that this sample client calls into. + /// The OAuth 2.0 client object to use to obtain authorization and authorize outgoing HTTP requests. /// </summary> - private static AuthorizationServerDescription AuthServerDescription = new AuthorizationServerDescription { - TokenEndpoint = new Uri("http://localhost:65169/OAuth.ashx"), - AuthorizationEndpoint = new Uri("http://localhost:65169/Members/Authorize.aspx"), - }; + private static readonly WebServerClient Client; /// <summary> /// Gets or sets the authorization details for the logged in user. @@ -37,17 +34,20 @@ } /// <summary> - /// The OAuth 2.0 client object to use to obtain authorization and authorize outgoing HTTP requests. - /// </summary> - private static readonly WebServerClient Client; - - /// <summary> - /// Initializes the <see cref="SampleWcf2"/> class. + /// Initializes static members of the <see cref="SampleWcf2"/> class. /// </summary> static SampleWcf2() { Client = new WebServerClient(AuthServerDescription, "sampleconsumer", "samplesecret"); } + /// <summary> + /// The details about the sample OAuth-enabled WCF service that this sample client calls into. + /// </summary> + private static AuthorizationServerDescription AuthServerDescription = new AuthorizationServerDescription { + TokenEndpoint = new Uri("http://localhost:65169/OAuth.ashx"), + AuthorizationEndpoint = new Uri("http://localhost:65169/Members/Authorize.aspx"), + }; + protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { // Check to see if we're receiving a end user authorization response. diff --git a/samples/OAuthConsumerWpf/Authorize2.xaml.cs b/samples/OAuthConsumerWpf/Authorize2.xaml.cs index 86d8d9e..d303145 100644 --- a/samples/OAuthConsumerWpf/Authorize2.xaml.cs +++ b/samples/OAuthConsumerWpf/Authorize2.xaml.cs @@ -13,8 +13,8 @@ using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes; - using DotNetOpenAuth.OAuth2; using DotNetOpenAuth.Messaging; + using DotNetOpenAuth.OAuth2; /// <summary> /// Interaction logic for Authorize2.xaml @@ -36,6 +36,12 @@ public IAuthorizationState Authorization { get; set; } + private static bool SignificantlyEqual(Uri location1, Uri location2, UriComponents components) { + string value1 = location1.GetComponents(components, UriFormat.Unescaped); + string value2 = location2.GetComponents(components, UriFormat.Unescaped); + return string.Equals(value1, value2, StringComparison.Ordinal); + } + private void webBrowser_Navigating(object sender, System.Windows.Forms.WebBrowserNavigatingEventArgs e) { this.locationChanged(e.Url); } @@ -66,11 +72,5 @@ private void webBrowser_LocationChanged(object sender, EventArgs e) { this.locationChanged(webBrowser.Url); } - - private static bool SignificantlyEqual(Uri location1, Uri location2, UriComponents components) { - string value1 = location1.GetComponents(components, UriFormat.Unescaped); - string value2 = location2.GetComponents(components, UriFormat.Unescaped); - return string.Equals(value1, value2, StringComparison.Ordinal); - } } }
\ No newline at end of file diff --git a/samples/OAuthServiceProvider/Members/Authorize.aspx.cs b/samples/OAuthServiceProvider/Members/Authorize.aspx.cs index 1a4c78e..3fdcdbd 100644 --- a/samples/OAuthServiceProvider/Members/Authorize.aspx.cs +++ b/samples/OAuthServiceProvider/Members/Authorize.aspx.cs @@ -27,20 +27,20 @@ protected void Page_Load(object sender, EventArgs e) { var getRequest = new HttpRequestInfo("GET", this.Request.Url, this.Request.RawUrl, new WebHeaderCollection(), null); - pendingRequest = Global.AuthorizationServer.ReadAuthorizationRequest(getRequest); - if (pendingRequest == null) { + this.pendingRequest = Global.AuthorizationServer.ReadAuthorizationRequest(getRequest); + if (this.pendingRequest == null) { throw new HttpException((int)HttpStatusCode.BadRequest, "Missing authorization request."); } - client = Global.DataContext.Clients.First(c => c.ClientIdentifier == pendingRequest.ClientIdentifier); + client = Global.DataContext.Clients.First(c => c.ClientIdentifier == this.pendingRequest.ClientIdentifier); var authServer = new OAuth2AuthorizationServer(); - if (authServer.CanBeAutoApproved(pendingRequest)) { - Global.AuthorizationServer.ApproveAuthorizationRequest(pendingRequest, User.Identity.Name); + if (authServer.CanBeAutoApproved(this.pendingRequest)) { + Global.AuthorizationServer.ApproveAuthorizationRequest(this.pendingRequest, User.Identity.Name); } if (!IsPostBack) { - this.desiredAccessLabel.Text = OAuthUtilities.JoinScopes(pendingRequest.Scope); + this.desiredAccessLabel.Text = OAuthUtilities.JoinScopes(this.pendingRequest.Scope); this.consumerLabel.Text = client.Name; // Generate an unpredictable secret that goes to the user agent and must come back @@ -62,15 +62,15 @@ client.ClientAuthorizations.Add( new ClientAuthorization { - Scope = OAuthUtilities.JoinScopes(pendingRequest.Scope), + Scope = OAuthUtilities.JoinScopes(this.pendingRequest.Scope), User = Global.LoggedInUser, CreatedOnUtc = DateTime.UtcNow, }); - Global.AuthorizationServer.ApproveAuthorizationRequest(pendingRequest, User.Identity.Name); + Global.AuthorizationServer.ApproveAuthorizationRequest(this.pendingRequest, User.Identity.Name); } protected void denyAccessButton_Click(object sender, EventArgs e) { - Global.AuthorizationServer.RejectAuthorizationRequest(pendingRequest); + Global.AuthorizationServer.RejectAuthorizationRequest(this.pendingRequest); } } }
\ No newline at end of file |