diff options
57 files changed, 2462 insertions, 3445 deletions
diff --git a/samples/OAuthConsumer/Code/Logging.cs b/samples/OAuthConsumer/Code/Logging.cs index 185c9a9..510ea85 100644 --- a/samples/OAuthConsumer/Code/Logging.cs +++ b/samples/OAuthConsumer/Code/Logging.cs @@ -1,20 +1,22 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Web; +namespace OAuthConsumer { + using System; + using System.Collections.Generic; + using System.Linq; + using System.Text; + using System.Web; -/// <summary> -/// Logging tools for this sample. -/// </summary> -public static class Logging { /// <summary> - /// An application memory cache of recent log messages. + /// Logging tools for this sample. /// </summary> - public static StringBuilder LogMessages = new StringBuilder(); + public static class Logging { + /// <summary> + /// An application memory cache of recent log messages. + /// </summary> + public static StringBuilder LogMessages = new StringBuilder(); - /// <summary> - /// The logger for this sample to use. - /// </summary> - public static log4net.ILog Logger = log4net.LogManager.GetLogger("DotNetOpenAuth.ConsumerSample"); + /// <summary> + /// The logger for this sample to use. + /// </summary> + public static log4net.ILog Logger = log4net.LogManager.GetLogger("DotNetOpenAuth.OAuthConsumer"); + } }
\ No newline at end of file diff --git a/samples/OAuthConsumer/Code/TracePageAppender.cs b/samples/OAuthConsumer/Code/TracePageAppender.cs index 93ec9e3..5d3ba36 100644 --- a/samples/OAuthConsumer/Code/TracePageAppender.cs +++ b/samples/OAuthConsumer/Code/TracePageAppender.cs @@ -1,11 +1,13 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Web; +namespace OAuthConsumer { + using System; + using System.Collections.Generic; + using System.IO; + using System.Web; -public class TracePageAppender : log4net.Appender.AppenderSkeleton { - protected override void Append(log4net.Core.LoggingEvent loggingEvent) { - StringWriter sw = new StringWriter(Logging.LogMessages); - Layout.Format(sw, loggingEvent); + public class TracePageAppender : log4net.Appender.AppenderSkeleton { + protected override void Append(log4net.Core.LoggingEvent loggingEvent) { + StringWriter sw = new StringWriter(Logging.LogMessages); + Layout.Format(sw, loggingEvent); + } } -} +}
\ No newline at end of file diff --git a/samples/OAuthConsumer/Global.asax b/samples/OAuthConsumer/Global.asax index fa4ca9b..06ffcd8 100644 --- a/samples/OAuthConsumer/Global.asax +++ b/samples/OAuthConsumer/Global.asax @@ -1,31 +1 @@ -<%@ Application Language="C#" %> - -<script RunAt="server"> - void Application_Start(object sender, EventArgs e) { - log4net.Config.XmlConfigurator.Configure(); - Logging.Logger.Info("Sample starting..."); - } - - void Application_End(object sender, EventArgs e) { - Logging.Logger.Info("Sample shutting down..."); - // this would be automatic, but in partial trust scenarios it is not. - log4net.LogManager.Shutdown(); - } - - void Application_Error(object sender, EventArgs e) { - Logging.Logger.ErrorFormat("An unhandled exception was raised. Details follow: {0}", HttpContext.Current.Server.GetLastError()); - } - - void Session_Start(object sender, EventArgs e) { - // Code that runs when a new session is started - - } - - void Session_End(object sender, EventArgs e) { - // Code that runs when a session ends. - // Note: The Session_End event is raised only when the sessionstate mode - // is set to InProc in the Web.config file. If session mode is set to StateServer - // or SQLServer, the event is not raised. - - } -</script> +<%@ Application Language="C#" Inherits="OAuthConsumer.Global" CodeBehind="Global.asax.cs" %> diff --git a/samples/OAuthConsumer/Global.asax.cs b/samples/OAuthConsumer/Global.asax.cs new file mode 100644 index 0000000..b2f5b5a --- /dev/null +++ b/samples/OAuthConsumer/Global.asax.cs @@ -0,0 +1,36 @@ +namespace OAuthConsumer { + using System; + using System.Collections.Generic; + using System.Linq; + using System.Web; + + public partial class Global : HttpApplication { + protected void Application_Start(object sender, EventArgs e) { + log4net.Config.XmlConfigurator.Configure(); + Logging.Logger.Info("Sample starting..."); + } + + protected void Application_End(object sender, EventArgs e) { + Logging.Logger.Info("Sample shutting down..."); + // this would be automatic, but in partial trust scenarios it is not. + log4net.LogManager.Shutdown(); + } + + protected void Application_Error(object sender, EventArgs e) { + Logging.Logger.ErrorFormat("An unhandled exception was raised. Details follow: {0}", HttpContext.Current.Server.GetLastError()); + } + + protected void Session_Start(object sender, EventArgs e) { + // Code that runs when a new session is started + + } + + protected void Session_End(object sender, EventArgs e) { + // Code that runs when a session ends. + // Note: The Session_End event is raised only when the sessionstate mode + // is set to InProc in the Web.config file. If session mode is set to StateServer + // or SQLServer, the event is not raised. + + } + } +}
\ No newline at end of file diff --git a/samples/OAuthConsumer/GoogleAddressBook.aspx b/samples/OAuthConsumer/GoogleAddressBook.aspx index bd4bd81..1be21aa 100644 --- a/samples/OAuthConsumer/GoogleAddressBook.aspx +++ b/samples/OAuthConsumer/GoogleAddressBook.aspx @@ -1,5 +1,5 @@ <%@ Page Title="Gmail address book demo" Language="C#" MasterPageFile="~/MasterPage.master" - AutoEventWireup="true" Inherits="GoogleAddressBook" Codebehind="GoogleAddressBook.aspx.cs" %> + AutoEventWireup="true" Inherits="OAuthConsumer.GoogleAddressBook" Codebehind="GoogleAddressBook.aspx.cs" %> <asp:Content ID="Content2" ContentPlaceHolderID="Body" runat="Server"> <asp:MultiView ID="MultiView1" runat="server" ActiveViewIndex="0"> diff --git a/samples/OAuthConsumer/GoogleAddressBook.aspx.cs b/samples/OAuthConsumer/GoogleAddressBook.aspx.cs index 463d7e3..825dd1a 100644 --- a/samples/OAuthConsumer/GoogleAddressBook.aspx.cs +++ b/samples/OAuthConsumer/GoogleAddressBook.aspx.cs @@ -1,73 +1,75 @@ -using System; -using System.Configuration; -using System.Linq; -using System.Text; -using System.Web; -using System.Web.UI; -using System.Web.UI.WebControls; -using System.Xml.Linq; -using DotNetOpenAuth.ApplicationBlock; -using DotNetOpenAuth.OAuth; +namespace OAuthConsumer { + using System; + using System.Configuration; + using System.Linq; + using System.Text; + using System.Web; + using System.Web.UI; + using System.Web.UI.WebControls; + using System.Xml.Linq; + using DotNetOpenAuth.ApplicationBlock; + using DotNetOpenAuth.OAuth; -/// <summary> -/// A page to demonstrate downloading a Gmail address book using OAuth. -/// </summary> -public partial class GoogleAddressBook : System.Web.UI.Page { - private string AccessToken { - get { return (string)Session["GoogleAccessToken"]; } - set { Session["GoogleAccessToken"] = value; } - } + /// <summary> + /// A page to demonstrate downloading a Gmail address book using OAuth. + /// </summary> + public partial class GoogleAddressBook : System.Web.UI.Page { + private string AccessToken { + get { return (string)Session["GoogleAccessToken"]; } + set { Session["GoogleAccessToken"] = value; } + } - private InMemoryTokenManager TokenManager { - get { - var tokenManager = (InMemoryTokenManager)Application["GoogleTokenManager"]; - if (tokenManager == null) { - string consumerKey = ConfigurationManager.AppSettings["googleConsumerKey"]; - string consumerSecret = ConfigurationManager.AppSettings["googleConsumerSecret"]; - if (!string.IsNullOrEmpty(consumerKey)) { - tokenManager = new InMemoryTokenManager(consumerKey, consumerSecret); - Application["GoogleTokenManager"] = tokenManager; + private InMemoryTokenManager TokenManager { + get { + var tokenManager = (InMemoryTokenManager)Application["GoogleTokenManager"]; + if (tokenManager == null) { + string consumerKey = ConfigurationManager.AppSettings["googleConsumerKey"]; + string consumerSecret = ConfigurationManager.AppSettings["googleConsumerSecret"]; + if (!string.IsNullOrEmpty(consumerKey)) { + tokenManager = new InMemoryTokenManager(consumerKey, consumerSecret); + Application["GoogleTokenManager"] = tokenManager; + } } - } - return tokenManager; + return tokenManager; + } } - } - protected void Page_Load(object sender, EventArgs e) { - if (this.TokenManager != null) { - MultiView1.ActiveViewIndex = 1; + protected void Page_Load(object sender, EventArgs e) { + if (this.TokenManager != null) { + MultiView1.ActiveViewIndex = 1; - if (!IsPostBack) { - var google = new WebConsumer(GoogleConsumer.ServiceDescription, this.TokenManager); + if (!IsPostBack) { + var google = new WebConsumer(GoogleConsumer.ServiceDescription, this.TokenManager); - // Is Google calling back with authorization? - var accessTokenResponse = google.ProcessUserAuthorization(); - if (accessTokenResponse != null) { - this.AccessToken = accessTokenResponse.AccessToken; - } else if (this.AccessToken == null) { - // If we don't yet have access, immediately request it. - GoogleConsumer.RequestAuthorization(google, GoogleConsumer.Applications.Contacts); + // Is Google calling back with authorization? + var accessTokenResponse = google.ProcessUserAuthorization(); + if (accessTokenResponse != null) { + this.AccessToken = accessTokenResponse.AccessToken; + } else if (this.AccessToken == null) { + // If we don't yet have access, immediately request it. + GoogleConsumer.RequestAuthorization(google, GoogleConsumer.Applications.Contacts); + } } } } - } - protected void getAddressBookButton_Click(object sender, EventArgs e) { - var google = new WebConsumer(GoogleConsumer.ServiceDescription, this.TokenManager); + protected void getAddressBookButton_Click(object sender, EventArgs e) { + var google = new WebConsumer(GoogleConsumer.ServiceDescription, this.TokenManager); - XDocument contactsDocument = GoogleConsumer.GetContacts(google, this.AccessToken); - var contacts = from entry in contactsDocument.Root.Elements(XName.Get("entry", "http://www.w3.org/2005/Atom")) - select new { Name = entry.Element(XName.Get("title", "http://www.w3.org/2005/Atom")).Value, Email = entry.Element(XName.Get("email", "http://schemas.google.com/g/2005")).Attribute("address").Value }; - StringBuilder tableBuilder = new StringBuilder(); - tableBuilder.Append("<table><tr><td>Name</td><td>Email</td></tr>"); - foreach (var contact in contacts) { - tableBuilder.AppendFormat( - "<tr><td>{0}</td><td>{1}</td></tr>", - HttpUtility.HtmlEncode(contact.Name), - HttpUtility.HtmlEncode(contact.Email)); + XDocument contactsDocument = GoogleConsumer.GetContacts(google, this.AccessToken); + var contacts = from entry in contactsDocument.Root.Elements(XName.Get("entry", "http://www.w3.org/2005/Atom")) + select new { Name = entry.Element(XName.Get("title", "http://www.w3.org/2005/Atom")).Value, Email = entry.Element(XName.Get("email", "http://schemas.google.com/g/2005")).Attribute("address").Value }; + StringBuilder tableBuilder = new StringBuilder(); + tableBuilder.Append("<table><tr><td>Name</td><td>Email</td></tr>"); + foreach (var contact in contacts) { + tableBuilder.AppendFormat( + "<tr><td>{0}</td><td>{1}</td></tr>", + HttpUtility.HtmlEncode(contact.Name), + HttpUtility.HtmlEncode(contact.Email)); + } + tableBuilder.Append("</table>"); + resultsPlaceholder.Controls.Add(new Literal { Text = tableBuilder.ToString() }); } - tableBuilder.Append("</table>"); - resultsPlaceholder.Controls.Add(new Literal { Text = tableBuilder.ToString() }); } -} +}
\ No newline at end of file diff --git a/samples/OAuthConsumer/GoogleAddressBook.aspx.designer.cs b/samples/OAuthConsumer/GoogleAddressBook.aspx.designer.cs index 053bf3a..64558d5 100644 --- a/samples/OAuthConsumer/GoogleAddressBook.aspx.designer.cs +++ b/samples/OAuthConsumer/GoogleAddressBook.aspx.designer.cs @@ -7,34 +7,36 @@ // </auto-generated> //------------------------------------------------------------------------------ - - -public partial class GoogleAddressBook { - - /// <summary> - /// MultiView1 control. - /// </summary> - /// <remarks> - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// </remarks> - protected global::System.Web.UI.WebControls.MultiView MultiView1; +namespace OAuthConsumer { - /// <summary> - /// getAddressBookButton control. - /// </summary> - /// <remarks> - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// </remarks> - protected global::System.Web.UI.WebControls.Button getAddressBookButton; - /// <summary> - /// resultsPlaceholder control. - /// </summary> - /// <remarks> - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// </remarks> - protected global::System.Web.UI.WebControls.PlaceHolder resultsPlaceholder; + public partial class GoogleAddressBook { + + /// <summary> + /// MultiView1 control. + /// </summary> + /// <remarks> + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// </remarks> + protected global::System.Web.UI.WebControls.MultiView MultiView1; + + /// <summary> + /// getAddressBookButton control. + /// </summary> + /// <remarks> + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// </remarks> + protected global::System.Web.UI.WebControls.Button getAddressBookButton; + + /// <summary> + /// resultsPlaceholder control. + /// </summary> + /// <remarks> + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// </remarks> + protected global::System.Web.UI.WebControls.PlaceHolder resultsPlaceholder; + } } diff --git a/samples/OAuthConsumer/OAuthConsumer.csproj b/samples/OAuthConsumer/OAuthConsumer.csproj index 8063e15..f725ba7 100644 --- a/samples/OAuthConsumer/OAuthConsumer.csproj +++ b/samples/OAuthConsumer/OAuthConsumer.csproj @@ -78,6 +78,9 @@ </None> </ItemGroup> <ItemGroup> + <Compile Include="Global.asax.cs"> + <DependentUpon>Global.asax</DependentUpon> + </Compile> <Compile Include="GoogleAddressBook.aspx.designer.cs"> <DependentUpon>GoogleAddressBook.aspx</DependentUpon> </Compile> diff --git a/samples/OAuthConsumer/SampleWcf.aspx b/samples/OAuthConsumer/SampleWcf.aspx index 84df01b..fb318ce 100644 --- a/samples/OAuthConsumer/SampleWcf.aspx +++ b/samples/OAuthConsumer/SampleWcf.aspx @@ -1,4 +1,4 @@ -<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" Inherits="SampleWcf" Codebehind="SampleWcf.aspx.cs" %> +<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" Inherits="OAuthConsumer.SampleWcf" Codebehind="SampleWcf.aspx.cs" %> <asp:Content ID="Content2" ContentPlaceHolderID="Body" runat="Server"> <fieldset title="Authorization"> diff --git a/samples/OAuthConsumer/SampleWcf.aspx.cs b/samples/OAuthConsumer/SampleWcf.aspx.cs index 25e8f55..4055c6c 100644 --- a/samples/OAuthConsumer/SampleWcf.aspx.cs +++ b/samples/OAuthConsumer/SampleWcf.aspx.cs @@ -1,117 +1,119 @@ -using System; -using System.Collections.Generic; -using System.Globalization; -using System.Linq; -using System.Net; -using System.ServiceModel; -using System.ServiceModel.Channels; -using System.ServiceModel.Security; -using System.Web.UI.WebControls; -using DotNetOpenAuth; -using DotNetOpenAuth.ApplicationBlock; -using DotNetOpenAuth.Messaging; -using DotNetOpenAuth.OAuth; -using DotNetOpenAuth.OAuth.ChannelElements; -using OAuthConsumer.SampleServiceProvider; +namespace OAuthConsumer { + using System; + using System.Collections.Generic; + using System.Globalization; + using System.Linq; + using System.Net; + using System.ServiceModel; + using System.ServiceModel.Channels; + using System.ServiceModel.Security; + using System.Web.UI.WebControls; + using DotNetOpenAuth; + using DotNetOpenAuth.ApplicationBlock; + using DotNetOpenAuth.Messaging; + using DotNetOpenAuth.OAuth; + using DotNetOpenAuth.OAuth.ChannelElements; + using OAuthConsumer.SampleServiceProvider; -/// <summary> -/// Sample consumer of our Service Provider sample's WCF service. -/// </summary> -public partial class SampleWcf : System.Web.UI.Page { - protected void Page_Load(object sender, EventArgs e) { - if (!IsPostBack) { - if (Session["WcfTokenManager"] != null) { - WebConsumer consumer = this.CreateConsumer(); - var accessTokenMessage = consumer.ProcessUserAuthorization(); - if (accessTokenMessage != null) { - Session["WcfAccessToken"] = accessTokenMessage.AccessToken; - authorizationLabel.Text = "Authorized! Access token: " + accessTokenMessage.AccessToken; + /// <summary> + /// Sample consumer of our Service Provider sample's WCF service. + /// </summary> + public partial class SampleWcf : System.Web.UI.Page { + protected void Page_Load(object sender, EventArgs e) { + if (!IsPostBack) { + if (Session["WcfTokenManager"] != null) { + WebConsumer consumer = this.CreateConsumer(); + var accessTokenMessage = consumer.ProcessUserAuthorization(); + if (accessTokenMessage != null) { + Session["WcfAccessToken"] = accessTokenMessage.AccessToken; + authorizationLabel.Text = "Authorized! Access token: " + accessTokenMessage.AccessToken; + } } } } - } - protected void getAuthorizationButton_Click(object sender, EventArgs e) { - WebConsumer consumer = this.CreateConsumer(); - UriBuilder callback = new UriBuilder(Request.Url); - callback.Query = null; - string[] scopes = (from item in scopeList.Items.OfType<ListItem>() - where item.Selected - select item.Value).ToArray(); - string scope = string.Join("|", scopes); - var requestParams = new Dictionary<string, string> { + protected void getAuthorizationButton_Click(object sender, EventArgs e) { + WebConsumer consumer = this.CreateConsumer(); + UriBuilder callback = new UriBuilder(Request.Url); + callback.Query = null; + string[] scopes = (from item in scopeList.Items.OfType<ListItem>() + where item.Selected + select item.Value).ToArray(); + string scope = string.Join("|", scopes); + var requestParams = new Dictionary<string, string> { { "scope", scope }, }; - var response = consumer.PrepareRequestUserAuthorization(callback.Uri, requestParams, null); - consumer.Channel.Send(response); - } - - protected void getNameButton_Click(object sender, EventArgs e) { - try { - nameLabel.Text = CallService(client => client.GetName()); - } catch (SecurityAccessDeniedException) { - nameLabel.Text = "Access denied!"; + var response = consumer.PrepareRequestUserAuthorization(callback.Uri, requestParams, null); + consumer.Channel.Send(response); } - } - protected void getAgeButton_Click(object sender, EventArgs e) { - try { - int? age = CallService(client => client.GetAge()); - ageLabel.Text = age.HasValue ? age.Value.ToString(CultureInfo.CurrentCulture) : "not available"; - } catch (SecurityAccessDeniedException) { - ageLabel.Text = "Access denied!"; + protected void getNameButton_Click(object sender, EventArgs e) { + try { + nameLabel.Text = CallService(client => client.GetName()); + } catch (SecurityAccessDeniedException) { + nameLabel.Text = "Access denied!"; + } } - } - protected void getFavoriteSites_Click(object sender, EventArgs e) { - try { - string[] favoriteSites = CallService(client => client.GetFavoriteSites()); - favoriteSitesLabel.Text = string.Join(", ", favoriteSites); - } catch (SecurityAccessDeniedException) { - favoriteSitesLabel.Text = "Access denied!"; + protected void getAgeButton_Click(object sender, EventArgs e) { + try { + int? age = CallService(client => client.GetAge()); + ageLabel.Text = age.HasValue ? age.Value.ToString(CultureInfo.CurrentCulture) : "not available"; + } catch (SecurityAccessDeniedException) { + ageLabel.Text = "Access denied!"; + } } - } - private T CallService<T>(Func<DataApiClient, T> predicate) { - DataApiClient client = new DataApiClient(); - var serviceEndpoint = new MessageReceivingEndpoint(client.Endpoint.Address.Uri, HttpDeliveryMethods.AuthorizationHeaderRequest | HttpDeliveryMethods.PostRequest); - var accessToken = Session["WcfAccessToken"] as string; - if (accessToken == null) { - throw new InvalidOperationException("No access token!"); + protected void getFavoriteSites_Click(object sender, EventArgs e) { + try { + string[] favoriteSites = CallService(client => client.GetFavoriteSites()); + favoriteSitesLabel.Text = string.Join(", ", favoriteSites); + } catch (SecurityAccessDeniedException) { + favoriteSitesLabel.Text = "Access denied!"; + } } - WebConsumer consumer = this.CreateConsumer(); - WebRequest httpRequest = consumer.PrepareAuthorizedRequest(serviceEndpoint, accessToken); - HttpRequestMessageProperty httpDetails = new HttpRequestMessageProperty(); - httpDetails.Headers[HttpRequestHeader.Authorization] = httpRequest.Headers[HttpRequestHeader.Authorization]; - using (OperationContextScope scope = new OperationContextScope(client.InnerChannel)) { - OperationContext.Current.OutgoingMessageProperties[HttpRequestMessageProperty.Name] = httpDetails; - return predicate(client); - } - } + private T CallService<T>(Func<DataApiClient, T> predicate) { + DataApiClient client = new DataApiClient(); + var serviceEndpoint = new MessageReceivingEndpoint(client.Endpoint.Address.Uri, HttpDeliveryMethods.AuthorizationHeaderRequest | HttpDeliveryMethods.PostRequest); + var accessToken = Session["WcfAccessToken"] as string; + if (accessToken == null) { + throw new InvalidOperationException("No access token!"); + } + WebConsumer consumer = this.CreateConsumer(); + WebRequest httpRequest = consumer.PrepareAuthorizedRequest(serviceEndpoint, accessToken); - private WebConsumer CreateConsumer() { - string consumerKey = "sampleconsumer"; - string consumerSecret = "samplesecret"; - var tokenManager = Session["WcfTokenManager"] as InMemoryTokenManager; - if (tokenManager == null) { - tokenManager = new InMemoryTokenManager(consumerKey, consumerSecret); - Session["WcfTokenManager"] = tokenManager; + HttpRequestMessageProperty httpDetails = new HttpRequestMessageProperty(); + httpDetails.Headers[HttpRequestHeader.Authorization] = httpRequest.Headers[HttpRequestHeader.Authorization]; + using (OperationContextScope scope = new OperationContextScope(client.InnerChannel)) { + OperationContext.Current.OutgoingMessageProperties[HttpRequestMessageProperty.Name] = httpDetails; + return predicate(client); + } } - MessageReceivingEndpoint oauthEndpoint = new MessageReceivingEndpoint( - new Uri("http://localhost:65169/OAuth.ashx"), - HttpDeliveryMethods.PostRequest); - WebConsumer consumer = new WebConsumer( - new ServiceProviderDescription { - RequestTokenEndpoint = oauthEndpoint, - UserAuthorizationEndpoint = oauthEndpoint, - AccessTokenEndpoint = oauthEndpoint, - TamperProtectionElements = new DotNetOpenAuth.Messaging.ITamperProtectionChannelBindingElement[] { + + private WebConsumer CreateConsumer() { + string consumerKey = "sampleconsumer"; + string consumerSecret = "samplesecret"; + var tokenManager = Session["WcfTokenManager"] as InMemoryTokenManager; + if (tokenManager == null) { + tokenManager = new InMemoryTokenManager(consumerKey, consumerSecret); + Session["WcfTokenManager"] = tokenManager; + } + MessageReceivingEndpoint oauthEndpoint = new MessageReceivingEndpoint( + new Uri("http://localhost:65169/OAuth.ashx"), + HttpDeliveryMethods.PostRequest); + WebConsumer consumer = new WebConsumer( + new ServiceProviderDescription { + RequestTokenEndpoint = oauthEndpoint, + UserAuthorizationEndpoint = oauthEndpoint, + AccessTokenEndpoint = oauthEndpoint, + TamperProtectionElements = new DotNetOpenAuth.Messaging.ITamperProtectionChannelBindingElement[] { new HmacSha1SigningBindingElement(), }, - }, - tokenManager); + }, + tokenManager); - return consumer; + return consumer; + } } -} +}
\ No newline at end of file diff --git a/samples/OAuthConsumer/SampleWcf.aspx.designer.cs b/samples/OAuthConsumer/SampleWcf.aspx.designer.cs index 79cdbfe..c041338 100644 --- a/samples/OAuthConsumer/SampleWcf.aspx.designer.cs +++ b/samples/OAuthConsumer/SampleWcf.aspx.designer.cs @@ -7,88 +7,90 @@ // </auto-generated> //------------------------------------------------------------------------------ - - -public partial class SampleWcf { - - /// <summary> - /// scopeList control. - /// </summary> - /// <remarks> - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// </remarks> - protected global::System.Web.UI.WebControls.CheckBoxList scopeList; - - /// <summary> - /// getAuthorizationButton control. - /// </summary> - /// <remarks> - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// </remarks> - protected global::System.Web.UI.WebControls.Button getAuthorizationButton; - - /// <summary> - /// authorizationLabel control. - /// </summary> - /// <remarks> - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// </remarks> - protected global::System.Web.UI.WebControls.Label authorizationLabel; - - /// <summary> - /// getNameButton control. - /// </summary> - /// <remarks> - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// </remarks> - protected global::System.Web.UI.WebControls.Button getNameButton; - - /// <summary> - /// nameLabel control. - /// </summary> - /// <remarks> - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// </remarks> - protected global::System.Web.UI.WebControls.Label nameLabel; - - /// <summary> - /// getAgeButton control. - /// </summary> - /// <remarks> - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// </remarks> - protected global::System.Web.UI.WebControls.Button getAgeButton; - - /// <summary> - /// ageLabel control. - /// </summary> - /// <remarks> - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// </remarks> - protected global::System.Web.UI.WebControls.Label ageLabel; +namespace OAuthConsumer { - /// <summary> - /// getFavoriteSites control. - /// </summary> - /// <remarks> - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// </remarks> - protected global::System.Web.UI.WebControls.Button getFavoriteSites; - /// <summary> - /// favoriteSitesLabel control. - /// </summary> - /// <remarks> - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// </remarks> - protected global::System.Web.UI.WebControls.Label favoriteSitesLabel; + public partial class SampleWcf { + + /// <summary> + /// scopeList control. + /// </summary> + /// <remarks> + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// </remarks> + protected global::System.Web.UI.WebControls.CheckBoxList scopeList; + + /// <summary> + /// getAuthorizationButton control. + /// </summary> + /// <remarks> + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// </remarks> + protected global::System.Web.UI.WebControls.Button getAuthorizationButton; + + /// <summary> + /// authorizationLabel control. + /// </summary> + /// <remarks> + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// </remarks> + protected global::System.Web.UI.WebControls.Label authorizationLabel; + + /// <summary> + /// getNameButton control. + /// </summary> + /// <remarks> + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// </remarks> + protected global::System.Web.UI.WebControls.Button getNameButton; + + /// <summary> + /// nameLabel control. + /// </summary> + /// <remarks> + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// </remarks> + protected global::System.Web.UI.WebControls.Label nameLabel; + + /// <summary> + /// getAgeButton control. + /// </summary> + /// <remarks> + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// </remarks> + protected global::System.Web.UI.WebControls.Button getAgeButton; + + /// <summary> + /// ageLabel control. + /// </summary> + /// <remarks> + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// </remarks> + protected global::System.Web.UI.WebControls.Label ageLabel; + + /// <summary> + /// getFavoriteSites control. + /// </summary> + /// <remarks> + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// </remarks> + protected global::System.Web.UI.WebControls.Button getFavoriteSites; + + /// <summary> + /// favoriteSitesLabel control. + /// </summary> + /// <remarks> + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// </remarks> + protected global::System.Web.UI.WebControls.Label favoriteSitesLabel; + } } diff --git a/samples/OAuthConsumer/SignInWithTwitter.aspx b/samples/OAuthConsumer/SignInWithTwitter.aspx index 5b1624d..86d29a4 100644 --- a/samples/OAuthConsumer/SignInWithTwitter.aspx +++ b/samples/OAuthConsumer/SignInWithTwitter.aspx @@ -1,5 +1,5 @@ <%@ Page Language="C#" AutoEventWireup="true" - Inherits="SignInWithTwitter" Codebehind="SignInWithTwitter.aspx.cs" %> + Inherits="OAuthConsumer.SignInWithTwitter" Codebehind="SignInWithTwitter.aspx.cs" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> diff --git a/samples/OAuthConsumer/SignInWithTwitter.aspx.cs b/samples/OAuthConsumer/SignInWithTwitter.aspx.cs index 688471a..9cea1f5 100644 --- a/samples/OAuthConsumer/SignInWithTwitter.aspx.cs +++ b/samples/OAuthConsumer/SignInWithTwitter.aspx.cs @@ -1,37 +1,39 @@ -using System; -using System.Collections.Generic; -using System.Configuration; -using System.Linq; -using System.Web; -using System.Web.Security; -using System.Web.UI; -using System.Web.UI.WebControls; -using System.Xml.Linq; -using System.Xml.XPath; -using DotNetOpenAuth.ApplicationBlock; -using DotNetOpenAuth.OAuth; +namespace OAuthConsumer { + using System; + using System.Collections.Generic; + using System.Configuration; + using System.Linq; + using System.Web; + using System.Web.Security; + using System.Web.UI; + using System.Web.UI.WebControls; + using System.Xml.Linq; + using System.Xml.XPath; + using DotNetOpenAuth.ApplicationBlock; + using DotNetOpenAuth.OAuth; -public partial class SignInWithTwitter : System.Web.UI.Page { - protected void Page_Load(object sender, EventArgs e) { - if (TwitterConsumer.IsTwitterConsumerConfigured) { - MultiView1.ActiveViewIndex = 1; + public partial class SignInWithTwitter : System.Web.UI.Page { + protected void Page_Load(object sender, EventArgs e) { + if (TwitterConsumer.IsTwitterConsumerConfigured) { + MultiView1.ActiveViewIndex = 1; - if (!IsPostBack) { - string screenName; - int userId; - if (TwitterConsumer.TryFinishSignInWithTwitter(out screenName, out userId)) { - loggedInPanel.Visible = true; - loggedInName.Text = screenName; + if (!IsPostBack) { + string screenName; + int userId; + if (TwitterConsumer.TryFinishSignInWithTwitter(out screenName, out userId)) { + loggedInPanel.Visible = true; + loggedInName.Text = screenName; - // In a real app, the Twitter username would likely be used - // to log the user into the application. - ////FormsAuthentication.RedirectFromLoginPage(screenName, false); + // In a real app, the Twitter username would likely be used + // to log the user into the application. + ////FormsAuthentication.RedirectFromLoginPage(screenName, false); + } } } } - } - protected void signInButton_Click(object sender, ImageClickEventArgs e) { - TwitterConsumer.StartSignInWithTwitter(forceLoginCheckbox.Checked).Send(); + protected void signInButton_Click(object sender, ImageClickEventArgs e) { + TwitterConsumer.StartSignInWithTwitter(forceLoginCheckbox.Checked).Send(); + } } }
\ No newline at end of file diff --git a/samples/OAuthConsumer/SignInWithTwitter.aspx.designer.cs b/samples/OAuthConsumer/SignInWithTwitter.aspx.designer.cs index d515c2a..962a1af 100644 --- a/samples/OAuthConsumer/SignInWithTwitter.aspx.designer.cs +++ b/samples/OAuthConsumer/SignInWithTwitter.aspx.designer.cs @@ -7,79 +7,81 @@ // </auto-generated> //------------------------------------------------------------------------------ - - -public partial class SignInWithTwitter { - - /// <summary> - /// form1 control. - /// </summary> - /// <remarks> - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// </remarks> - protected global::System.Web.UI.HtmlControls.HtmlForm form1; - - /// <summary> - /// MultiView1 control. - /// </summary> - /// <remarks> - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// </remarks> - protected global::System.Web.UI.WebControls.MultiView MultiView1; - - /// <summary> - /// View1 control. - /// </summary> - /// <remarks> - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// </remarks> - protected global::System.Web.UI.WebControls.View View1; - - /// <summary> - /// View2 control. - /// </summary> - /// <remarks> - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// </remarks> - protected global::System.Web.UI.WebControls.View View2; - - /// <summary> - /// signInButton control. - /// </summary> - /// <remarks> - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// </remarks> - protected global::System.Web.UI.WebControls.ImageButton signInButton; - - /// <summary> - /// forceLoginCheckbox control. - /// </summary> - /// <remarks> - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// </remarks> - protected global::System.Web.UI.WebControls.CheckBox forceLoginCheckbox; +namespace OAuthConsumer { - /// <summary> - /// loggedInPanel control. - /// </summary> - /// <remarks> - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// </remarks> - protected global::System.Web.UI.WebControls.Panel loggedInPanel; - /// <summary> - /// loggedInName control. - /// </summary> - /// <remarks> - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// </remarks> - protected global::System.Web.UI.WebControls.Label loggedInName; + public partial class SignInWithTwitter { + + /// <summary> + /// form1 control. + /// </summary> + /// <remarks> + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// </remarks> + protected global::System.Web.UI.HtmlControls.HtmlForm form1; + + /// <summary> + /// MultiView1 control. + /// </summary> + /// <remarks> + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// </remarks> + protected global::System.Web.UI.WebControls.MultiView MultiView1; + + /// <summary> + /// View1 control. + /// </summary> + /// <remarks> + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// </remarks> + protected global::System.Web.UI.WebControls.View View1; + + /// <summary> + /// View2 control. + /// </summary> + /// <remarks> + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// </remarks> + protected global::System.Web.UI.WebControls.View View2; + + /// <summary> + /// signInButton control. + /// </summary> + /// <remarks> + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// </remarks> + protected global::System.Web.UI.WebControls.ImageButton signInButton; + + /// <summary> + /// forceLoginCheckbox control. + /// </summary> + /// <remarks> + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// </remarks> + protected global::System.Web.UI.WebControls.CheckBox forceLoginCheckbox; + + /// <summary> + /// loggedInPanel control. + /// </summary> + /// <remarks> + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// </remarks> + protected global::System.Web.UI.WebControls.Panel loggedInPanel; + + /// <summary> + /// loggedInName control. + /// </summary> + /// <remarks> + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// </remarks> + protected global::System.Web.UI.WebControls.Label loggedInName; + } } diff --git a/samples/OAuthConsumer/TracePage.aspx b/samples/OAuthConsumer/TracePage.aspx index 1b686db..d3539fb 100644 --- a/samples/OAuthConsumer/TracePage.aspx +++ b/samples/OAuthConsumer/TracePage.aspx @@ -1,4 +1,4 @@ -<%@ Page Language="C#" AutoEventWireup="true" Inherits="TracePage" Codebehind="TracePage.aspx.cs" %> +<%@ Page Language="C#" AutoEventWireup="true" Inherits="OAuthConsumer.TracePage" Codebehind="TracePage.aspx.cs" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> diff --git a/samples/OAuthConsumer/TracePage.aspx.cs b/samples/OAuthConsumer/TracePage.aspx.cs index 7075ce3..b9ca260 100644 --- a/samples/OAuthConsumer/TracePage.aspx.cs +++ b/samples/OAuthConsumer/TracePage.aspx.cs @@ -1,21 +1,23 @@ -using System; -using System.Collections.Generic; -using System.Web; -using System.Web.UI; -using System.Web.UI.WebControls; +namespace OAuthConsumer { + using System; + using System.Collections.Generic; + using System.Web; + using System.Web.UI; + using System.Web.UI.WebControls; -/// <summary> -/// A page to display recent log messages. -/// </summary> -public partial class TracePage : System.Web.UI.Page { - protected void Page_Load(object sender, EventArgs e) { - this.placeHolder1.Controls.Add(new Label { Text = HttpUtility.HtmlEncode(Logging.LogMessages.ToString()) }); - } + /// <summary> + /// A page to display recent log messages. + /// </summary> + public partial class TracePage : System.Web.UI.Page { + protected void Page_Load(object sender, EventArgs e) { + this.placeHolder1.Controls.Add(new Label { Text = HttpUtility.HtmlEncode(Logging.LogMessages.ToString()) }); + } - protected void clearLogButton_Click(object sender, EventArgs e) { - Logging.LogMessages.Length = 0; + protected void clearLogButton_Click(object sender, EventArgs e) { + Logging.LogMessages.Length = 0; - // clear the page immediately, and allow for F5 without a Postback warning. - Response.Redirect(Request.Url.AbsoluteUri); + // clear the page immediately, and allow for F5 without a Postback warning. + Response.Redirect(Request.Url.AbsoluteUri); + } } -} +}
\ No newline at end of file diff --git a/samples/OAuthConsumer/TracePage.aspx.designer.cs b/samples/OAuthConsumer/TracePage.aspx.designer.cs index 6a0028b..73184b5 100644 --- a/samples/OAuthConsumer/TracePage.aspx.designer.cs +++ b/samples/OAuthConsumer/TracePage.aspx.designer.cs @@ -7,34 +7,36 @@ // </auto-generated> //------------------------------------------------------------------------------ - - -public partial class TracePage { - - /// <summary> - /// form1 control. - /// </summary> - /// <remarks> - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// </remarks> - protected global::System.Web.UI.HtmlControls.HtmlForm form1; +namespace OAuthConsumer { - /// <summary> - /// clearLogButton control. - /// </summary> - /// <remarks> - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// </remarks> - protected global::System.Web.UI.WebControls.Button clearLogButton; - /// <summary> - /// placeHolder1 control. - /// </summary> - /// <remarks> - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// </remarks> - protected global::System.Web.UI.WebControls.PlaceHolder placeHolder1; + public partial class TracePage { + + /// <summary> + /// form1 control. + /// </summary> + /// <remarks> + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// </remarks> + protected global::System.Web.UI.HtmlControls.HtmlForm form1; + + /// <summary> + /// clearLogButton control. + /// </summary> + /// <remarks> + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// </remarks> + protected global::System.Web.UI.WebControls.Button clearLogButton; + + /// <summary> + /// placeHolder1 control. + /// </summary> + /// <remarks> + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// </remarks> + protected global::System.Web.UI.WebControls.PlaceHolder placeHolder1; + } } diff --git a/samples/OAuthConsumer/Twitter.aspx b/samples/OAuthConsumer/Twitter.aspx index f52f624..a24c7bd 100644 --- a/samples/OAuthConsumer/Twitter.aspx +++ b/samples/OAuthConsumer/Twitter.aspx @@ -1,4 +1,4 @@ -<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" Inherits="Twitter" Codebehind="Twitter.aspx.cs" %> +<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" Inherits="OAuthConsumer.Twitter" Codebehind="Twitter.aspx.cs" %> <asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server"> </asp:Content> diff --git a/samples/OAuthConsumer/Twitter.aspx.cs b/samples/OAuthConsumer/Twitter.aspx.cs index f309396..44350ca 100644 --- a/samples/OAuthConsumer/Twitter.aspx.cs +++ b/samples/OAuthConsumer/Twitter.aspx.cs @@ -1,94 +1,96 @@ -using System; -using System.Collections.Generic; -using System.Configuration; -using System.Linq; -using System.Text; -using System.Web; -using System.Web.UI; -using System.Web.UI.WebControls; -using System.Xml.Linq; -using System.Xml.XPath; -using DotNetOpenAuth.ApplicationBlock; -using DotNetOpenAuth.OAuth; +namespace OAuthConsumer { + using System; + using System.Collections.Generic; + using System.Configuration; + using System.Linq; + using System.Text; + using System.Web; + using System.Web.UI; + using System.Web.UI.WebControls; + using System.Xml.Linq; + using System.Xml.XPath; + using DotNetOpenAuth.ApplicationBlock; + using DotNetOpenAuth.OAuth; -public partial class Twitter : System.Web.UI.Page { - private string AccessToken { - get { return (string)Session["TwitterAccessToken"]; } - set { Session["TwitterAccessToken"] = value; } - } + public partial class Twitter : System.Web.UI.Page { + private string AccessToken { + get { return (string)Session["TwitterAccessToken"]; } + set { Session["TwitterAccessToken"] = value; } + } - private InMemoryTokenManager TokenManager { - get { - var tokenManager = (InMemoryTokenManager)Application["TwitterTokenManager"]; - if (tokenManager == null) { - string consumerKey = ConfigurationManager.AppSettings["twitterConsumerKey"]; - string consumerSecret = ConfigurationManager.AppSettings["twitterConsumerSecret"]; - if (!string.IsNullOrEmpty(consumerKey)) { - tokenManager = new InMemoryTokenManager(consumerKey, consumerSecret); - Application["TwitterTokenManager"] = tokenManager; + private InMemoryTokenManager TokenManager { + get { + var tokenManager = (InMemoryTokenManager)Application["TwitterTokenManager"]; + if (tokenManager == null) { + string consumerKey = ConfigurationManager.AppSettings["twitterConsumerKey"]; + string consumerSecret = ConfigurationManager.AppSettings["twitterConsumerSecret"]; + if (!string.IsNullOrEmpty(consumerKey)) { + tokenManager = new InMemoryTokenManager(consumerKey, consumerSecret); + Application["TwitterTokenManager"] = tokenManager; + } } - } - return tokenManager; + return tokenManager; + } } - } - protected void Page_Load(object sender, EventArgs e) { - if (this.TokenManager != null) { - MultiView1.ActiveViewIndex = 1; + protected void Page_Load(object sender, EventArgs e) { + if (this.TokenManager != null) { + MultiView1.ActiveViewIndex = 1; - if (!IsPostBack) { - var twitter = new WebConsumer(TwitterConsumer.ServiceDescription, this.TokenManager); + if (!IsPostBack) { + var twitter = new WebConsumer(TwitterConsumer.ServiceDescription, this.TokenManager); - // Is Twitter calling back with authorization? - var accessTokenResponse = twitter.ProcessUserAuthorization(); - if (accessTokenResponse != null) { - this.AccessToken = accessTokenResponse.AccessToken; - } else if (this.AccessToken == null) { - // If we don't yet have access, immediately request it. - twitter.Channel.Send(twitter.PrepareRequestUserAuthorization()); + // Is Twitter calling back with authorization? + var accessTokenResponse = twitter.ProcessUserAuthorization(); + if (accessTokenResponse != null) { + this.AccessToken = accessTokenResponse.AccessToken; + } else if (this.AccessToken == null) { + // If we don't yet have access, immediately request it. + twitter.Channel.Send(twitter.PrepareRequestUserAuthorization()); + } } } } - } - protected void downloadUpdates_Click(object sender, EventArgs e) { - var twitter = new WebConsumer(TwitterConsumer.ServiceDescription, this.TokenManager); - XPathDocument updates = new XPathDocument(TwitterConsumer.GetUpdates(twitter, this.AccessToken).CreateReader()); - XPathNavigator nav = updates.CreateNavigator(); - var parsedUpdates = from status in nav.Select("/statuses/status").OfType<XPathNavigator>() - where !status.SelectSingleNode("user/protected").ValueAsBoolean - select new { - User = status.SelectSingleNode("user/name").InnerXml, - Status = status.SelectSingleNode("text").InnerXml, - }; + protected void downloadUpdates_Click(object sender, EventArgs e) { + var twitter = new WebConsumer(TwitterConsumer.ServiceDescription, this.TokenManager); + XPathDocument updates = new XPathDocument(TwitterConsumer.GetUpdates(twitter, this.AccessToken).CreateReader()); + XPathNavigator nav = updates.CreateNavigator(); + var parsedUpdates = from status in nav.Select("/statuses/status").OfType<XPathNavigator>() + where !status.SelectSingleNode("user/protected").ValueAsBoolean + select new { + User = status.SelectSingleNode("user/name").InnerXml, + Status = status.SelectSingleNode("text").InnerXml, + }; - StringBuilder tableBuilder = new StringBuilder(); - tableBuilder.Append("<table><tr><td>Name</td><td>Update</td></tr>"); + StringBuilder tableBuilder = new StringBuilder(); + tableBuilder.Append("<table><tr><td>Name</td><td>Update</td></tr>"); - foreach (var update in parsedUpdates) { - tableBuilder.AppendFormat( - "<tr><td>{0}</td><td>{1}</td></tr>", - HttpUtility.HtmlEncode(update.User), - HttpUtility.HtmlEncode(update.Status)); + foreach (var update in parsedUpdates) { + tableBuilder.AppendFormat( + "<tr><td>{0}</td><td>{1}</td></tr>", + HttpUtility.HtmlEncode(update.User), + HttpUtility.HtmlEncode(update.Status)); + } + tableBuilder.Append("</table>"); + resultsPlaceholder.Controls.Add(new Literal { Text = tableBuilder.ToString() }); } - tableBuilder.Append("</table>"); - resultsPlaceholder.Controls.Add(new Literal { Text = tableBuilder.ToString() }); - } - protected void uploadProfilePhotoButton_Click(object sender, EventArgs e) { - if (profilePhoto.PostedFile.ContentType == null) { + protected void uploadProfilePhotoButton_Click(object sender, EventArgs e) { + if (profilePhoto.PostedFile.ContentType == null) { + photoUploadedLabel.Visible = true; + photoUploadedLabel.Text = "Select a file first."; + return; + } + + var twitter = new WebConsumer(TwitterConsumer.ServiceDescription, this.TokenManager); + XDocument imageResult = TwitterConsumer.UpdateProfileImage( + twitter, + this.AccessToken, + profilePhoto.PostedFile.InputStream, + profilePhoto.PostedFile.ContentType); photoUploadedLabel.Visible = true; - photoUploadedLabel.Text = "Select a file first."; - return; } - - var twitter = new WebConsumer(TwitterConsumer.ServiceDescription, this.TokenManager); - XDocument imageResult = TwitterConsumer.UpdateProfileImage( - twitter, - this.AccessToken, - profilePhoto.PostedFile.InputStream, - profilePhoto.PostedFile.ContentType); - photoUploadedLabel.Visible = true; } -} +}
\ No newline at end of file diff --git a/samples/OAuthConsumer/Twitter.aspx.designer.cs b/samples/OAuthConsumer/Twitter.aspx.designer.cs index 10938cd..7c37271 100644 --- a/samples/OAuthConsumer/Twitter.aspx.designer.cs +++ b/samples/OAuthConsumer/Twitter.aspx.designer.cs @@ -7,70 +7,72 @@ // </auto-generated> //------------------------------------------------------------------------------ - - -public partial class Twitter { - - /// <summary> - /// MultiView1 control. - /// </summary> - /// <remarks> - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// </remarks> - protected global::System.Web.UI.WebControls.MultiView MultiView1; - - /// <summary> - /// View1 control. - /// </summary> - /// <remarks> - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// </remarks> - protected global::System.Web.UI.WebControls.View View1; - - /// <summary> - /// profilePhoto control. - /// </summary> - /// <remarks> - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// </remarks> - protected global::System.Web.UI.WebControls.FileUpload profilePhoto; - - /// <summary> - /// uploadProfilePhotoButton control. - /// </summary> - /// <remarks> - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// </remarks> - protected global::System.Web.UI.WebControls.Button uploadProfilePhotoButton; - - /// <summary> - /// photoUploadedLabel control. - /// </summary> - /// <remarks> - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// </remarks> - protected global::System.Web.UI.WebControls.Label photoUploadedLabel; +namespace OAuthConsumer { - /// <summary> - /// downloadUpdates control. - /// </summary> - /// <remarks> - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// </remarks> - protected global::System.Web.UI.WebControls.Button downloadUpdates; - /// <summary> - /// resultsPlaceholder control. - /// </summary> - /// <remarks> - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// </remarks> - protected global::System.Web.UI.WebControls.PlaceHolder resultsPlaceholder; + public partial class Twitter { + + /// <summary> + /// MultiView1 control. + /// </summary> + /// <remarks> + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// </remarks> + protected global::System.Web.UI.WebControls.MultiView MultiView1; + + /// <summary> + /// View1 control. + /// </summary> + /// <remarks> + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// </remarks> + protected global::System.Web.UI.WebControls.View View1; + + /// <summary> + /// profilePhoto control. + /// </summary> + /// <remarks> + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// </remarks> + protected global::System.Web.UI.WebControls.FileUpload profilePhoto; + + /// <summary> + /// uploadProfilePhotoButton control. + /// </summary> + /// <remarks> + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// </remarks> + protected global::System.Web.UI.WebControls.Button uploadProfilePhotoButton; + + /// <summary> + /// photoUploadedLabel control. + /// </summary> + /// <remarks> + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// </remarks> + protected global::System.Web.UI.WebControls.Label photoUploadedLabel; + + /// <summary> + /// downloadUpdates control. + /// </summary> + /// <remarks> + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// </remarks> + protected global::System.Web.UI.WebControls.Button downloadUpdates; + + /// <summary> + /// resultsPlaceholder control. + /// </summary> + /// <remarks> + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// </remarks> + protected global::System.Web.UI.WebControls.PlaceHolder resultsPlaceholder; + } } diff --git a/samples/OAuthConsumer/Web.config b/samples/OAuthConsumer/Web.config index cad6ef2..5e96705 100644 --- a/samples/OAuthConsumer/Web.config +++ b/samples/OAuthConsumer/Web.config @@ -149,7 +149,7 @@ </assemblyBinding> </runtime> <log4net> - <appender name="TracePageAppender" type="TracePageAppender, OAuthConsumer"> + <appender name="TracePageAppender" type="OAuthConsumer.TracePageAppender, OAuthConsumer"> <layout type="log4net.Layout.PatternLayout"> <conversionPattern value="%date (GMT%date{%z}) [%thread] %-5level %logger - %message%newline" /> </layout> diff --git a/samples/OAuthServiceProvider/Code/Constants.cs b/samples/OAuthServiceProvider/Code/Constants.cs index 168b952..3e629f0 100644 --- a/samples/OAuthServiceProvider/Code/Constants.cs +++ b/samples/OAuthServiceProvider/Code/Constants.cs @@ -1,30 +1,32 @@ -using System; -using DotNetOpenAuth.Messaging; -using DotNetOpenAuth.OAuth; -using DotNetOpenAuth.OAuth.ChannelElements; +namespace OAuthServiceProvider.Code { + using System; + using DotNetOpenAuth.Messaging; + using DotNetOpenAuth.OAuth; + using DotNetOpenAuth.OAuth.ChannelElements; -/// <summary> -/// Service Provider definitions. -/// </summary> -public static class Constants { - public static Uri WebRootUrl { get; set; } + /// <summary> + /// Service Provider definitions. + /// </summary> + public static class Constants { + public static Uri WebRootUrl { get; set; } - public static ServiceProviderDescription SelfDescription { - get { - ServiceProviderDescription description = new ServiceProviderDescription { - AccessTokenEndpoint = new MessageReceivingEndpoint(new Uri(WebRootUrl, "/OAuth.ashx"), HttpDeliveryMethods.PostRequest), - RequestTokenEndpoint = new MessageReceivingEndpoint(new Uri(WebRootUrl, "/OAuth.ashx"), HttpDeliveryMethods.PostRequest), - UserAuthorizationEndpoint = new MessageReceivingEndpoint(new Uri(WebRootUrl, "/OAuth.ashx"), HttpDeliveryMethods.PostRequest), - TamperProtectionElements = new ITamperProtectionChannelBindingElement[] { + public static ServiceProviderDescription SelfDescription { + get { + ServiceProviderDescription description = new ServiceProviderDescription { + AccessTokenEndpoint = new MessageReceivingEndpoint(new Uri(WebRootUrl, "/OAuth.ashx"), HttpDeliveryMethods.PostRequest), + RequestTokenEndpoint = new MessageReceivingEndpoint(new Uri(WebRootUrl, "/OAuth.ashx"), HttpDeliveryMethods.PostRequest), + UserAuthorizationEndpoint = new MessageReceivingEndpoint(new Uri(WebRootUrl, "/OAuth.ashx"), HttpDeliveryMethods.PostRequest), + TamperProtectionElements = new ITamperProtectionChannelBindingElement[] { new HmacSha1SigningBindingElement(), }, - }; + }; - return description; + return description; + } } - } - public static ServiceProvider CreateServiceProvider() { - return new ServiceProvider(SelfDescription, Global.TokenManager, Global.NonceStore); + public static ServiceProvider CreateServiceProvider() { + return new ServiceProvider(SelfDescription, Global.TokenManager, Global.NonceStore); + } } -} +}
\ No newline at end of file diff --git a/samples/OAuthServiceProvider/Code/CustomOAuthTypeProvider.cs b/samples/OAuthServiceProvider/Code/CustomOAuthTypeProvider.cs index 0932dec..67da17c 100644 --- a/samples/OAuthServiceProvider/Code/CustomOAuthTypeProvider.cs +++ b/samples/OAuthServiceProvider/Code/CustomOAuthTypeProvider.cs @@ -1,32 +1,34 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Web; -using DotNetOpenAuth.Messaging; -using DotNetOpenAuth.OAuth.ChannelElements; -using DotNetOpenAuth.OAuth.Messages; +namespace OAuthServiceProvider.Code { + using System; + using System.Collections.Generic; + using System.Linq; + using System.Web; + using DotNetOpenAuth.Messaging; + using DotNetOpenAuth.OAuth.ChannelElements; + using DotNetOpenAuth.OAuth.Messages; -/// <summary> -/// A custom class that will cause the OAuth library to use our custom message types -/// where we have them. -/// </summary> -public class CustomOAuthMessageFactory : OAuthServiceProviderMessageFactory { /// <summary> - /// Initializes a new instance of the <see cref="CustomOAuthMessageFactory"/> class. + /// A custom class that will cause the OAuth library to use our custom message types + /// where we have them. /// </summary> - /// <param name="tokenManager">The token manager instance to use.</param> - public CustomOAuthMessageFactory(IServiceProviderTokenManager tokenManager) - : base(tokenManager) { - } + public class CustomOAuthMessageFactory : OAuthServiceProviderMessageFactory { + /// <summary> + /// Initializes a new instance of the <see cref="CustomOAuthMessageFactory"/> class. + /// </summary> + /// <param name="tokenManager">The token manager instance to use.</param> + public CustomOAuthMessageFactory(IServiceProviderTokenManager tokenManager) + : base(tokenManager) { + } - public override IDirectedProtocolMessage GetNewRequestMessage(MessageReceivingEndpoint recipient, IDictionary<string, string> fields) { - var message = base.GetNewRequestMessage(recipient, fields); + public override IDirectedProtocolMessage GetNewRequestMessage(MessageReceivingEndpoint recipient, IDictionary<string, string> fields) { + var message = base.GetNewRequestMessage(recipient, fields); - // inject our own type here to replace the standard one - if (message is UnauthorizedTokenRequest) { - message = new RequestScopedTokenMessage(recipient, message.Version); - } + // inject our own type here to replace the standard one + if (message is UnauthorizedTokenRequest) { + message = new RequestScopedTokenMessage(recipient, message.Version); + } - return message; + return message; + } } -} +}
\ No newline at end of file diff --git a/samples/OAuthServiceProvider/Code/DataClasses.dbml b/samples/OAuthServiceProvider/Code/DataClasses.dbml index 393420e..5522ec8 100644 --- a/samples/OAuthServiceProvider/Code/DataClasses.dbml +++ b/samples/OAuthServiceProvider/Code/DataClasses.dbml @@ -1,4 +1,4 @@ -<?xml version="1.0" encoding="utf-8"?><Database Name="Database" Class="DataClassesDataContext" xmlns="http://schemas.microsoft.com/linqtosql/dbml/2007"> +<?xml version="1.0" encoding="utf-8"?><Database Name="Database" EntityNamespace="OAuthServiceProvider.Code" Class="DataClassesDataContext" xmlns="http://schemas.microsoft.com/linqtosql/dbml/2007"> <Connection Mode="WebSettings" ConnectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Database.mdf;Integrated Security=True;User Instance=True" SettingsObjectName="System.Configuration.ConfigurationManager.ConnectionStrings" SettingsPropertyName="DatabaseConnectionString" Provider="System.Data.SqlClient" /> <Table Name="dbo.[User]" Member="Users"> <Type Name="User"> @@ -35,7 +35,7 @@ <Column Name="TokenId" Type="System.Int32" DbType="Int NOT NULL IDENTITY" IsPrimaryKey="true" IsDbGenerated="true" CanBeNull="false" /> <Column Name="Token" Type="System.String" DbType="NVarChar(50) NOT NULL" CanBeNull="false" /> <Column Name="TokenSecret" Type="System.String" DbType="NVarChar(50) NOT NULL" CanBeNull="false" /> - <Column Name="State" Type="TokenAuthorizationState" DbType="INT NOT NULL" CanBeNull="false" /> + <Column Name="State" Type="OAuthServiceProvider.Code.TokenAuthorizationState" DbType="INT NOT NULL" CanBeNull="false" /> <Column Name="IssueDate" Type="System.DateTime" DbType="DateTime NOT NULL" CanBeNull="false" /> <Column Name="ConsumerId" Type="System.Int32" DbType="Int NOT NULL" CanBeNull="false" /> <Column Name="UserId" Type="System.Int32" DbType="Int" CanBeNull="true" /> diff --git a/samples/OAuthServiceProvider/Code/DataClasses.dbml.layout b/samples/OAuthServiceProvider/Code/DataClasses.dbml.layout index 44ce026..9b80443 100644 --- a/samples/OAuthServiceProvider/Code/DataClasses.dbml.layout +++ b/samples/OAuthServiceProvider/Code/DataClasses.dbml.layout @@ -26,7 +26,7 @@ <elementListCompartment Id="403126d0-3d2a-4af4-b0b8-c489a830bbd4" absoluteBounds="3.515, 3.585, 1.9700000000000002, 2.364705403645833" name="DataPropertiesCompartment" titleTextColor="Black" itemTextColor="Black" /> </nestedChildShapes> </classShape> - <associationConnector edgePoints="[(2.625 : 1.31814697265625); (3.5 : 1.31814697265625)]" fixedFrom="Algorithm" fixedTo="Algorithm"> + <associationConnector edgePoints="[(2.625 : 1.31814697265625); (3.5 : 1.31814697265625)]" fixedFrom="NotFixed" fixedTo="NotFixed"> <AssociationMoniker Name="/DataClassesDataContext/User/User_FavoriteSite" /> <nodes> <classShapeMoniker Id="696d2c69-040e-411d-9257-bb664b743834" /> @@ -40,7 +40,7 @@ <classShapeMoniker Id="895ebbc8-8352-4c04-9e53-b8e6c8302d36" /> </nodes> </associationConnector> - <associationConnector edgePoints="[(0.53125 : 2.27089680989583); (0.53125 : 5.66270182291667); (3.5 : 5.66270182291667)]" fixedFrom="Algorithm" fixedTo="Algorithm"> + <associationConnector edgePoints="[(0.53125 : 2.27089680989583); (0.53125 : 5.66270182291667); (3.5 : 5.66270182291667)]" fixedFrom="NotFixed" fixedTo="NotFixed"> <AssociationMoniker Name="/DataClassesDataContext/User/User_OAuthToken" /> <nodes> <classShapeMoniker Id="696d2c69-040e-411d-9257-bb664b743834" /> diff --git a/samples/OAuthServiceProvider/Code/DataClasses.designer.cs b/samples/OAuthServiceProvider/Code/DataClasses.designer.cs index 89757e5..3c0d936 100644 --- a/samples/OAuthServiceProvider/Code/DataClasses.designer.cs +++ b/samples/OAuthServiceProvider/Code/DataClasses.designer.cs @@ -9,134 +9,135 @@ // </auto-generated> //------------------------------------------------------------------------------ -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Data; -using System.Data.Linq; -using System.Data.Linq.Mapping; -using System.Linq; -using System.Linq.Expressions; -using System.Reflection; - - - -[global::System.Data.Linq.Mapping.DatabaseAttribute(Name="Database")] -public partial class DataClassesDataContext : System.Data.Linq.DataContext +namespace OAuthServiceProvider.Code { - - private static System.Data.Linq.Mapping.MappingSource mappingSource = new AttributeMappingSource(); - - #region Extensibility Method Definitions - partial void OnCreated(); - partial void InsertUser(User instance); - partial void UpdateUser(User instance); - partial void DeleteUser(User instance); - partial void InsertFavoriteSite(FavoriteSite instance); - partial void UpdateFavoriteSite(FavoriteSite instance); - partial void DeleteFavoriteSite(FavoriteSite instance); - partial void InsertOAuthConsumer(OAuthConsumer instance); - partial void UpdateOAuthConsumer(OAuthConsumer instance); - partial void DeleteOAuthConsumer(OAuthConsumer instance); - partial void InsertOAuthToken(OAuthToken instance); - partial void UpdateOAuthToken(OAuthToken instance); - partial void DeleteOAuthToken(OAuthToken instance); - partial void InsertNonce(Nonce instance); - partial void UpdateNonce(Nonce instance); - partial void DeleteNonce(Nonce instance); - #endregion - - public DataClassesDataContext() : - base(global::System.Configuration.ConfigurationManager.ConnectionStrings["DatabaseConnectionString"].ConnectionString, mappingSource) - { - OnCreated(); - } - - public DataClassesDataContext(string connection) : - base(connection, mappingSource) - { - OnCreated(); - } - - public DataClassesDataContext(System.Data.IDbConnection connection) : - base(connection, mappingSource) - { - OnCreated(); - } - - public DataClassesDataContext(string connection, System.Data.Linq.Mapping.MappingSource mappingSource) : - base(connection, mappingSource) - { - OnCreated(); - } - - public DataClassesDataContext(System.Data.IDbConnection connection, System.Data.Linq.Mapping.MappingSource mappingSource) : - base(connection, mappingSource) - { - OnCreated(); - } - - public System.Data.Linq.Table<User> Users - { - get + using System.Data.Linq; + using System.Data.Linq.Mapping; + using System.Data; + using System.Collections.Generic; + using System.Reflection; + using System.Linq; + using System.Linq.Expressions; + using System.ComponentModel; + using System; + + + [global::System.Data.Linq.Mapping.DatabaseAttribute(Name="Database")] + public partial class DataClassesDataContext : System.Data.Linq.DataContext + { + + private static System.Data.Linq.Mapping.MappingSource mappingSource = new AttributeMappingSource(); + + #region Extensibility Method Definitions + partial void OnCreated(); + partial void InsertUser(User instance); + partial void UpdateUser(User instance); + partial void DeleteUser(User instance); + partial void InsertFavoriteSite(FavoriteSite instance); + partial void UpdateFavoriteSite(FavoriteSite instance); + partial void DeleteFavoriteSite(FavoriteSite instance); + partial void InsertOAuthConsumer(OAuthConsumer instance); + partial void UpdateOAuthConsumer(OAuthConsumer instance); + partial void DeleteOAuthConsumer(OAuthConsumer instance); + partial void InsertOAuthToken(OAuthToken instance); + partial void UpdateOAuthToken(OAuthToken instance); + partial void DeleteOAuthToken(OAuthToken instance); + partial void InsertNonce(Nonce instance); + partial void UpdateNonce(Nonce instance); + partial void DeleteNonce(Nonce instance); + #endregion + + public DataClassesDataContext() : + base(global::System.Configuration.ConfigurationManager.ConnectionStrings["DatabaseConnectionString"].ConnectionString, mappingSource) { - return this.GetTable<User>(); + OnCreated(); } - } - - public System.Data.Linq.Table<FavoriteSite> FavoriteSites - { - get + + public DataClassesDataContext(string connection) : + base(connection, mappingSource) { - return this.GetTable<FavoriteSite>(); + OnCreated(); } - } - - public System.Data.Linq.Table<OAuthConsumer> OAuthConsumers - { - get + + public DataClassesDataContext(System.Data.IDbConnection connection) : + base(connection, mappingSource) { - return this.GetTable<OAuthConsumer>(); + OnCreated(); } - } - - public System.Data.Linq.Table<OAuthToken> OAuthTokens - { - get + + public DataClassesDataContext(string connection, System.Data.Linq.Mapping.MappingSource mappingSource) : + base(connection, mappingSource) { - return this.GetTable<OAuthToken>(); + OnCreated(); } - } - - public System.Data.Linq.Table<Nonce> Nonces - { - get + + public DataClassesDataContext(System.Data.IDbConnection connection, System.Data.Linq.Mapping.MappingSource mappingSource) : + base(connection, mappingSource) + { + OnCreated(); + } + + public System.Data.Linq.Table<User> Users { - return this.GetTable<Nonce>(); + get + { + return this.GetTable<User>(); + } + } + + public System.Data.Linq.Table<FavoriteSite> FavoriteSites + { + get + { + return this.GetTable<FavoriteSite>(); + } + } + + public System.Data.Linq.Table<OAuthConsumer> OAuthConsumers + { + get + { + return this.GetTable<OAuthConsumer>(); + } + } + + public System.Data.Linq.Table<OAuthToken> OAuthTokens + { + get + { + return this.GetTable<OAuthToken>(); + } + } + + public System.Data.Linq.Table<Nonce> Nonces + { + get + { + return this.GetTable<Nonce>(); + } } } -} - -[global::System.Data.Linq.Mapping.TableAttribute(Name="dbo.[User]")] -public partial class User : INotifyPropertyChanging, INotifyPropertyChanged -{ - - private static PropertyChangingEventArgs emptyChangingEventArgs = new PropertyChangingEventArgs(String.Empty); - - private int _UserId; - - private string _OpenIDClaimedIdentifier; - - private string _OpenIDFriendlyIdentifier; - - private string _FullName; - - private System.Nullable<int> _Age; - - private EntitySet<FavoriteSite> _FavoriteSites; - - private EntitySet<OAuthToken> _OAuthTokens; + [global::System.Data.Linq.Mapping.TableAttribute(Name="dbo.[User]")] + public partial class User : INotifyPropertyChanging, INotifyPropertyChanged + { + + private static PropertyChangingEventArgs emptyChangingEventArgs = new PropertyChangingEventArgs(String.Empty); + + private int _UserId; + + private string _OpenIDClaimedIdentifier; + + private string _OpenIDFriendlyIdentifier; + + private string _FullName; + + private System.Nullable<int> _Age; + + private EntitySet<FavoriteSite> _FavoriteSites; + + private EntitySet<OAuthToken> _OAuthTokens; + #region Extensibility Method Definitions partial void OnLoaded(); partial void OnValidate(System.Data.Linq.ChangeAction action); @@ -152,199 +153,199 @@ public partial class User : INotifyPropertyChanging, INotifyPropertyChanged partial void OnAgeChanging(System.Nullable<int> value); partial void OnAgeChanged(); #endregion - - public User() - { - this._FavoriteSites = new EntitySet<FavoriteSite>(new Action<FavoriteSite>(this.attach_FavoriteSites), new Action<FavoriteSite>(this.detach_FavoriteSites)); - this._OAuthTokens = new EntitySet<OAuthToken>(new Action<OAuthToken>(this.attach_OAuthTokens), new Action<OAuthToken>(this.detach_OAuthTokens)); - OnCreated(); - } - - [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_UserId", AutoSync=AutoSync.OnInsert, DbType="Int NOT NULL IDENTITY", IsPrimaryKey=true, IsDbGenerated=true)] - public int UserId - { - get + + public User() { - return this._UserId; + this._FavoriteSites = new EntitySet<FavoriteSite>(new Action<FavoriteSite>(this.attach_FavoriteSites), new Action<FavoriteSite>(this.detach_FavoriteSites)); + this._OAuthTokens = new EntitySet<OAuthToken>(new Action<OAuthToken>(this.attach_OAuthTokens), new Action<OAuthToken>(this.detach_OAuthTokens)); + OnCreated(); } - set + + [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_UserId", AutoSync=AutoSync.OnInsert, DbType="Int NOT NULL IDENTITY", IsPrimaryKey=true, IsDbGenerated=true)] + public int UserId { - if ((this._UserId != value)) + get { - this.OnUserIdChanging(value); - this.SendPropertyChanging(); - this._UserId = value; - this.SendPropertyChanged("UserId"); - this.OnUserIdChanged(); + return this._UserId; } - } - } - - [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_OpenIDClaimedIdentifier", DbType="NVarChar(150) NOT NULL", CanBeNull=false)] - public string OpenIDClaimedIdentifier - { - get - { - return this._OpenIDClaimedIdentifier; - } - set - { - if ((this._OpenIDClaimedIdentifier != value)) + set { - this.OnOpenIDClaimedIdentifierChanging(value); - this.SendPropertyChanging(); - this._OpenIDClaimedIdentifier = value; - this.SendPropertyChanged("OpenIDClaimedIdentifier"); - this.OnOpenIDClaimedIdentifierChanged(); + if ((this._UserId != value)) + { + this.OnUserIdChanging(value); + this.SendPropertyChanging(); + this._UserId = value; + this.SendPropertyChanged("UserId"); + this.OnUserIdChanged(); + } } } - } - - [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_OpenIDFriendlyIdentifier", DbType="NVarChar(150)")] - public string OpenIDFriendlyIdentifier - { - get + + [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_OpenIDClaimedIdentifier", DbType="NVarChar(150) NOT NULL", CanBeNull=false)] + public string OpenIDClaimedIdentifier { - return this._OpenIDFriendlyIdentifier; + get + { + return this._OpenIDClaimedIdentifier; + } + set + { + if ((this._OpenIDClaimedIdentifier != value)) + { + this.OnOpenIDClaimedIdentifierChanging(value); + this.SendPropertyChanging(); + this._OpenIDClaimedIdentifier = value; + this.SendPropertyChanged("OpenIDClaimedIdentifier"); + this.OnOpenIDClaimedIdentifierChanged(); + } + } } - set + + [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_OpenIDFriendlyIdentifier", DbType="NVarChar(150)")] + public string OpenIDFriendlyIdentifier { - if ((this._OpenIDFriendlyIdentifier != value)) + get { - this.OnOpenIDFriendlyIdentifierChanging(value); - this.SendPropertyChanging(); - this._OpenIDFriendlyIdentifier = value; - this.SendPropertyChanged("OpenIDFriendlyIdentifier"); - this.OnOpenIDFriendlyIdentifierChanged(); + return this._OpenIDFriendlyIdentifier; + } + set + { + if ((this._OpenIDFriendlyIdentifier != value)) + { + this.OnOpenIDFriendlyIdentifierChanging(value); + this.SendPropertyChanging(); + this._OpenIDFriendlyIdentifier = value; + this.SendPropertyChanged("OpenIDFriendlyIdentifier"); + this.OnOpenIDFriendlyIdentifierChanged(); + } } } - } - - [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_FullName", DbType="NVarChar(150)", CanBeNull=false)] - public string FullName - { - get + + [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_FullName", DbType="NVarChar(150)", CanBeNull=false)] + public string FullName { - return this._FullName; + get + { + return this._FullName; + } + set + { + if ((this._FullName != value)) + { + this.OnFullNameChanging(value); + this.SendPropertyChanging(); + this._FullName = value; + this.SendPropertyChanged("FullName"); + this.OnFullNameChanged(); + } + } } - set + + [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_Age", DbType="int")] + public System.Nullable<int> Age { - if ((this._FullName != value)) + get { - this.OnFullNameChanging(value); - this.SendPropertyChanging(); - this._FullName = value; - this.SendPropertyChanged("FullName"); - this.OnFullNameChanged(); + return this._Age; + } + set + { + if ((this._Age != value)) + { + this.OnAgeChanging(value); + this.SendPropertyChanging(); + this._Age = value; + this.SendPropertyChanged("Age"); + this.OnAgeChanged(); + } } } - } - - [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_Age", DbType="int")] - public System.Nullable<int> Age - { - get + + [global::System.Data.Linq.Mapping.AssociationAttribute(Name="User_FavoriteSite", Storage="_FavoriteSites", ThisKey="UserId", OtherKey="UserId")] + public EntitySet<FavoriteSite> FavoriteSites { - return this._Age; + get + { + return this._FavoriteSites; + } + set + { + this._FavoriteSites.Assign(value); + } } - set + + [global::System.Data.Linq.Mapping.AssociationAttribute(Name="User_OAuthToken", Storage="_OAuthTokens", ThisKey="UserId", OtherKey="UserId")] + public EntitySet<OAuthToken> OAuthTokens { - if ((this._Age != value)) + get { - this.OnAgeChanging(value); - this.SendPropertyChanging(); - this._Age = value; - this.SendPropertyChanged("Age"); - this.OnAgeChanged(); + return this._OAuthTokens; + } + set + { + this._OAuthTokens.Assign(value); } } - } - - [global::System.Data.Linq.Mapping.AssociationAttribute(Name="User_FavoriteSite", Storage="_FavoriteSites", ThisKey="UserId", OtherKey="UserId")] - public EntitySet<FavoriteSite> FavoriteSites - { - get + + public event PropertyChangingEventHandler PropertyChanging; + + public event PropertyChangedEventHandler PropertyChanged; + + protected virtual void SendPropertyChanging() { - return this._FavoriteSites; + if ((this.PropertyChanging != null)) + { + this.PropertyChanging(this, emptyChangingEventArgs); + } } - set + + protected virtual void SendPropertyChanged(String propertyName) { - this._FavoriteSites.Assign(value); + if ((this.PropertyChanged != null)) + { + this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName)); + } } - } - - [global::System.Data.Linq.Mapping.AssociationAttribute(Name="User_OAuthToken", Storage="_OAuthTokens", ThisKey="UserId", OtherKey="UserId")] - public EntitySet<OAuthToken> OAuthTokens - { - get + + private void attach_FavoriteSites(FavoriteSite entity) { - return this._OAuthTokens; + this.SendPropertyChanging(); + entity.User = this; } - set + + private void detach_FavoriteSites(FavoriteSite entity) { - this._OAuthTokens.Assign(value); + this.SendPropertyChanging(); + entity.User = null; } - } - - public event PropertyChangingEventHandler PropertyChanging; - - public event PropertyChangedEventHandler PropertyChanged; - - protected virtual void SendPropertyChanging() - { - if ((this.PropertyChanging != null)) + + private void attach_OAuthTokens(OAuthToken entity) { - this.PropertyChanging(this, emptyChangingEventArgs); + this.SendPropertyChanging(); + entity.User = this; } - } - - protected virtual void SendPropertyChanged(String propertyName) - { - if ((this.PropertyChanged != null)) + + private void detach_OAuthTokens(OAuthToken entity) { - this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName)); + this.SendPropertyChanging(); + entity.User = null; } } - private void attach_FavoriteSites(FavoriteSite entity) + [global::System.Data.Linq.Mapping.TableAttribute(Name="dbo.FavoriteSite")] + public partial class FavoriteSite : INotifyPropertyChanging, INotifyPropertyChanged { - this.SendPropertyChanging(); - entity.User = this; - } - - private void detach_FavoriteSites(FavoriteSite entity) - { - this.SendPropertyChanging(); - entity.User = null; - } - - private void attach_OAuthTokens(OAuthToken entity) - { - this.SendPropertyChanging(); - entity.User = this; - } - - private void detach_OAuthTokens(OAuthToken entity) - { - this.SendPropertyChanging(); - entity.User = null; - } -} - -[global::System.Data.Linq.Mapping.TableAttribute(Name="dbo.FavoriteSite")] -public partial class FavoriteSite : INotifyPropertyChanging, INotifyPropertyChanged -{ - - private static PropertyChangingEventArgs emptyChangingEventArgs = new PropertyChangingEventArgs(String.Empty); - - private int _FavoriteSiteId; - - private int _UserId; - - private string _SiteUrl; - - private EntityRef<User> _User; - + + private static PropertyChangingEventArgs emptyChangingEventArgs = new PropertyChangingEventArgs(String.Empty); + + private int _FavoriteSiteId; + + private int _UserId; + + private string _SiteUrl; + + private EntityRef<User> _User; + #region Extensibility Method Definitions partial void OnLoaded(); partial void OnValidate(System.Data.Linq.ChangeAction action); @@ -356,152 +357,152 @@ public partial class FavoriteSite : INotifyPropertyChanging, INotifyPropertyChan partial void OnSiteUrlChanging(string value); partial void OnSiteUrlChanged(); #endregion - - public FavoriteSite() - { - this._User = default(EntityRef<User>); - OnCreated(); - } - - [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_FavoriteSiteId", AutoSync=AutoSync.OnInsert, DbType="Int NOT NULL IDENTITY", IsPrimaryKey=true, IsDbGenerated=true)] - public int FavoriteSiteId - { - get + + public FavoriteSite() { - return this._FavoriteSiteId; + this._User = default(EntityRef<User>); + OnCreated(); } - set + + [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_FavoriteSiteId", AutoSync=AutoSync.OnInsert, DbType="Int NOT NULL IDENTITY", IsPrimaryKey=true, IsDbGenerated=true)] + public int FavoriteSiteId { - if ((this._FavoriteSiteId != value)) + get { - this.OnFavoriteSiteIdChanging(value); - this.SendPropertyChanging(); - this._FavoriteSiteId = value; - this.SendPropertyChanged("FavoriteSiteId"); - this.OnFavoriteSiteIdChanged(); + return this._FavoriteSiteId; } - } - } - - [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_UserId", DbType="Int NOT NULL")] - public int UserId - { - get - { - return this._UserId; - } - set - { - if ((this._UserId != value)) + set { - if (this._User.HasLoadedOrAssignedValue) + if ((this._FavoriteSiteId != value)) { - throw new System.Data.Linq.ForeignKeyReferenceAlreadyHasValueException(); + this.OnFavoriteSiteIdChanging(value); + this.SendPropertyChanging(); + this._FavoriteSiteId = value; + this.SendPropertyChanged("FavoriteSiteId"); + this.OnFavoriteSiteIdChanged(); } - this.OnUserIdChanging(value); - this.SendPropertyChanging(); - this._UserId = value; - this.SendPropertyChanged("UserId"); - this.OnUserIdChanged(); } } - } - - [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_SiteUrl", DbType="NVarChar(255) NOT NULL", CanBeNull=false)] - public string SiteUrl - { - get - { - return this._SiteUrl; - } - set + + [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_UserId", DbType="Int NOT NULL")] + public int UserId { - if ((this._SiteUrl != value)) + get { - this.OnSiteUrlChanging(value); - this.SendPropertyChanging(); - this._SiteUrl = value; - this.SendPropertyChanged("SiteUrl"); - this.OnSiteUrlChanged(); + return this._UserId; } - } - } - - [global::System.Data.Linq.Mapping.AssociationAttribute(Name="User_FavoriteSite", Storage="_User", ThisKey="UserId", OtherKey="UserId", IsForeignKey=true, DeleteOnNull=true, DeleteRule="CASCADE")] - public User User - { - get - { - return this._User.Entity; - } - set - { - User previousValue = this._User.Entity; - if (((previousValue != value) - || (this._User.HasLoadedOrAssignedValue == false))) + set { - this.SendPropertyChanging(); - if ((previousValue != null)) + if ((this._UserId != value)) { - this._User.Entity = null; - previousValue.FavoriteSites.Remove(this); + if (this._User.HasLoadedOrAssignedValue) + { + throw new System.Data.Linq.ForeignKeyReferenceAlreadyHasValueException(); + } + this.OnUserIdChanging(value); + this.SendPropertyChanging(); + this._UserId = value; + this.SendPropertyChanged("UserId"); + this.OnUserIdChanged(); } - this._User.Entity = value; - if ((value != null)) + } + } + + [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_SiteUrl", DbType="NVarChar(255) NOT NULL", CanBeNull=false)] + public string SiteUrl + { + get + { + return this._SiteUrl; + } + set + { + if ((this._SiteUrl != value)) { - value.FavoriteSites.Add(this); - this._UserId = value.UserId; + this.OnSiteUrlChanging(value); + this.SendPropertyChanging(); + this._SiteUrl = value; + this.SendPropertyChanged("SiteUrl"); + this.OnSiteUrlChanged(); } - else + } + } + + [global::System.Data.Linq.Mapping.AssociationAttribute(Name="User_FavoriteSite", Storage="_User", ThisKey="UserId", OtherKey="UserId", IsForeignKey=true, DeleteOnNull=true, DeleteRule="CASCADE")] + public User User + { + get + { + return this._User.Entity; + } + set + { + User previousValue = this._User.Entity; + if (((previousValue != value) + || (this._User.HasLoadedOrAssignedValue == false))) { - this._UserId = default(int); + this.SendPropertyChanging(); + if ((previousValue != null)) + { + this._User.Entity = null; + previousValue.FavoriteSites.Remove(this); + } + this._User.Entity = value; + if ((value != null)) + { + value.FavoriteSites.Add(this); + this._UserId = value.UserId; + } + else + { + this._UserId = default(int); + } + this.SendPropertyChanged("User"); } - this.SendPropertyChanged("User"); } } - } - - public event PropertyChangingEventHandler PropertyChanging; - - public event PropertyChangedEventHandler PropertyChanged; - - protected virtual void SendPropertyChanging() - { - if ((this.PropertyChanging != null)) + + public event PropertyChangingEventHandler PropertyChanging; + + public event PropertyChangedEventHandler PropertyChanged; + + protected virtual void SendPropertyChanging() { - this.PropertyChanging(this, emptyChangingEventArgs); + if ((this.PropertyChanging != null)) + { + this.PropertyChanging(this, emptyChangingEventArgs); + } } - } - - protected virtual void SendPropertyChanged(String propertyName) - { - if ((this.PropertyChanged != null)) + + protected virtual void SendPropertyChanged(String propertyName) { - this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName)); + if ((this.PropertyChanged != null)) + { + this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName)); + } } } -} - -[global::System.Data.Linq.Mapping.TableAttribute(Name="dbo.OAuthConsumer")] -public partial class OAuthConsumer : INotifyPropertyChanging, INotifyPropertyChanged -{ - - private static PropertyChangingEventArgs emptyChangingEventArgs = new PropertyChangingEventArgs(String.Empty); - - private int _ConsumerId; - - private string _ConsumerKey; - - private string _ConsumerSecret; - - private string _Callback; - - private DotNetOpenAuth.OAuth.VerificationCodeFormat _VerificationCodeFormat; - - private int _VerificationCodeLength; - - private EntitySet<OAuthToken> _OAuthTokens; + [global::System.Data.Linq.Mapping.TableAttribute(Name="dbo.OAuthConsumer")] + public partial class OAuthConsumer : INotifyPropertyChanging, INotifyPropertyChanged + { + + private static PropertyChangingEventArgs emptyChangingEventArgs = new PropertyChangingEventArgs(String.Empty); + + private int _ConsumerId; + + private string _ConsumerKey; + + private string _ConsumerSecret; + + private string _Callback; + + private DotNetOpenAuth.OAuth.VerificationCodeFormat _VerificationCodeFormat; + + private int _VerificationCodeLength; + + private EntitySet<OAuthToken> _OAuthTokens; + #region Extensibility Method Definitions partial void OnLoaded(); partial void OnValidate(System.Data.Linq.ChangeAction action); @@ -519,211 +520,211 @@ public partial class OAuthConsumer : INotifyPropertyChanging, INotifyPropertyCha partial void OnVerificationCodeLengthChanging(int value); partial void OnVerificationCodeLengthChanged(); #endregion - - public OAuthConsumer() - { - this._OAuthTokens = new EntitySet<OAuthToken>(new Action<OAuthToken>(this.attach_OAuthTokens), new Action<OAuthToken>(this.detach_OAuthTokens)); - OnCreated(); - } - - [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_ConsumerId", AutoSync=AutoSync.OnInsert, DbType="Int NOT NULL IDENTITY", IsPrimaryKey=true, IsDbGenerated=true)] - public int ConsumerId - { - get + + public OAuthConsumer() { - return this._ConsumerId; + this._OAuthTokens = new EntitySet<OAuthToken>(new Action<OAuthToken>(this.attach_OAuthTokens), new Action<OAuthToken>(this.detach_OAuthTokens)); + OnCreated(); } - set + + [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_ConsumerId", AutoSync=AutoSync.OnInsert, DbType="Int NOT NULL IDENTITY", IsPrimaryKey=true, IsDbGenerated=true)] + public int ConsumerId { - if ((this._ConsumerId != value)) + get { - this.OnConsumerIdChanging(value); - this.SendPropertyChanging(); - this._ConsumerId = value; - this.SendPropertyChanged("ConsumerId"); - this.OnConsumerIdChanged(); + return this._ConsumerId; } - } - } - - [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_ConsumerKey", DbType="NVarChar(50) NOT NULL", CanBeNull=false)] - public string ConsumerKey - { - get - { - return this._ConsumerKey; - } - set - { - if ((this._ConsumerKey != value)) + set { - this.OnConsumerKeyChanging(value); - this.SendPropertyChanging(); - this._ConsumerKey = value; - this.SendPropertyChanged("ConsumerKey"); - this.OnConsumerKeyChanged(); + if ((this._ConsumerId != value)) + { + this.OnConsumerIdChanging(value); + this.SendPropertyChanging(); + this._ConsumerId = value; + this.SendPropertyChanged("ConsumerId"); + this.OnConsumerIdChanged(); + } } } - } - - [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_ConsumerSecret", DbType="NVarChar(50) NOT NULL", CanBeNull=false)] - public string ConsumerSecret - { - get - { - return this._ConsumerSecret; - } - set + + [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_ConsumerKey", DbType="NVarChar(50) NOT NULL", CanBeNull=false)] + public string ConsumerKey { - if ((this._ConsumerSecret != value)) + get { - this.OnConsumerSecretChanging(value); - this.SendPropertyChanging(); - this._ConsumerSecret = value; - this.SendPropertyChanged("ConsumerSecret"); - this.OnConsumerSecretChanged(); + return this._ConsumerKey; } - } - } - - [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_Callback")] - public string Callback - { - get - { - return this._Callback; - } - set - { - if ((this._Callback != value)) + set { - this.OnCallbackChanging(value); - this.SendPropertyChanging(); - this._Callback = value; - this.SendPropertyChanged("Callback"); - this.OnCallbackChanged(); + if ((this._ConsumerKey != value)) + { + this.OnConsumerKeyChanging(value); + this.SendPropertyChanging(); + this._ConsumerKey = value; + this.SendPropertyChanged("ConsumerKey"); + this.OnConsumerKeyChanged(); + } } } - } - - [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_VerificationCodeFormat", CanBeNull=false)] - public DotNetOpenAuth.OAuth.VerificationCodeFormat VerificationCodeFormat - { - get + + [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_ConsumerSecret", DbType="NVarChar(50) NOT NULL", CanBeNull=false)] + public string ConsumerSecret { - return this._VerificationCodeFormat; - } - set - { - if ((this._VerificationCodeFormat != value)) + get + { + return this._ConsumerSecret; + } + set { - this.OnVerificationCodeFormatChanging(value); - this.SendPropertyChanging(); - this._VerificationCodeFormat = value; - this.SendPropertyChanged("VerificationCodeFormat"); - this.OnVerificationCodeFormatChanged(); + if ((this._ConsumerSecret != value)) + { + this.OnConsumerSecretChanging(value); + this.SendPropertyChanging(); + this._ConsumerSecret = value; + this.SendPropertyChanged("ConsumerSecret"); + this.OnConsumerSecretChanged(); + } } } - } - - [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_VerificationCodeLength")] - public int VerificationCodeLength - { - get + + [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_Callback")] + public string Callback { - return this._VerificationCodeLength; + get + { + return this._Callback; + } + set + { + if ((this._Callback != value)) + { + this.OnCallbackChanging(value); + this.SendPropertyChanging(); + this._Callback = value; + this.SendPropertyChanged("Callback"); + this.OnCallbackChanged(); + } + } } - set + + [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_VerificationCodeFormat")] + public DotNetOpenAuth.OAuth.VerificationCodeFormat VerificationCodeFormat { - if ((this._VerificationCodeLength != value)) + get { - this.OnVerificationCodeLengthChanging(value); - this.SendPropertyChanging(); - this._VerificationCodeLength = value; - this.SendPropertyChanged("VerificationCodeLength"); - this.OnVerificationCodeLengthChanged(); + return this._VerificationCodeFormat; + } + set + { + if ((this._VerificationCodeFormat != value)) + { + this.OnVerificationCodeFormatChanging(value); + this.SendPropertyChanging(); + this._VerificationCodeFormat = value; + this.SendPropertyChanged("VerificationCodeFormat"); + this.OnVerificationCodeFormatChanged(); + } } } - } - - [global::System.Data.Linq.Mapping.AssociationAttribute(Name="OAuthConsumer_OAuthToken", Storage="_OAuthTokens", ThisKey="ConsumerId", OtherKey="ConsumerId")] - public EntitySet<OAuthToken> OAuthTokens - { - get + + [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_VerificationCodeLength")] + public int VerificationCodeLength { - return this._OAuthTokens; + get + { + return this._VerificationCodeLength; + } + set + { + if ((this._VerificationCodeLength != value)) + { + this.OnVerificationCodeLengthChanging(value); + this.SendPropertyChanging(); + this._VerificationCodeLength = value; + this.SendPropertyChanged("VerificationCodeLength"); + this.OnVerificationCodeLengthChanged(); + } + } } - set + + [global::System.Data.Linq.Mapping.AssociationAttribute(Name="OAuthConsumer_OAuthToken", Storage="_OAuthTokens", ThisKey="ConsumerId", OtherKey="ConsumerId")] + public EntitySet<OAuthToken> OAuthTokens { - this._OAuthTokens.Assign(value); + get + { + return this._OAuthTokens; + } + set + { + this._OAuthTokens.Assign(value); + } } - } - - public event PropertyChangingEventHandler PropertyChanging; - - public event PropertyChangedEventHandler PropertyChanged; - - protected virtual void SendPropertyChanging() - { - if ((this.PropertyChanging != null)) + + public event PropertyChangingEventHandler PropertyChanging; + + public event PropertyChangedEventHandler PropertyChanged; + + protected virtual void SendPropertyChanging() { - this.PropertyChanging(this, emptyChangingEventArgs); + if ((this.PropertyChanging != null)) + { + this.PropertyChanging(this, emptyChangingEventArgs); + } } - } - - protected virtual void SendPropertyChanged(String propertyName) - { - if ((this.PropertyChanged != null)) + + protected virtual void SendPropertyChanged(String propertyName) { - this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName)); + if ((this.PropertyChanged != null)) + { + this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName)); + } } - } - - private void attach_OAuthTokens(OAuthToken entity) - { - this.SendPropertyChanging(); - entity.OAuthConsumer = this; - } - - private void detach_OAuthTokens(OAuthToken entity) - { - this.SendPropertyChanging(); - entity.OAuthConsumer = null; - } -} - -[global::System.Data.Linq.Mapping.TableAttribute(Name="dbo.OAuthToken")] -public partial class OAuthToken : INotifyPropertyChanging, INotifyPropertyChanged -{ - - private static PropertyChangingEventArgs emptyChangingEventArgs = new PropertyChangingEventArgs(String.Empty); - - private int _TokenId; - - private string _Token; - - private string _TokenSecret; - - private TokenAuthorizationState _State; - - private System.DateTime _IssueDate; - - private int _ConsumerId; - - private System.Nullable<int> _UserId; - - private string _Scope; - - private string _RequestTokenVerifier; - - private string _RequestTokenCallback; - - private string _ConsumerVersion; - - private EntityRef<OAuthConsumer> _OAuthConsumer; - - private EntityRef<User> _User; - + + private void attach_OAuthTokens(OAuthToken entity) + { + this.SendPropertyChanging(); + entity.OAuthConsumer = this; + } + + private void detach_OAuthTokens(OAuthToken entity) + { + this.SendPropertyChanging(); + entity.OAuthConsumer = null; + } + } + + [global::System.Data.Linq.Mapping.TableAttribute(Name="dbo.OAuthToken")] + public partial class OAuthToken : INotifyPropertyChanging, INotifyPropertyChanged + { + + private static PropertyChangingEventArgs emptyChangingEventArgs = new PropertyChangingEventArgs(String.Empty); + + private int _TokenId; + + private string _Token; + + private string _TokenSecret; + + private OAuthServiceProvider.Code.TokenAuthorizationState _State; + + private System.DateTime _IssueDate; + + private int _ConsumerId; + + private System.Nullable<int> _UserId; + + private string _Scope; + + private string _RequestTokenVerifier; + + private string _RequestTokenCallback; + + private string _ConsumerVersion; + + private EntityRef<OAuthConsumer> _OAuthConsumer; + + private EntityRef<User> _User; + #region Extensibility Method Definitions partial void OnLoaded(); partial void OnValidate(System.Data.Linq.ChangeAction action); @@ -734,7 +735,7 @@ public partial class OAuthToken : INotifyPropertyChanging, INotifyPropertyChange partial void OnTokenChanged(); partial void OnTokenSecretChanging(string value); partial void OnTokenSecretChanged(); - partial void OnStateChanging(TokenAuthorizationState value); + partial void OnStateChanging(OAuthServiceProvider.Code.TokenAuthorizationState value); partial void OnStateChanged(); partial void OnIssueDateChanging(System.DateTime value); partial void OnIssueDateChanged(); @@ -751,343 +752,343 @@ public partial class OAuthToken : INotifyPropertyChanging, INotifyPropertyChange partial void OnConsumerVersionChanging(string value); partial void OnConsumerVersionChanged(); #endregion - - public OAuthToken() - { - this._OAuthConsumer = default(EntityRef<OAuthConsumer>); - this._User = default(EntityRef<User>); - OnCreated(); - } - - [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_TokenId", AutoSync=AutoSync.OnInsert, DbType="Int NOT NULL IDENTITY", IsPrimaryKey=true, IsDbGenerated=true)] - public int TokenId - { - get + + public OAuthToken() { - return this._TokenId; + this._OAuthConsumer = default(EntityRef<OAuthConsumer>); + this._User = default(EntityRef<User>); + OnCreated(); } - set + + [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_TokenId", AutoSync=AutoSync.OnInsert, DbType="Int NOT NULL IDENTITY", IsPrimaryKey=true, IsDbGenerated=true)] + public int TokenId { - if ((this._TokenId != value)) + get { - this.OnTokenIdChanging(value); - this.SendPropertyChanging(); - this._TokenId = value; - this.SendPropertyChanged("TokenId"); - this.OnTokenIdChanged(); + return this._TokenId; } - } - } - - [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_Token", DbType="NVarChar(50) NOT NULL", CanBeNull=false)] - public string Token - { - get - { - return this._Token; - } - set - { - if ((this._Token != value)) + set { - this.OnTokenChanging(value); - this.SendPropertyChanging(); - this._Token = value; - this.SendPropertyChanged("Token"); - this.OnTokenChanged(); + if ((this._TokenId != value)) + { + this.OnTokenIdChanging(value); + this.SendPropertyChanging(); + this._TokenId = value; + this.SendPropertyChanged("TokenId"); + this.OnTokenIdChanged(); + } } } - } - - [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_TokenSecret", DbType="NVarChar(50) NOT NULL", CanBeNull=false)] - public string TokenSecret - { - get + + [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_Token", DbType="NVarChar(50) NOT NULL", CanBeNull=false)] + public string Token { - return this._TokenSecret; - } - set - { - if ((this._TokenSecret != value)) + get { - this.OnTokenSecretChanging(value); - this.SendPropertyChanging(); - this._TokenSecret = value; - this.SendPropertyChanged("TokenSecret"); - this.OnTokenSecretChanged(); + return this._Token; } - } - } - - [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_State", DbType="INT NOT NULL", CanBeNull=false)] - public TokenAuthorizationState State - { - get - { - return this._State; - } - set - { - if ((this._State != value)) + set { - this.OnStateChanging(value); - this.SendPropertyChanging(); - this._State = value; - this.SendPropertyChanged("State"); - this.OnStateChanged(); + if ((this._Token != value)) + { + this.OnTokenChanging(value); + this.SendPropertyChanging(); + this._Token = value; + this.SendPropertyChanged("Token"); + this.OnTokenChanged(); + } } } - } - - [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_IssueDate", DbType="DateTime NOT NULL")] - public System.DateTime IssueDate - { - get + + [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_TokenSecret", DbType="NVarChar(50) NOT NULL", CanBeNull=false)] + public string TokenSecret { - return this._IssueDate; - } - set - { - if ((this._IssueDate != value)) + get { - this.OnIssueDateChanging(value); - this.SendPropertyChanging(); - this._IssueDate = value; - this.SendPropertyChanged("IssueDate"); - this.OnIssueDateChanged(); + return this._TokenSecret; } - } - } - - [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_ConsumerId", DbType="Int NOT NULL")] - public int ConsumerId - { - get - { - return this._ConsumerId; - } - set - { - if ((this._ConsumerId != value)) + set { - if (this._OAuthConsumer.HasLoadedOrAssignedValue) + if ((this._TokenSecret != value)) { - throw new System.Data.Linq.ForeignKeyReferenceAlreadyHasValueException(); + this.OnTokenSecretChanging(value); + this.SendPropertyChanging(); + this._TokenSecret = value; + this.SendPropertyChanged("TokenSecret"); + this.OnTokenSecretChanged(); } - this.OnConsumerIdChanging(value); - this.SendPropertyChanging(); - this._ConsumerId = value; - this.SendPropertyChanged("ConsumerId"); - this.OnConsumerIdChanged(); } } - } - - [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_UserId", DbType="Int")] - public System.Nullable<int> UserId - { - get - { - return this._UserId; - } - set + + [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_State", DbType="INT NOT NULL", CanBeNull=false)] + public OAuthServiceProvider.Code.TokenAuthorizationState State { - if ((this._UserId != value)) + get + { + return this._State; + } + set { - if (this._User.HasLoadedOrAssignedValue) + if ((this._State != value)) { - throw new System.Data.Linq.ForeignKeyReferenceAlreadyHasValueException(); + this.OnStateChanging(value); + this.SendPropertyChanging(); + this._State = value; + this.SendPropertyChanged("State"); + this.OnStateChanged(); } - this.OnUserIdChanging(value); - this.SendPropertyChanging(); - this._UserId = value; - this.SendPropertyChanged("UserId"); - this.OnUserIdChanged(); } } - } - - [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_Scope", DbType="nvarchar(MAX)", CanBeNull=false)] - public string Scope - { - get + + [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_IssueDate", DbType="DateTime NOT NULL")] + public System.DateTime IssueDate { - return this._Scope; - } - set - { - if ((this._Scope != value)) + get { - this.OnScopeChanging(value); - this.SendPropertyChanging(); - this._Scope = value; - this.SendPropertyChanged("Scope"); - this.OnScopeChanged(); + return this._IssueDate; } - } - } - - [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_RequestTokenVerifier")] - public string RequestTokenVerifier - { - get - { - return this._RequestTokenVerifier; - } - set - { - if ((this._RequestTokenVerifier != value)) + set { - this.OnRequestTokenVerifierChanging(value); - this.SendPropertyChanging(); - this._RequestTokenVerifier = value; - this.SendPropertyChanged("RequestTokenVerifier"); - this.OnRequestTokenVerifierChanged(); + if ((this._IssueDate != value)) + { + this.OnIssueDateChanging(value); + this.SendPropertyChanging(); + this._IssueDate = value; + this.SendPropertyChanged("IssueDate"); + this.OnIssueDateChanged(); + } } } - } - - [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_RequestTokenCallback")] - public string RequestTokenCallback - { - get - { - return this._RequestTokenCallback; - } - set + + [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_ConsumerId", DbType="Int NOT NULL")] + public int ConsumerId { - if ((this._RequestTokenCallback != value)) + get { - this.OnRequestTokenCallbackChanging(value); - this.SendPropertyChanging(); - this._RequestTokenCallback = value; - this.SendPropertyChanged("RequestTokenCallback"); - this.OnRequestTokenCallbackChanged(); + return this._ConsumerId; } - } - } - - [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_ConsumerVersion")] - public string ConsumerVersion - { - get - { - return this._ConsumerVersion; - } - set - { - if ((this._ConsumerVersion != value)) + set { - this.OnConsumerVersionChanging(value); - this.SendPropertyChanging(); - this._ConsumerVersion = value; - this.SendPropertyChanged("ConsumerVersion"); - this.OnConsumerVersionChanged(); + if ((this._ConsumerId != value)) + { + if (this._OAuthConsumer.HasLoadedOrAssignedValue) + { + throw new System.Data.Linq.ForeignKeyReferenceAlreadyHasValueException(); + } + this.OnConsumerIdChanging(value); + this.SendPropertyChanging(); + this._ConsumerId = value; + this.SendPropertyChanged("ConsumerId"); + this.OnConsumerIdChanged(); + } } } - } - - [global::System.Data.Linq.Mapping.AssociationAttribute(Name="OAuthConsumer_OAuthToken", Storage="_OAuthConsumer", ThisKey="ConsumerId", OtherKey="ConsumerId", IsForeignKey=true, DeleteOnNull=true, DeleteRule="CASCADE")] - public OAuthConsumer OAuthConsumer - { - get + + [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_UserId", DbType="Int")] + public System.Nullable<int> UserId { - return this._OAuthConsumer.Entity; - } - set - { - OAuthConsumer previousValue = this._OAuthConsumer.Entity; - if (((previousValue != value) - || (this._OAuthConsumer.HasLoadedOrAssignedValue == false))) + get + { + return this._UserId; + } + set { - this.SendPropertyChanging(); - if ((previousValue != null)) + if ((this._UserId != value)) { - this._OAuthConsumer.Entity = null; - previousValue.OAuthTokens.Remove(this); + if (this._User.HasLoadedOrAssignedValue) + { + throw new System.Data.Linq.ForeignKeyReferenceAlreadyHasValueException(); + } + this.OnUserIdChanging(value); + this.SendPropertyChanging(); + this._UserId = value; + this.SendPropertyChanged("UserId"); + this.OnUserIdChanged(); } - this._OAuthConsumer.Entity = value; - if ((value != null)) + } + } + + [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_Scope", DbType="nvarchar(MAX)", CanBeNull=false)] + public string Scope + { + get + { + return this._Scope; + } + set + { + if ((this._Scope != value)) { - value.OAuthTokens.Add(this); - this._ConsumerId = value.ConsumerId; + this.OnScopeChanging(value); + this.SendPropertyChanging(); + this._Scope = value; + this.SendPropertyChanged("Scope"); + this.OnScopeChanged(); } - else + } + } + + [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_RequestTokenVerifier")] + public string RequestTokenVerifier + { + get + { + return this._RequestTokenVerifier; + } + set + { + if ((this._RequestTokenVerifier != value)) { - this._ConsumerId = default(int); + this.OnRequestTokenVerifierChanging(value); + this.SendPropertyChanging(); + this._RequestTokenVerifier = value; + this.SendPropertyChanged("RequestTokenVerifier"); + this.OnRequestTokenVerifierChanged(); } - this.SendPropertyChanged("OAuthConsumer"); } } - } - - [global::System.Data.Linq.Mapping.AssociationAttribute(Name="User_OAuthToken", Storage="_User", ThisKey="UserId", OtherKey="UserId", IsForeignKey=true, DeleteRule="CASCADE")] - public User User - { - get + + [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_RequestTokenCallback")] + public string RequestTokenCallback { - return this._User.Entity; + get + { + return this._RequestTokenCallback; + } + set + { + if ((this._RequestTokenCallback != value)) + { + this.OnRequestTokenCallbackChanging(value); + this.SendPropertyChanging(); + this._RequestTokenCallback = value; + this.SendPropertyChanged("RequestTokenCallback"); + this.OnRequestTokenCallbackChanged(); + } + } } - set + + [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_ConsumerVersion")] + public string ConsumerVersion { - User previousValue = this._User.Entity; - if (((previousValue != value) - || (this._User.HasLoadedOrAssignedValue == false))) + get + { + return this._ConsumerVersion; + } + set { - this.SendPropertyChanging(); - if ((previousValue != null)) + if ((this._ConsumerVersion != value)) { - this._User.Entity = null; - previousValue.OAuthTokens.Remove(this); + this.OnConsumerVersionChanging(value); + this.SendPropertyChanging(); + this._ConsumerVersion = value; + this.SendPropertyChanged("ConsumerVersion"); + this.OnConsumerVersionChanged(); } - this._User.Entity = value; - if ((value != null)) + } + } + + [global::System.Data.Linq.Mapping.AssociationAttribute(Name="OAuthConsumer_OAuthToken", Storage="_OAuthConsumer", ThisKey="ConsumerId", OtherKey="ConsumerId", IsForeignKey=true, DeleteOnNull=true, DeleteRule="CASCADE")] + public OAuthConsumer OAuthConsumer + { + get + { + return this._OAuthConsumer.Entity; + } + set + { + OAuthConsumer previousValue = this._OAuthConsumer.Entity; + if (((previousValue != value) + || (this._OAuthConsumer.HasLoadedOrAssignedValue == false))) { - value.OAuthTokens.Add(this); - this._UserId = value.UserId; + this.SendPropertyChanging(); + if ((previousValue != null)) + { + this._OAuthConsumer.Entity = null; + previousValue.OAuthTokens.Remove(this); + } + this._OAuthConsumer.Entity = value; + if ((value != null)) + { + value.OAuthTokens.Add(this); + this._ConsumerId = value.ConsumerId; + } + else + { + this._ConsumerId = default(int); + } + this.SendPropertyChanged("OAuthConsumer"); } - else + } + } + + [global::System.Data.Linq.Mapping.AssociationAttribute(Name="User_OAuthToken", Storage="_User", ThisKey="UserId", OtherKey="UserId", IsForeignKey=true, DeleteRule="CASCADE")] + public User User + { + get + { + return this._User.Entity; + } + set + { + User previousValue = this._User.Entity; + if (((previousValue != value) + || (this._User.HasLoadedOrAssignedValue == false))) { - this._UserId = default(Nullable<int>); + this.SendPropertyChanging(); + if ((previousValue != null)) + { + this._User.Entity = null; + previousValue.OAuthTokens.Remove(this); + } + this._User.Entity = value; + if ((value != null)) + { + value.OAuthTokens.Add(this); + this._UserId = value.UserId; + } + else + { + this._UserId = default(Nullable<int>); + } + this.SendPropertyChanged("User"); } - this.SendPropertyChanged("User"); } } - } - - public event PropertyChangingEventHandler PropertyChanging; - - public event PropertyChangedEventHandler PropertyChanged; - - protected virtual void SendPropertyChanging() - { - if ((this.PropertyChanging != null)) + + public event PropertyChangingEventHandler PropertyChanging; + + public event PropertyChangedEventHandler PropertyChanged; + + protected virtual void SendPropertyChanging() { - this.PropertyChanging(this, emptyChangingEventArgs); + if ((this.PropertyChanging != null)) + { + this.PropertyChanging(this, emptyChangingEventArgs); + } } - } - - protected virtual void SendPropertyChanged(String propertyName) - { - if ((this.PropertyChanged != null)) + + protected virtual void SendPropertyChanged(String propertyName) { - this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName)); + if ((this.PropertyChanged != null)) + { + this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName)); + } } } -} - -[global::System.Data.Linq.Mapping.TableAttribute(Name="")] -public partial class Nonce : INotifyPropertyChanging, INotifyPropertyChanged -{ - - private static PropertyChangingEventArgs emptyChangingEventArgs = new PropertyChangingEventArgs(String.Empty); - - private string _Context; - - private string _Code; - - private System.DateTime _Timestamp; + [global::System.Data.Linq.Mapping.TableAttribute(Name="")] + public partial class Nonce : INotifyPropertyChanging, INotifyPropertyChanged + { + + private static PropertyChangingEventArgs emptyChangingEventArgs = new PropertyChangingEventArgs(String.Empty); + + private string _Context; + + private string _Code; + + private System.DateTime _Timestamp; + #region Extensibility Method Definitions partial void OnLoaded(); partial void OnValidate(System.Data.Linq.ChangeAction action); @@ -1099,89 +1100,90 @@ public partial class Nonce : INotifyPropertyChanging, INotifyPropertyChanged partial void OnTimestampChanging(System.DateTime value); partial void OnTimestampChanged(); #endregion - - public Nonce() - { - OnCreated(); - } - - [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_Context", CanBeNull=false, IsPrimaryKey=true)] - public string Context - { - get + + public Nonce() { - return this._Context; + OnCreated(); } - set + + [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_Context", CanBeNull=false, IsPrimaryKey=true)] + public string Context { - if ((this._Context != value)) + get { - this.OnContextChanging(value); - this.SendPropertyChanging(); - this._Context = value; - this.SendPropertyChanged("Context"); - this.OnContextChanged(); + return this._Context; } - } - } - - [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_Code", CanBeNull=false, IsPrimaryKey=true)] - public string Code - { - get - { - return this._Code; - } - set - { - if ((this._Code != value)) + set { - this.OnCodeChanging(value); - this.SendPropertyChanging(); - this._Code = value; - this.SendPropertyChanged("Code"); - this.OnCodeChanged(); + if ((this._Context != value)) + { + this.OnContextChanging(value); + this.SendPropertyChanging(); + this._Context = value; + this.SendPropertyChanged("Context"); + this.OnContextChanged(); + } } } - } - - [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_Timestamp", IsPrimaryKey=true)] - public System.DateTime Timestamp - { - get + + [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_Code", CanBeNull=false, IsPrimaryKey=true)] + public string Code { - return this._Timestamp; + get + { + return this._Code; + } + set + { + if ((this._Code != value)) + { + this.OnCodeChanging(value); + this.SendPropertyChanging(); + this._Code = value; + this.SendPropertyChanged("Code"); + this.OnCodeChanged(); + } + } } - set + + [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_Timestamp", IsPrimaryKey=true)] + public System.DateTime Timestamp { - if ((this._Timestamp != value)) + get + { + return this._Timestamp; + } + set { - this.OnTimestampChanging(value); - this.SendPropertyChanging(); - this._Timestamp = value; - this.SendPropertyChanged("Timestamp"); - this.OnTimestampChanged(); + if ((this._Timestamp != value)) + { + this.OnTimestampChanging(value); + this.SendPropertyChanging(); + this._Timestamp = value; + this.SendPropertyChanged("Timestamp"); + this.OnTimestampChanged(); + } } } - } - - public event PropertyChangingEventHandler PropertyChanging; - - public event PropertyChangedEventHandler PropertyChanged; - - protected virtual void SendPropertyChanging() - { - if ((this.PropertyChanging != null)) + + public event PropertyChangingEventHandler PropertyChanging; + + public event PropertyChangedEventHandler PropertyChanged; + + protected virtual void SendPropertyChanging() { - this.PropertyChanging(this, emptyChangingEventArgs); + if ((this.PropertyChanging != null)) + { + this.PropertyChanging(this, emptyChangingEventArgs); + } } - } - - protected virtual void SendPropertyChanged(String propertyName) - { - if ((this.PropertyChanged != null)) + + protected virtual void SendPropertyChanged(String propertyName) { - this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName)); + if ((this.PropertyChanged != null)) + { + this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName)); + } } } } diff --git a/samples/OAuthServiceProvider/Code/DataClasses1.designer.cs b/samples/OAuthServiceProvider/Code/DataClasses1.designer.cs deleted file mode 100644 index ee4ad87..0000000 --- a/samples/OAuthServiceProvider/Code/DataClasses1.designer.cs +++ /dev/null @@ -1,1069 +0,0 @@ -#pragma warning disable 1591 -//------------------------------------------------------------------------------ -// <auto-generated> -// This code was generated by a tool. -// Runtime Version:4.0.30319.1 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// </auto-generated> -//------------------------------------------------------------------------------ - -namespace OAuthServiceProvider.Code -{ - using System.Data.Linq; - using System.Data.Linq.Mapping; - using System.Data; - using System.Collections.Generic; - using System.Reflection; - using System.Linq; - using System.Linq.Expressions; - using System.ComponentModel; - using System; - - - [global::System.Data.Linq.Mapping.DatabaseAttribute(Name="Database")] - public partial class DataClassesDataContext : System.Data.Linq.DataContext - { - - private static System.Data.Linq.Mapping.MappingSource mappingSource = new AttributeMappingSource(); - - #region Extensibility Method Definitions - partial void OnCreated(); - partial void InsertUser(User instance); - partial void UpdateUser(User instance); - partial void DeleteUser(User instance); - partial void InsertFavoriteSite(FavoriteSite instance); - partial void UpdateFavoriteSite(FavoriteSite instance); - partial void DeleteFavoriteSite(FavoriteSite instance); - partial void InsertOAuthConsumer(OAuthConsumer instance); - partial void UpdateOAuthConsumer(OAuthConsumer instance); - partial void DeleteOAuthConsumer(OAuthConsumer instance); - partial void InsertOAuthToken(OAuthToken instance); - partial void UpdateOAuthToken(OAuthToken instance); - partial void DeleteOAuthToken(OAuthToken instance); - #endregion - - public DataClassesDataContext() : - base(global::System.Configuration.ConfigurationManager.ConnectionStrings["DatabaseConnectionString"].ConnectionString, mappingSource) - { - OnCreated(); - } - - public DataClassesDataContext(string connection) : - base(connection, mappingSource) - { - OnCreated(); - } - - public DataClassesDataContext(System.Data.IDbConnection connection) : - base(connection, mappingSource) - { - OnCreated(); - } - - public DataClassesDataContext(string connection, System.Data.Linq.Mapping.MappingSource mappingSource) : - base(connection, mappingSource) - { - OnCreated(); - } - - public DataClassesDataContext(System.Data.IDbConnection connection, System.Data.Linq.Mapping.MappingSource mappingSource) : - base(connection, mappingSource) - { - OnCreated(); - } - - public System.Data.Linq.Table<User> Users - { - get - { - return this.GetTable<User>(); - } - } - - public System.Data.Linq.Table<FavoriteSite> FavoriteSites - { - get - { - return this.GetTable<FavoriteSite>(); - } - } - - public System.Data.Linq.Table<OAuthConsumer> OAuthConsumers - { - get - { - return this.GetTable<OAuthConsumer>(); - } - } - - public System.Data.Linq.Table<OAuthToken> OAuthTokens - { - get - { - return this.GetTable<OAuthToken>(); - } - } - } - - [global::System.Data.Linq.Mapping.TableAttribute(Name="dbo.[User]")] - public partial class User : INotifyPropertyChanging, INotifyPropertyChanged - { - - private static PropertyChangingEventArgs emptyChangingEventArgs = new PropertyChangingEventArgs(String.Empty); - - private int _UserId; - - private string _OpenIDClaimedIdentifier; - - private string _OpenIDFriendlyIdentifier; - - private string _FullName; - - private System.Nullable<int> _Age; - - private EntitySet<FavoriteSite> _FavoriteSites; - - private EntitySet<OAuthToken> _OAuthTokens; - - #region Extensibility Method Definitions - partial void OnLoaded(); - partial void OnValidate(System.Data.Linq.ChangeAction action); - partial void OnCreated(); - partial void OnUserIdChanging(int value); - partial void OnUserIdChanged(); - partial void OnOpenIDClaimedIdentifierChanging(string value); - partial void OnOpenIDClaimedIdentifierChanged(); - partial void OnOpenIDFriendlyIdentifierChanging(string value); - partial void OnOpenIDFriendlyIdentifierChanged(); - partial void OnFullNameChanging(string value); - partial void OnFullNameChanged(); - partial void OnAgeChanging(System.Nullable<int> value); - partial void OnAgeChanged(); - #endregion - - public User() - { - this._FavoriteSites = new EntitySet<FavoriteSite>(new Action<FavoriteSite>(this.attach_FavoriteSites), new Action<FavoriteSite>(this.detach_FavoriteSites)); - this._OAuthTokens = new EntitySet<OAuthToken>(new Action<OAuthToken>(this.attach_OAuthTokens), new Action<OAuthToken>(this.detach_OAuthTokens)); - OnCreated(); - } - - [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_UserId", AutoSync=AutoSync.OnInsert, DbType="Int NOT NULL IDENTITY", IsPrimaryKey=true, IsDbGenerated=true)] - public int UserId - { - get - { - return this._UserId; - } - set - { - if ((this._UserId != value)) - { - this.OnUserIdChanging(value); - this.SendPropertyChanging(); - this._UserId = value; - this.SendPropertyChanged("UserId"); - this.OnUserIdChanged(); - } - } - } - - [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_OpenIDClaimedIdentifier", DbType="NVarChar(150) NOT NULL", CanBeNull=false)] - public string OpenIDClaimedIdentifier - { - get - { - return this._OpenIDClaimedIdentifier; - } - set - { - if ((this._OpenIDClaimedIdentifier != value)) - { - this.OnOpenIDClaimedIdentifierChanging(value); - this.SendPropertyChanging(); - this._OpenIDClaimedIdentifier = value; - this.SendPropertyChanged("OpenIDClaimedIdentifier"); - this.OnOpenIDClaimedIdentifierChanged(); - } - } - } - - [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_OpenIDFriendlyIdentifier", DbType="NVarChar(150)")] - public string OpenIDFriendlyIdentifier - { - get - { - return this._OpenIDFriendlyIdentifier; - } - set - { - if ((this._OpenIDFriendlyIdentifier != value)) - { - this.OnOpenIDFriendlyIdentifierChanging(value); - this.SendPropertyChanging(); - this._OpenIDFriendlyIdentifier = value; - this.SendPropertyChanged("OpenIDFriendlyIdentifier"); - this.OnOpenIDFriendlyIdentifierChanged(); - } - } - } - - [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_FullName", DbType="NVarChar(150)", CanBeNull=false)] - public string FullName - { - get - { - return this._FullName; - } - set - { - if ((this._FullName != value)) - { - this.OnFullNameChanging(value); - this.SendPropertyChanging(); - this._FullName = value; - this.SendPropertyChanged("FullName"); - this.OnFullNameChanged(); - } - } - } - - [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_Age", DbType="int")] - public System.Nullable<int> Age - { - get - { - return this._Age; - } - set - { - if ((this._Age != value)) - { - this.OnAgeChanging(value); - this.SendPropertyChanging(); - this._Age = value; - this.SendPropertyChanged("Age"); - this.OnAgeChanged(); - } - } - } - - [global::System.Data.Linq.Mapping.AssociationAttribute(Name="User_FavoriteSite", Storage="_FavoriteSites", ThisKey="UserId", OtherKey="UserId")] - public EntitySet<FavoriteSite> FavoriteSites - { - get - { - return this._FavoriteSites; - } - set - { - this._FavoriteSites.Assign(value); - } - } - - [global::System.Data.Linq.Mapping.AssociationAttribute(Name="User_OAuthToken", Storage="_OAuthTokens", ThisKey="UserId", OtherKey="UserId")] - public EntitySet<OAuthToken> OAuthTokens - { - get - { - return this._OAuthTokens; - } - set - { - this._OAuthTokens.Assign(value); - } - } - - public event PropertyChangingEventHandler PropertyChanging; - - public event PropertyChangedEventHandler PropertyChanged; - - protected virtual void SendPropertyChanging() - { - if ((this.PropertyChanging != null)) - { - this.PropertyChanging(this, emptyChangingEventArgs); - } - } - - protected virtual void SendPropertyChanged(String propertyName) - { - if ((this.PropertyChanged != null)) - { - this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName)); - } - } - - private void attach_FavoriteSites(FavoriteSite entity) - { - this.SendPropertyChanging(); - entity.User = this; - } - - private void detach_FavoriteSites(FavoriteSite entity) - { - this.SendPropertyChanging(); - entity.User = null; - } - - private void attach_OAuthTokens(OAuthToken entity) - { - this.SendPropertyChanging(); - entity.User = this; - } - - private void detach_OAuthTokens(OAuthToken entity) - { - this.SendPropertyChanging(); - entity.User = null; - } - } - - [global::System.Data.Linq.Mapping.TableAttribute(Name="dbo.FavoriteSite")] - public partial class FavoriteSite : INotifyPropertyChanging, INotifyPropertyChanged - { - - private static PropertyChangingEventArgs emptyChangingEventArgs = new PropertyChangingEventArgs(String.Empty); - - private int _FavoriteSiteId; - - private int _UserId; - - private string _SiteUrl; - - private EntityRef<User> _User; - - #region Extensibility Method Definitions - partial void OnLoaded(); - partial void OnValidate(System.Data.Linq.ChangeAction action); - partial void OnCreated(); - partial void OnFavoriteSiteIdChanging(int value); - partial void OnFavoriteSiteIdChanged(); - partial void OnUserIdChanging(int value); - partial void OnUserIdChanged(); - partial void OnSiteUrlChanging(string value); - partial void OnSiteUrlChanged(); - #endregion - - public FavoriteSite() - { - this._User = default(EntityRef<User>); - OnCreated(); - } - - [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_FavoriteSiteId", AutoSync=AutoSync.OnInsert, DbType="Int NOT NULL IDENTITY", IsPrimaryKey=true, IsDbGenerated=true)] - public int FavoriteSiteId - { - get - { - return this._FavoriteSiteId; - } - set - { - if ((this._FavoriteSiteId != value)) - { - this.OnFavoriteSiteIdChanging(value); - this.SendPropertyChanging(); - this._FavoriteSiteId = value; - this.SendPropertyChanged("FavoriteSiteId"); - this.OnFavoriteSiteIdChanged(); - } - } - } - - [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_UserId", DbType="Int NOT NULL")] - public int UserId - { - get - { - return this._UserId; - } - set - { - if ((this._UserId != value)) - { - if (this._User.HasLoadedOrAssignedValue) - { - throw new System.Data.Linq.ForeignKeyReferenceAlreadyHasValueException(); - } - this.OnUserIdChanging(value); - this.SendPropertyChanging(); - this._UserId = value; - this.SendPropertyChanged("UserId"); - this.OnUserIdChanged(); - } - } - } - - [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_SiteUrl", DbType="NVarChar(255) NOT NULL", CanBeNull=false)] - public string SiteUrl - { - get - { - return this._SiteUrl; - } - set - { - if ((this._SiteUrl != value)) - { - this.OnSiteUrlChanging(value); - this.SendPropertyChanging(); - this._SiteUrl = value; - this.SendPropertyChanged("SiteUrl"); - this.OnSiteUrlChanged(); - } - } - } - - [global::System.Data.Linq.Mapping.AssociationAttribute(Name="User_FavoriteSite", Storage="_User", ThisKey="UserId", OtherKey="UserId", IsForeignKey=true, DeleteOnNull=true, DeleteRule="CASCADE")] - public User User - { - get - { - return this._User.Entity; - } - set - { - User previousValue = this._User.Entity; - if (((previousValue != value) - || (this._User.HasLoadedOrAssignedValue == false))) - { - this.SendPropertyChanging(); - if ((previousValue != null)) - { - this._User.Entity = null; - previousValue.FavoriteSites.Remove(this); - } - this._User.Entity = value; - if ((value != null)) - { - value.FavoriteSites.Add(this); - this._UserId = value.UserId; - } - else - { - this._UserId = default(int); - } - this.SendPropertyChanged("User"); - } - } - } - - public event PropertyChangingEventHandler PropertyChanging; - - public event PropertyChangedEventHandler PropertyChanged; - - protected virtual void SendPropertyChanging() - { - if ((this.PropertyChanging != null)) - { - this.PropertyChanging(this, emptyChangingEventArgs); - } - } - - protected virtual void SendPropertyChanged(String propertyName) - { - if ((this.PropertyChanged != null)) - { - this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName)); - } - } - } - - [global::System.Data.Linq.Mapping.TableAttribute(Name="dbo.OAuthConsumer")] - public partial class OAuthConsumer : INotifyPropertyChanging, INotifyPropertyChanged - { - - private static PropertyChangingEventArgs emptyChangingEventArgs = new PropertyChangingEventArgs(String.Empty); - - private int _ConsumerId; - - private string _ConsumerKey; - - private string _ConsumerSecret; - - private string _Callback; - - private DotNetOpenAuth.OAuth.VerificationCodeFormat _VerificationCodeFormat; - - private int _VerificationCodeLength; - - private EntitySet<OAuthToken> _OAuthTokens; - - #region Extensibility Method Definitions - partial void OnLoaded(); - partial void OnValidate(System.Data.Linq.ChangeAction action); - partial void OnCreated(); - partial void OnConsumerIdChanging(int value); - partial void OnConsumerIdChanged(); - partial void OnConsumerKeyChanging(string value); - partial void OnConsumerKeyChanged(); - partial void OnConsumerSecretChanging(string value); - partial void OnConsumerSecretChanged(); - partial void OnCallbackChanging(string value); - partial void OnCallbackChanged(); - partial void OnVerificationCodeFormatChanging(DotNetOpenAuth.OAuth.VerificationCodeFormat value); - partial void OnVerificationCodeFormatChanged(); - partial void OnVerificationCodeLengthChanging(int value); - partial void OnVerificationCodeLengthChanged(); - #endregion - - public OAuthConsumer() - { - this._OAuthTokens = new EntitySet<OAuthToken>(new Action<OAuthToken>(this.attach_OAuthTokens), new Action<OAuthToken>(this.detach_OAuthTokens)); - OnCreated(); - } - - [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_ConsumerId", AutoSync=AutoSync.OnInsert, DbType="Int NOT NULL IDENTITY", IsPrimaryKey=true, IsDbGenerated=true)] - public int ConsumerId - { - get - { - return this._ConsumerId; - } - set - { - if ((this._ConsumerId != value)) - { - this.OnConsumerIdChanging(value); - this.SendPropertyChanging(); - this._ConsumerId = value; - this.SendPropertyChanged("ConsumerId"); - this.OnConsumerIdChanged(); - } - } - } - - [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_ConsumerKey", DbType="NVarChar(50) NOT NULL", CanBeNull=false)] - public string ConsumerKey - { - get - { - return this._ConsumerKey; - } - set - { - if ((this._ConsumerKey != value)) - { - this.OnConsumerKeyChanging(value); - this.SendPropertyChanging(); - this._ConsumerKey = value; - this.SendPropertyChanged("ConsumerKey"); - this.OnConsumerKeyChanged(); - } - } - } - - [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_ConsumerSecret", DbType="NVarChar(50) NOT NULL", CanBeNull=false)] - public string ConsumerSecret - { - get - { - return this._ConsumerSecret; - } - set - { - if ((this._ConsumerSecret != value)) - { - this.OnConsumerSecretChanging(value); - this.SendPropertyChanging(); - this._ConsumerSecret = value; - this.SendPropertyChanged("ConsumerSecret"); - this.OnConsumerSecretChanged(); - } - } - } - - [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_Callback")] - public string Callback - { - get - { - return this._Callback; - } - set - { - if ((this._Callback != value)) - { - this.OnCallbackChanging(value); - this.SendPropertyChanging(); - this._Callback = value; - this.SendPropertyChanged("Callback"); - this.OnCallbackChanged(); - } - } - } - - [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_VerificationCodeFormat", CanBeNull=false)] - public DotNetOpenAuth.OAuth.VerificationCodeFormat VerificationCodeFormat - { - get - { - return this._VerificationCodeFormat; - } - set - { - if ((this._VerificationCodeFormat != value)) - { - this.OnVerificationCodeFormatChanging(value); - this.SendPropertyChanging(); - this._VerificationCodeFormat = value; - this.SendPropertyChanged("VerificationCodeFormat"); - this.OnVerificationCodeFormatChanged(); - } - } - } - - [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_VerificationCodeLength")] - public int VerificationCodeLength - { - get - { - return this._VerificationCodeLength; - } - set - { - if ((this._VerificationCodeLength != value)) - { - this.OnVerificationCodeLengthChanging(value); - this.SendPropertyChanging(); - this._VerificationCodeLength = value; - this.SendPropertyChanged("VerificationCodeLength"); - this.OnVerificationCodeLengthChanged(); - } - } - } - - [global::System.Data.Linq.Mapping.AssociationAttribute(Name="OAuthConsumer_OAuthToken", Storage="_OAuthTokens", ThisKey="ConsumerId", OtherKey="ConsumerId")] - public EntitySet<OAuthToken> OAuthTokens - { - get - { - return this._OAuthTokens; - } - set - { - this._OAuthTokens.Assign(value); - } - } - - public event PropertyChangingEventHandler PropertyChanging; - - public event PropertyChangedEventHandler PropertyChanged; - - protected virtual void SendPropertyChanging() - { - if ((this.PropertyChanging != null)) - { - this.PropertyChanging(this, emptyChangingEventArgs); - } - } - - protected virtual void SendPropertyChanged(String propertyName) - { - if ((this.PropertyChanged != null)) - { - this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName)); - } - } - - private void attach_OAuthTokens(OAuthToken entity) - { - this.SendPropertyChanging(); - entity.OAuthConsumer = this; - } - - private void detach_OAuthTokens(OAuthToken entity) - { - this.SendPropertyChanging(); - entity.OAuthConsumer = null; - } - } - - [global::System.Data.Linq.Mapping.TableAttribute(Name="dbo.OAuthToken")] - public partial class OAuthToken : INotifyPropertyChanging, INotifyPropertyChanged - { - - private static PropertyChangingEventArgs emptyChangingEventArgs = new PropertyChangingEventArgs(String.Empty); - - private int _TokenId; - - private string _Token; - - private string _TokenSecret; - - private TokenAuthorizationState _State; - - private System.DateTime _IssueDate; - - private int _ConsumerId; - - private System.Nullable<int> _UserId; - - private string _Scope; - - private string _RequestTokenVerifier; - - private string _RequestTokenCallback; - - private string _ConsumerVersion; - - private EntityRef<OAuthConsumer> _OAuthConsumer; - - private EntityRef<User> _User; - - #region Extensibility Method Definitions - partial void OnLoaded(); - partial void OnValidate(System.Data.Linq.ChangeAction action); - partial void OnCreated(); - partial void OnTokenIdChanging(int value); - partial void OnTokenIdChanged(); - partial void OnTokenChanging(string value); - partial void OnTokenChanged(); - partial void OnTokenSecretChanging(string value); - partial void OnTokenSecretChanged(); - partial void OnStateChanging(TokenAuthorizationState value); - partial void OnStateChanged(); - partial void OnIssueDateChanging(System.DateTime value); - partial void OnIssueDateChanged(); - partial void OnConsumerIdChanging(int value); - partial void OnConsumerIdChanged(); - partial void OnUserIdChanging(System.Nullable<int> value); - partial void OnUserIdChanged(); - partial void OnScopeChanging(string value); - partial void OnScopeChanged(); - partial void OnRequestTokenVerifierChanging(string value); - partial void OnRequestTokenVerifierChanged(); - partial void OnRequestTokenCallbackChanging(string value); - partial void OnRequestTokenCallbackChanged(); - partial void OnConsumerVersionChanging(string value); - partial void OnConsumerVersionChanged(); - #endregion - - public OAuthToken() - { - this._OAuthConsumer = default(EntityRef<OAuthConsumer>); - this._User = default(EntityRef<User>); - OnCreated(); - } - - [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_TokenId", AutoSync=AutoSync.OnInsert, DbType="Int NOT NULL IDENTITY", IsPrimaryKey=true, IsDbGenerated=true)] - public int TokenId - { - get - { - return this._TokenId; - } - set - { - if ((this._TokenId != value)) - { - this.OnTokenIdChanging(value); - this.SendPropertyChanging(); - this._TokenId = value; - this.SendPropertyChanged("TokenId"); - this.OnTokenIdChanged(); - } - } - } - - [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_Token", DbType="NVarChar(50) NOT NULL", CanBeNull=false)] - public string Token - { - get - { - return this._Token; - } - set - { - if ((this._Token != value)) - { - this.OnTokenChanging(value); - this.SendPropertyChanging(); - this._Token = value; - this.SendPropertyChanged("Token"); - this.OnTokenChanged(); - } - } - } - - [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_TokenSecret", DbType="NVarChar(50) NOT NULL", CanBeNull=false)] - public string TokenSecret - { - get - { - return this._TokenSecret; - } - set - { - if ((this._TokenSecret != value)) - { - this.OnTokenSecretChanging(value); - this.SendPropertyChanging(); - this._TokenSecret = value; - this.SendPropertyChanged("TokenSecret"); - this.OnTokenSecretChanged(); - } - } - } - - [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_State", DbType="INT NOT NULL", CanBeNull=false)] - public TokenAuthorizationState State - { - get - { - return this._State; - } - set - { - if ((this._State != value)) - { - this.OnStateChanging(value); - this.SendPropertyChanging(); - this._State = value; - this.SendPropertyChanged("State"); - this.OnStateChanged(); - } - } - } - - [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_IssueDate", DbType="DateTime NOT NULL")] - public System.DateTime IssueDate - { - get - { - return this._IssueDate; - } - set - { - if ((this._IssueDate != value)) - { - this.OnIssueDateChanging(value); - this.SendPropertyChanging(); - this._IssueDate = value; - this.SendPropertyChanged("IssueDate"); - this.OnIssueDateChanged(); - } - } - } - - [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_ConsumerId", DbType="Int NOT NULL")] - public int ConsumerId - { - get - { - return this._ConsumerId; - } - set - { - if ((this._ConsumerId != value)) - { - if (this._OAuthConsumer.HasLoadedOrAssignedValue) - { - throw new System.Data.Linq.ForeignKeyReferenceAlreadyHasValueException(); - } - this.OnConsumerIdChanging(value); - this.SendPropertyChanging(); - this._ConsumerId = value; - this.SendPropertyChanged("ConsumerId"); - this.OnConsumerIdChanged(); - } - } - } - - [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_UserId", DbType="Int")] - public System.Nullable<int> UserId - { - get - { - return this._UserId; - } - set - { - if ((this._UserId != value)) - { - if (this._User.HasLoadedOrAssignedValue) - { - throw new System.Data.Linq.ForeignKeyReferenceAlreadyHasValueException(); - } - this.OnUserIdChanging(value); - this.SendPropertyChanging(); - this._UserId = value; - this.SendPropertyChanged("UserId"); - this.OnUserIdChanged(); - } - } - } - - [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_Scope", DbType="nvarchar(MAX)", CanBeNull=false)] - public string Scope - { - get - { - return this._Scope; - } - set - { - if ((this._Scope != value)) - { - this.OnScopeChanging(value); - this.SendPropertyChanging(); - this._Scope = value; - this.SendPropertyChanged("Scope"); - this.OnScopeChanged(); - } - } - } - - [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_RequestTokenVerifier")] - public string RequestTokenVerifier - { - get - { - return this._RequestTokenVerifier; - } - set - { - if ((this._RequestTokenVerifier != value)) - { - this.OnRequestTokenVerifierChanging(value); - this.SendPropertyChanging(); - this._RequestTokenVerifier = value; - this.SendPropertyChanged("RequestTokenVerifier"); - this.OnRequestTokenVerifierChanged(); - } - } - } - - [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_RequestTokenCallback")] - public string RequestTokenCallback - { - get - { - return this._RequestTokenCallback; - } - set - { - if ((this._RequestTokenCallback != value)) - { - this.OnRequestTokenCallbackChanging(value); - this.SendPropertyChanging(); - this._RequestTokenCallback = value; - this.SendPropertyChanged("RequestTokenCallback"); - this.OnRequestTokenCallbackChanged(); - } - } - } - - [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_ConsumerVersion")] - public string ConsumerVersion - { - get - { - return this._ConsumerVersion; - } - set - { - if ((this._ConsumerVersion != value)) - { - this.OnConsumerVersionChanging(value); - this.SendPropertyChanging(); - this._ConsumerVersion = value; - this.SendPropertyChanged("ConsumerVersion"); - this.OnConsumerVersionChanged(); - } - } - } - - [global::System.Data.Linq.Mapping.AssociationAttribute(Name="OAuthConsumer_OAuthToken", Storage="_OAuthConsumer", ThisKey="ConsumerId", OtherKey="ConsumerId", IsForeignKey=true, DeleteOnNull=true, DeleteRule="CASCADE")] - public OAuthConsumer OAuthConsumer - { - get - { - return this._OAuthConsumer.Entity; - } - set - { - OAuthConsumer previousValue = this._OAuthConsumer.Entity; - if (((previousValue != value) - || (this._OAuthConsumer.HasLoadedOrAssignedValue == false))) - { - this.SendPropertyChanging(); - if ((previousValue != null)) - { - this._OAuthConsumer.Entity = null; - previousValue.OAuthTokens.Remove(this); - } - this._OAuthConsumer.Entity = value; - if ((value != null)) - { - value.OAuthTokens.Add(this); - this._ConsumerId = value.ConsumerId; - } - else - { - this._ConsumerId = default(int); - } - this.SendPropertyChanged("OAuthConsumer"); - } - } - } - - [global::System.Data.Linq.Mapping.AssociationAttribute(Name="User_OAuthToken", Storage="_User", ThisKey="UserId", OtherKey="UserId", IsForeignKey=true, DeleteRule="CASCADE")] - public User User - { - get - { - return this._User.Entity; - } - set - { - User previousValue = this._User.Entity; - if (((previousValue != value) - || (this._User.HasLoadedOrAssignedValue == false))) - { - this.SendPropertyChanging(); - if ((previousValue != null)) - { - this._User.Entity = null; - previousValue.OAuthTokens.Remove(this); - } - this._User.Entity = value; - if ((value != null)) - { - value.OAuthTokens.Add(this); - this._UserId = value.UserId; - } - else - { - this._UserId = default(Nullable<int>); - } - this.SendPropertyChanged("User"); - } - } - } - - public event PropertyChangingEventHandler PropertyChanging; - - public event PropertyChangedEventHandler PropertyChanged; - - protected virtual void SendPropertyChanging() - { - if ((this.PropertyChanging != null)) - { - this.PropertyChanging(this, emptyChangingEventArgs); - } - } - - protected virtual void SendPropertyChanged(String propertyName) - { - if ((this.PropertyChanged != null)) - { - this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName)); - } - } - } -} -#pragma warning restore 1591 diff --git a/samples/OAuthServiceProvider/Code/DatabaseNonceStore.cs b/samples/OAuthServiceProvider/Code/DatabaseNonceStore.cs index c535fca..1f8f56e 100644 --- a/samples/OAuthServiceProvider/Code/DatabaseNonceStore.cs +++ b/samples/OAuthServiceProvider/Code/DatabaseNonceStore.cs @@ -1,53 +1,55 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Web; -using DotNetOpenAuth.Messaging.Bindings; +namespace OAuthServiceProvider.Code { + using System; + using System.Collections.Generic; + using System.Linq; + using System.Web; + using DotNetOpenAuth.Messaging.Bindings; -/// <summary> -/// A database-persisted nonce store. -/// </summary> -public class DatabaseNonceStore : INonceStore { /// <summary> - /// Initializes a new instance of the <see cref="DatabaseNonceStore"/> class. + /// A database-persisted nonce store. /// </summary> - public DatabaseNonceStore() { - } + public class DatabaseNonceStore : INonceStore { + /// <summary> + /// Initializes a new instance of the <see cref="DatabaseNonceStore"/> class. + /// </summary> + public DatabaseNonceStore() { + } - #region INonceStore Members + #region INonceStore Members - /// <summary> - /// Stores a given nonce and timestamp. - /// </summary> - /// <param name="context">The context, or namespace, within which the - /// <paramref name="nonce"/> must be unique. - /// The context SHOULD be treated as case-sensitive. - /// The value will never be <c>null</c> but may be the empty string.</param> - /// <param name="nonce">A series of random characters.</param> - /// <param name="timestampUtc">The UTC timestamp that together with the nonce string make it unique - /// within the given <paramref name="context"/>. - /// The timestamp may also be used by the data store to clear out old nonces.</param> - /// <returns> - /// True if the context+nonce+timestamp (combination) was not previously in the database. - /// False if the nonce was stored previously with the same timestamp and context. - /// </returns> - /// <remarks> - /// The nonce must be stored for no less than the maximum time window a message may - /// be processed within before being discarded as an expired message. - /// This maximum message age can be looked up via the - /// <see cref="DotNetOpenAuth.Configuration.MessagingElement.MaximumMessageLifetime"/> - /// property, accessible via the <see cref="DotNetOpenAuth.Configuration.DotNetOpenAuthSection.Configuration"/> - /// property. - /// </remarks> - public bool StoreNonce(string context, string nonce, DateTime timestampUtc) { - Global.DataContext.Nonces.InsertOnSubmit(new Nonce { Context = context, Code = nonce, Timestamp = timestampUtc }); - try { - Global.DataContext.SubmitChanges(); - return true; - } catch (System.Data.Linq.DuplicateKeyException) { - return false; + /// <summary> + /// Stores a given nonce and timestamp. + /// </summary> + /// <param name="context">The context, or namespace, within which the + /// <paramref name="nonce"/> must be unique. + /// The context SHOULD be treated as case-sensitive. + /// The value will never be <c>null</c> but may be the empty string.</param> + /// <param name="nonce">A series of random characters.</param> + /// <param name="timestampUtc">The UTC timestamp that together with the nonce string make it unique + /// within the given <paramref name="context"/>. + /// The timestamp may also be used by the data store to clear out old nonces.</param> + /// <returns> + /// True if the context+nonce+timestamp (combination) was not previously in the database. + /// False if the nonce was stored previously with the same timestamp and context. + /// </returns> + /// <remarks> + /// The nonce must be stored for no less than the maximum time window a message may + /// be processed within before being discarded as an expired message. + /// This maximum message age can be looked up via the + /// <see cref="DotNetOpenAuth.Configuration.MessagingElement.MaximumMessageLifetime"/> + /// property, accessible via the <see cref="DotNetOpenAuth.Configuration.DotNetOpenAuthSection.Configuration"/> + /// property. + /// </remarks> + public bool StoreNonce(string context, string nonce, DateTime timestampUtc) { + Global.DataContext.Nonces.InsertOnSubmit(new Nonce { Context = context, Code = nonce, Timestamp = timestampUtc }); + try { + Global.DataContext.SubmitChanges(); + return true; + } catch (System.Data.Linq.DuplicateKeyException) { + return false; + } } - } - #endregion + #endregion + } }
\ No newline at end of file diff --git a/samples/OAuthServiceProvider/Code/DatabaseTokenManager.cs b/samples/OAuthServiceProvider/Code/DatabaseTokenManager.cs index 8c93d2f..721e124 100644 --- a/samples/OAuthServiceProvider/Code/DatabaseTokenManager.cs +++ b/samples/OAuthServiceProvider/Code/DatabaseTokenManager.cs @@ -4,154 +4,156 @@ // </copyright> //----------------------------------------------------------------------- -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.Linq; -using DotNetOpenAuth.OAuth.ChannelElements; -using DotNetOpenAuth.OAuth.Messages; - -public class DatabaseTokenManager : IServiceProviderTokenManager { - #region IServiceProviderTokenManager - - public IConsumerDescription GetConsumer(string consumerKey) { - var consumerRow = Global.DataContext.OAuthConsumers.SingleOrDefault( - consumerCandidate => consumerCandidate.ConsumerKey == consumerKey); - if (consumerRow == null) { - throw new KeyNotFoundException(); +namespace OAuthServiceProvider.Code { + using System; + using System.Collections.Generic; + using System.Diagnostics; + using System.Linq; + using DotNetOpenAuth.OAuth.ChannelElements; + using DotNetOpenAuth.OAuth.Messages; + + public class DatabaseTokenManager : IServiceProviderTokenManager { + #region IServiceProviderTokenManager + + public IConsumerDescription GetConsumer(string consumerKey) { + var consumerRow = Global.DataContext.OAuthConsumers.SingleOrDefault( + consumerCandidate => consumerCandidate.ConsumerKey == consumerKey); + if (consumerRow == null) { + throw new KeyNotFoundException(); + } + + return consumerRow; } - return consumerRow; - } - - public IServiceProviderRequestToken GetRequestToken(string token) { - try { - return Global.DataContext.OAuthTokens.First(t => t.Token == token && t.State != TokenAuthorizationState.AccessToken); - } catch (InvalidOperationException ex) { - throw new KeyNotFoundException("Unrecognized token", ex); + public IServiceProviderRequestToken GetRequestToken(string token) { + try { + return Global.DataContext.OAuthTokens.First(t => t.Token == token && t.State != TokenAuthorizationState.AccessToken); + } catch (InvalidOperationException ex) { + throw new KeyNotFoundException("Unrecognized token", ex); + } } - } - public IServiceProviderAccessToken GetAccessToken(string token) { - try { - return Global.DataContext.OAuthTokens.First(t => t.Token == token && t.State == TokenAuthorizationState.AccessToken); - } catch (InvalidOperationException ex) { - throw new KeyNotFoundException("Unrecognized token", ex); + public IServiceProviderAccessToken GetAccessToken(string token) { + try { + return Global.DataContext.OAuthTokens.First(t => t.Token == token && t.State == TokenAuthorizationState.AccessToken); + } catch (InvalidOperationException ex) { + throw new KeyNotFoundException("Unrecognized token", ex); + } } - } - - public void UpdateToken(IServiceProviderRequestToken token) { - // Nothing to do here, since we're using Linq To SQL. - } - - #endregion - - #region ITokenManager Members - public string GetTokenSecret(string token) { - var tokenRow = Global.DataContext.OAuthTokens.SingleOrDefault( - tokenCandidate => tokenCandidate.Token == token); - if (tokenRow == null) { - throw new ArgumentException(); + public void UpdateToken(IServiceProviderRequestToken token) { + // Nothing to do here, since we're using Linq To SQL. } - return tokenRow.TokenSecret; - } + #endregion - public void StoreNewRequestToken(UnauthorizedTokenRequest request, ITokenSecretContainingMessage response) { - RequestScopedTokenMessage scopedRequest = (RequestScopedTokenMessage)request; - var consumer = Global.DataContext.OAuthConsumers.Single(consumerRow => consumerRow.ConsumerKey == request.ConsumerKey); - string scope = scopedRequest.Scope; - OAuthToken newToken = new OAuthToken { - OAuthConsumer = consumer, - Token = response.Token, - TokenSecret = response.TokenSecret, - IssueDate = DateTime.UtcNow, - Scope = scope, - }; - - Global.DataContext.OAuthTokens.InsertOnSubmit(newToken); - Global.DataContext.SubmitChanges(); - } + #region ITokenManager Members - /// <summary> - /// Checks whether a given request token has already been authorized - /// by some user for use by the Consumer that requested it. - /// </summary> - /// <param name="requestToken">The Consumer's request token.</param> - /// <returns> - /// True if the request token has already been fully authorized by the user - /// who owns the relevant protected resources. False if the token has not yet - /// been authorized, has expired or does not exist. - /// </returns> - public bool IsRequestTokenAuthorized(string requestToken) { - var tokenFound = Global.DataContext.OAuthTokens.SingleOrDefault( - token => token.Token == requestToken && - token.State == TokenAuthorizationState.AuthorizedRequestToken); - return tokenFound != null; - } + public string GetTokenSecret(string token) { + var tokenRow = Global.DataContext.OAuthTokens.SingleOrDefault( + tokenCandidate => tokenCandidate.Token == token); + if (tokenRow == null) { + throw new ArgumentException(); + } - public void ExpireRequestTokenAndStoreNewAccessToken(string consumerKey, string requestToken, string accessToken, string accessTokenSecret) { - var data = Global.DataContext; - var consumerRow = data.OAuthConsumers.Single(consumer => consumer.ConsumerKey == consumerKey); - var tokenRow = data.OAuthTokens.Single(token => token.Token == requestToken && token.OAuthConsumer == consumerRow); - Debug.Assert(tokenRow.State == TokenAuthorizationState.AuthorizedRequestToken, "The token should be authorized already!"); - - // Update the existing row to be an access token. - tokenRow.IssueDate = DateTime.UtcNow; - tokenRow.State = TokenAuthorizationState.AccessToken; - tokenRow.Token = accessToken; - tokenRow.TokenSecret = accessTokenSecret; - } + return tokenRow.TokenSecret; + } - /// <summary> - /// Classifies a token as a request token or an access token. - /// </summary> - /// <param name="token">The token to classify.</param> - /// <returns>Request or Access token, or invalid if the token is not recognized.</returns> - public TokenType GetTokenType(string token) { - var tokenRow = Global.DataContext.OAuthTokens.SingleOrDefault(tokenCandidate => tokenCandidate.Token == token); - if (tokenRow == null) { - return TokenType.InvalidToken; - } else if (tokenRow.State == TokenAuthorizationState.AccessToken) { - return TokenType.AccessToken; - } else { - return TokenType.RequestToken; + public void StoreNewRequestToken(UnauthorizedTokenRequest request, ITokenSecretContainingMessage response) { + RequestScopedTokenMessage scopedRequest = (RequestScopedTokenMessage)request; + var consumer = Global.DataContext.OAuthConsumers.Single(consumerRow => consumerRow.ConsumerKey == request.ConsumerKey); + string scope = scopedRequest.Scope; + OAuthToken newToken = new OAuthToken { + OAuthConsumer = consumer, + Token = response.Token, + TokenSecret = response.TokenSecret, + IssueDate = DateTime.UtcNow, + Scope = scope, + }; + + Global.DataContext.OAuthTokens.InsertOnSubmit(newToken); + Global.DataContext.SubmitChanges(); } - } - #endregion + /// <summary> + /// Checks whether a given request token has already been authorized + /// by some user for use by the Consumer that requested it. + /// </summary> + /// <param name="requestToken">The Consumer's request token.</param> + /// <returns> + /// True if the request token has already been fully authorized by the user + /// who owns the relevant protected resources. False if the token has not yet + /// been authorized, has expired or does not exist. + /// </returns> + public bool IsRequestTokenAuthorized(string requestToken) { + var tokenFound = Global.DataContext.OAuthTokens.SingleOrDefault( + token => token.Token == requestToken && + token.State == TokenAuthorizationState.AuthorizedRequestToken); + return tokenFound != null; + } - public void AuthorizeRequestToken(string requestToken, User user) { - if (requestToken == null) { - throw new ArgumentNullException("requestToken"); + public void ExpireRequestTokenAndStoreNewAccessToken(string consumerKey, string requestToken, string accessToken, string accessTokenSecret) { + var data = Global.DataContext; + var consumerRow = data.OAuthConsumers.Single(consumer => consumer.ConsumerKey == consumerKey); + var tokenRow = data.OAuthTokens.Single(token => token.Token == requestToken && token.OAuthConsumer == consumerRow); + Debug.Assert(tokenRow.State == TokenAuthorizationState.AuthorizedRequestToken, "The token should be authorized already!"); + + // Update the existing row to be an access token. + tokenRow.IssueDate = DateTime.UtcNow; + tokenRow.State = TokenAuthorizationState.AccessToken; + tokenRow.Token = accessToken; + tokenRow.TokenSecret = accessTokenSecret; } - if (user == null) { - throw new ArgumentNullException("user"); + + /// <summary> + /// Classifies a token as a request token or an access token. + /// </summary> + /// <param name="token">The token to classify.</param> + /// <returns>Request or Access token, or invalid if the token is not recognized.</returns> + public TokenType GetTokenType(string token) { + var tokenRow = Global.DataContext.OAuthTokens.SingleOrDefault(tokenCandidate => tokenCandidate.Token == token); + if (tokenRow == null) { + return TokenType.InvalidToken; + } else if (tokenRow.State == TokenAuthorizationState.AccessToken) { + return TokenType.AccessToken; + } else { + return TokenType.RequestToken; + } } - var tokenRow = Global.DataContext.OAuthTokens.SingleOrDefault( - tokenCandidate => tokenCandidate.Token == requestToken && - tokenCandidate.State == TokenAuthorizationState.UnauthorizedRequestToken); - if (tokenRow == null) { - throw new ArgumentException(); + #endregion + + public void AuthorizeRequestToken(string requestToken, User user) { + if (requestToken == null) { + throw new ArgumentNullException("requestToken"); + } + if (user == null) { + throw new ArgumentNullException("user"); + } + + var tokenRow = Global.DataContext.OAuthTokens.SingleOrDefault( + tokenCandidate => tokenCandidate.Token == requestToken && + tokenCandidate.State == TokenAuthorizationState.UnauthorizedRequestToken); + if (tokenRow == null) { + throw new ArgumentException(); + } + + tokenRow.State = TokenAuthorizationState.AuthorizedRequestToken; + tokenRow.User = user; } - tokenRow.State = TokenAuthorizationState.AuthorizedRequestToken; - tokenRow.User = user; - } + public OAuthConsumer GetConsumerForToken(string token) { + if (String.IsNullOrEmpty(token)) { + throw new ArgumentNullException("requestToken"); + } - public OAuthConsumer GetConsumerForToken(string token) { - if (String.IsNullOrEmpty(token)) { - throw new ArgumentNullException("requestToken"); - } + var tokenRow = Global.DataContext.OAuthTokens.SingleOrDefault( + tokenCandidate => tokenCandidate.Token == token); + if (tokenRow == null) { + throw new ArgumentException(); + } - var tokenRow = Global.DataContext.OAuthTokens.SingleOrDefault( - tokenCandidate => tokenCandidate.Token == token); - if (tokenRow == null) { - throw new ArgumentException(); + return tokenRow.OAuthConsumer; } - - return tokenRow.OAuthConsumer; } -} +}
\ No newline at end of file diff --git a/samples/OAuthServiceProvider/Code/Global.cs b/samples/OAuthServiceProvider/Code/Global.cs index 6a7ccc9..ceaeac8 100644 --- a/samples/OAuthServiceProvider/Code/Global.cs +++ b/samples/OAuthServiceProvider/Code/Global.cs @@ -1,124 +1,126 @@ -using System; -using System.Linq; -using System.ServiceModel; -using System.Text; -using System.Web; -using DotNetOpenAuth.OAuth.Messages; - -/// <summary> -/// The web application global events and properties. -/// </summary> -public class Global : HttpApplication { - /// <summary> - /// An application memory cache of recent log messages. - /// </summary> - public static StringBuilder LogMessages = new StringBuilder(); +namespace OAuthServiceProvider.Code { + using System; + using System.Linq; + using System.ServiceModel; + using System.Text; + using System.Web; + using DotNetOpenAuth.OAuth.Messages; /// <summary> - /// The logger for this sample to use. + /// The web application global events and properties. /// </summary> - public static log4net.ILog Logger = log4net.LogManager.GetLogger("DotNetOpenAuth.ConsumerSample"); + public class Global : HttpApplication { + /// <summary> + /// An application memory cache of recent log messages. + /// </summary> + public static StringBuilder LogMessages = new StringBuilder(); + + /// <summary> + /// The logger for this sample to use. + /// </summary> + public static log4net.ILog Logger = log4net.LogManager.GetLogger("DotNetOpenAuth.OAuthServiceProvider"); + + /// <summary> + /// Gets the transaction-protected database connection for the current request. + /// </summary> + public static DataClassesDataContext DataContext { + get { + DataClassesDataContext dataContext = dataContextSimple; + if (dataContext == null) { + dataContext = new DataClassesDataContext(); + dataContext.Connection.Open(); + dataContext.Transaction = dataContext.Connection.BeginTransaction(); + dataContextSimple = dataContext; + } - /// <summary> - /// Gets the transaction-protected database connection for the current request. - /// </summary> - public static DataClassesDataContext DataContext { - get { - DataClassesDataContext dataContext = dataContextSimple; - if (dataContext == null) { - dataContext = new DataClassesDataContext(); - dataContext.Connection.Open(); - dataContext.Transaction = dataContext.Connection.BeginTransaction(); - dataContextSimple = dataContext; + return dataContext; } - - return dataContext; } - } - public static DatabaseTokenManager TokenManager { get; set; } + public static DatabaseTokenManager TokenManager { get; set; } - public static DatabaseNonceStore NonceStore { get; set; } + public static DatabaseNonceStore NonceStore { get; set; } - public static User LoggedInUser { - get { return Global.DataContext.Users.SingleOrDefault(user => user.OpenIDClaimedIdentifier == HttpContext.Current.User.Identity.Name); } - } + public static User LoggedInUser { + get { return Global.DataContext.Users.SingleOrDefault(user => user.OpenIDClaimedIdentifier == HttpContext.Current.User.Identity.Name); } + } - public static UserAuthorizationRequest PendingOAuthAuthorization { - get { return HttpContext.Current.Session["authrequest"] as UserAuthorizationRequest; } - set { HttpContext.Current.Session["authrequest"] = value; } - } + public static UserAuthorizationRequest PendingOAuthAuthorization { + get { return HttpContext.Current.Session["authrequest"] as UserAuthorizationRequest; } + set { HttpContext.Current.Session["authrequest"] = value; } + } - private static DataClassesDataContext dataContextSimple { - get { - if (HttpContext.Current != null) { - return HttpContext.Current.Items["DataContext"] as DataClassesDataContext; - } else if (OperationContext.Current != null) { - object data; - if (OperationContext.Current.IncomingMessageProperties.TryGetValue("DataContext", out data)) { - return data as DataClassesDataContext; + private static DataClassesDataContext dataContextSimple { + get { + if (HttpContext.Current != null) { + return HttpContext.Current.Items["DataContext"] as DataClassesDataContext; + } else if (OperationContext.Current != null) { + object data; + if (OperationContext.Current.IncomingMessageProperties.TryGetValue("DataContext", out data)) { + return data as DataClassesDataContext; + } else { + return null; + } } else { - return null; + throw new InvalidOperationException(); } - } else { - throw new InvalidOperationException(); } - } - set { - if (HttpContext.Current != null) { - HttpContext.Current.Items["DataContext"] = value; - } else if (OperationContext.Current != null) { - OperationContext.Current.IncomingMessageProperties["DataContext"] = value; - } else { - throw new InvalidOperationException(); + set { + if (HttpContext.Current != null) { + HttpContext.Current.Items["DataContext"] = value; + } else if (OperationContext.Current != null) { + OperationContext.Current.IncomingMessageProperties["DataContext"] = value; + } else { + throw new InvalidOperationException(); + } } } - } - - public static void AuthorizePendingRequestToken() { - ITokenContainingMessage tokenMessage = PendingOAuthAuthorization; - TokenManager.AuthorizeRequestToken(tokenMessage.Token, LoggedInUser); - PendingOAuthAuthorization = null; - } - private static void CommitAndCloseDatabaseIfNecessary() { - var dataContext = dataContextSimple; - if (dataContext != null) { - dataContext.SubmitChanges(); - dataContext.Transaction.Commit(); - dataContext.Connection.Close(); + public static void AuthorizePendingRequestToken() { + ITokenContainingMessage tokenMessage = PendingOAuthAuthorization; + TokenManager.AuthorizeRequestToken(tokenMessage.Token, LoggedInUser); + PendingOAuthAuthorization = null; } - } - private void Application_Start(object sender, EventArgs e) { - log4net.Config.XmlConfigurator.Configure(); - Logger.Info("Sample starting..."); - string appPath = HttpContext.Current.Request.ApplicationPath; - if (!appPath.EndsWith("/")) { - appPath += "/"; + private static void CommitAndCloseDatabaseIfNecessary() { + var dataContext = dataContextSimple; + if (dataContext != null) { + dataContext.SubmitChanges(); + dataContext.Transaction.Commit(); + dataContext.Connection.Close(); + } } - // This will break in IIS Integrated Pipeline mode, since applications - // start before the first incoming request context is available. - // TODO: fix this. - Constants.WebRootUrl = new Uri(HttpContext.Current.Request.Url, appPath); - Global.TokenManager = new DatabaseTokenManager(); - Global.NonceStore = new DatabaseNonceStore(); - } + private void Application_Start(object sender, EventArgs e) { + log4net.Config.XmlConfigurator.Configure(); + Logger.Info("Sample starting..."); + string appPath = HttpContext.Current.Request.ApplicationPath; + if (!appPath.EndsWith("/")) { + appPath += "/"; + } - private void Application_End(object sender, EventArgs e) { - Logger.Info("Sample shutting down..."); + // This will break in IIS Integrated Pipeline mode, since applications + // start before the first incoming request context is available. + // TODO: fix this. + Constants.WebRootUrl = new Uri(HttpContext.Current.Request.Url, appPath); + Global.TokenManager = new DatabaseTokenManager(); + Global.NonceStore = new DatabaseNonceStore(); + } - // this would be automatic, but in partial trust scenarios it is not. - log4net.LogManager.Shutdown(); - } + private void Application_End(object sender, EventArgs e) { + Logger.Info("Sample shutting down..."); - private void Application_Error(object sender, EventArgs e) { - Logger.Error("An unhandled exception occurred in ASP.NET processing: " + Server.GetLastError(), Server.GetLastError()); - } + // this would be automatic, but in partial trust scenarios it is not. + log4net.LogManager.Shutdown(); + } - private void Application_EndRequest(object sender, EventArgs e) { - CommitAndCloseDatabaseIfNecessary(); + private void Application_Error(object sender, EventArgs e) { + Logger.Error("An unhandled exception occurred in ASP.NET processing: " + Server.GetLastError(), Server.GetLastError()); + } + + private void Application_EndRequest(object sender, EventArgs e) { + CommitAndCloseDatabaseIfNecessary(); + } } -} +}
\ No newline at end of file diff --git a/samples/OAuthServiceProvider/Code/IDataApi.cs b/samples/OAuthServiceProvider/Code/IDataApi.cs index 350df35..45853cd 100644 --- a/samples/OAuthServiceProvider/Code/IDataApi.cs +++ b/samples/OAuthServiceProvider/Code/IDataApi.cs @@ -1,18 +1,20 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Runtime.Serialization; -using System.ServiceModel; -using System.Text; +namespace OAuthServiceProvider.Code { + using System; + using System.Collections.Generic; + using System.Linq; + using System.Runtime.Serialization; + using System.ServiceModel; + using System.Text; -[ServiceContract] -public interface IDataApi { - [OperationContract] - int? GetAge(); + [ServiceContract] + public interface IDataApi { + [OperationContract] + int? GetAge(); - [OperationContract] - string GetName(); + [OperationContract] + string GetName(); - [OperationContract] - string[] GetFavoriteSites(); -} + [OperationContract] + string[] GetFavoriteSites(); + } +}
\ No newline at end of file diff --git a/samples/OAuthServiceProvider/Code/OAuthAuthorizationManager.cs b/samples/OAuthServiceProvider/Code/OAuthAuthorizationManager.cs index ee90364..6d5bfff 100644 --- a/samples/OAuthServiceProvider/Code/OAuthAuthorizationManager.cs +++ b/samples/OAuthServiceProvider/Code/OAuthAuthorizationManager.cs @@ -1,63 +1,65 @@ -using System; -using System.Collections.Generic; -using System.IdentityModel.Policy; -using System.Linq; -using System.Security.Principal; -using System.ServiceModel; -using System.ServiceModel.Channels; -using System.ServiceModel.Security; -using DotNetOpenAuth; -using DotNetOpenAuth.OAuth; - -/// <summary> -/// A WCF extension to authenticate incoming messages using OAuth. -/// </summary> -public class OAuthAuthorizationManager : ServiceAuthorizationManager { - public OAuthAuthorizationManager() { - } +namespace OAuthServiceProvider.Code { + using System; + using System.Collections.Generic; + using System.IdentityModel.Policy; + using System.Linq; + using System.Security.Principal; + using System.ServiceModel; + using System.ServiceModel.Channels; + using System.ServiceModel.Security; + using DotNetOpenAuth; + using DotNetOpenAuth.OAuth; - protected override bool CheckAccessCore(OperationContext operationContext) { - if (!base.CheckAccessCore(operationContext)) { - return false; + /// <summary> + /// A WCF extension to authenticate incoming messages using OAuth. + /// </summary> + public class OAuthAuthorizationManager : ServiceAuthorizationManager { + public OAuthAuthorizationManager() { } - HttpRequestMessageProperty httpDetails = operationContext.RequestContext.RequestMessage.Properties[HttpRequestMessageProperty.Name] as HttpRequestMessageProperty; - Uri requestUri = operationContext.RequestContext.RequestMessage.Properties["OriginalHttpRequestUri"] as Uri; - ServiceProvider sp = Constants.CreateServiceProvider(); - try { - var auth = sp.ReadProtectedResourceAuthorization(httpDetails, requestUri); - if (auth != null) { - var accessToken = Global.DataContext.OAuthTokens.Single(token => token.Token == auth.AccessToken); - - var principal = sp.CreatePrincipal(auth); - var policy = new OAuthPrincipalAuthorizationPolicy(principal); - var policies = new List<IAuthorizationPolicy> { + protected override bool CheckAccessCore(OperationContext operationContext) { + if (!base.CheckAccessCore(operationContext)) { + return false; + } + + HttpRequestMessageProperty httpDetails = operationContext.RequestContext.RequestMessage.Properties[HttpRequestMessageProperty.Name] as HttpRequestMessageProperty; + Uri requestUri = operationContext.RequestContext.RequestMessage.Properties["OriginalHttpRequestUri"] as Uri; + ServiceProvider sp = Constants.CreateServiceProvider(); + try { + var auth = sp.ReadProtectedResourceAuthorization(httpDetails, requestUri); + if (auth != null) { + var accessToken = Global.DataContext.OAuthTokens.Single(token => token.Token == auth.AccessToken); + + var principal = sp.CreatePrincipal(auth); + var policy = new OAuthPrincipalAuthorizationPolicy(principal); + var policies = new List<IAuthorizationPolicy> { policy, }; - var securityContext = new ServiceSecurityContext(policies.AsReadOnly()); - if (operationContext.IncomingMessageProperties.Security != null) { - operationContext.IncomingMessageProperties.Security.ServiceSecurityContext = securityContext; - } else { - operationContext.IncomingMessageProperties.Security = new SecurityMessageProperty { - ServiceSecurityContext = securityContext, - }; - } + var securityContext = new ServiceSecurityContext(policies.AsReadOnly()); + if (operationContext.IncomingMessageProperties.Security != null) { + operationContext.IncomingMessageProperties.Security.ServiceSecurityContext = securityContext; + } else { + operationContext.IncomingMessageProperties.Security = new SecurityMessageProperty { + ServiceSecurityContext = securityContext, + }; + } - securityContext.AuthorizationContext.Properties["Identities"] = new List<IIdentity> { + securityContext.AuthorizationContext.Properties["Identities"] = new List<IIdentity> { principal.Identity, }; - // Only allow this method call if the access token scope permits it. - string[] scopes = accessToken.Scope.Split('|'); - if (scopes.Contains(operationContext.IncomingMessageHeaders.Action)) { - return true; + // Only allow this method call if the access token scope permits it. + string[] scopes = accessToken.Scope.Split('|'); + if (scopes.Contains(operationContext.IncomingMessageHeaders.Action)) { + return true; + } } + } catch (ProtocolException ex) { + Global.Logger.Error("Error processing OAuth messages.", ex); } - } catch (ProtocolException ex) { - Global.Logger.Error("Error processing OAuth messages.", ex); - } - return false; + return false; + } } -} +}
\ No newline at end of file diff --git a/samples/OAuthServiceProvider/Code/OAuthConsumer.cs b/samples/OAuthServiceProvider/Code/OAuthConsumer.cs index db8f469..d7dfc06 100644 --- a/samples/OAuthServiceProvider/Code/OAuthConsumer.cs +++ b/samples/OAuthServiceProvider/Code/OAuthConsumer.cs @@ -4,38 +4,40 @@ // </copyright> //----------------------------------------------------------------------- -using System; -using System.Collections.Generic; -using System.Linq; -using System.Web; -using DotNetOpenAuth.OAuth.ChannelElements; +namespace OAuthServiceProvider.Code { + using System; + using System.Collections.Generic; + using System.Linq; + using System.Web; + using DotNetOpenAuth.OAuth.ChannelElements; -public partial class OAuthConsumer : IConsumerDescription { - #region IConsumerDescription Members + public partial class OAuthConsumer : IConsumerDescription { + #region IConsumerDescription Members - string IConsumerDescription.Key { - get { return this.ConsumerKey; } - } + string IConsumerDescription.Key { + get { return this.ConsumerKey; } + } - string IConsumerDescription.Secret { - get { return this.ConsumerSecret; } - } + string IConsumerDescription.Secret { + get { return this.ConsumerSecret; } + } - System.Security.Cryptography.X509Certificates.X509Certificate2 IConsumerDescription.Certificate { - get { return null; } - } + System.Security.Cryptography.X509Certificates.X509Certificate2 IConsumerDescription.Certificate { + get { return null; } + } - Uri IConsumerDescription.Callback { - get { return string.IsNullOrEmpty(this.Callback) ? null : new Uri(this.Callback); } - } + Uri IConsumerDescription.Callback { + get { return string.IsNullOrEmpty(this.Callback) ? null : new Uri(this.Callback); } + } - DotNetOpenAuth.OAuth.VerificationCodeFormat IConsumerDescription.VerificationCodeFormat { - get { return this.VerificationCodeFormat; } - } + DotNetOpenAuth.OAuth.VerificationCodeFormat IConsumerDescription.VerificationCodeFormat { + get { return this.VerificationCodeFormat; } + } - int IConsumerDescription.VerificationCodeLength { - get { return this.VerificationCodeLength; } - } + int IConsumerDescription.VerificationCodeLength { + get { return this.VerificationCodeLength; } + } - #endregion -} + #endregion + } +}
\ No newline at end of file diff --git a/samples/OAuthServiceProvider/Code/OAuthPrincipalAuthorizationPolicy.cs b/samples/OAuthServiceProvider/Code/OAuthPrincipalAuthorizationPolicy.cs index 5bd6b05..a25f4c5 100644 --- a/samples/OAuthServiceProvider/Code/OAuthPrincipalAuthorizationPolicy.cs +++ b/samples/OAuthServiceProvider/Code/OAuthPrincipalAuthorizationPolicy.cs @@ -1,45 +1,47 @@ -using System; -using System.Collections.Generic; -using System.IdentityModel.Claims; -using System.IdentityModel.Policy; -using System.Linq; -using System.Web; -using DotNetOpenAuth.OAuth.ChannelElements; - -public class OAuthPrincipalAuthorizationPolicy : IAuthorizationPolicy { - private readonly Guid uniqueId = Guid.NewGuid(); - private readonly OAuthPrincipal principal; - - /// <summary> - /// Initializes a new instance of the <see cref="OAuthPrincipalAuthorizationPolicy"/> class. - /// </summary> - /// <param name="principal">The principal.</param> - public OAuthPrincipalAuthorizationPolicy(OAuthPrincipal principal) { - this.principal = principal; +namespace OAuthServiceProvider.Code { + using System; + using System.Collections.Generic; + using System.IdentityModel.Claims; + using System.IdentityModel.Policy; + using System.Linq; + using System.Web; + using DotNetOpenAuth.OAuth.ChannelElements; + + public class OAuthPrincipalAuthorizationPolicy : IAuthorizationPolicy { + private readonly Guid uniqueId = Guid.NewGuid(); + private readonly OAuthPrincipal principal; + + /// <summary> + /// Initializes a new instance of the <see cref="OAuthPrincipalAuthorizationPolicy"/> class. + /// </summary> + /// <param name="principal">The principal.</param> + public OAuthPrincipalAuthorizationPolicy(OAuthPrincipal principal) { + this.principal = principal; + } + + #region IAuthorizationComponent Members + + /// <summary> + /// Gets a unique ID for this instance. + /// </summary> + public string Id { + get { return this.uniqueId.ToString(); } + } + + #endregion + + #region IAuthorizationPolicy Members + + public ClaimSet Issuer { + get { return ClaimSet.System; } + } + + public bool Evaluate(EvaluationContext evaluationContext, ref object state) { + evaluationContext.AddClaimSet(this, new DefaultClaimSet(Claim.CreateNameClaim(this.principal.Identity.Name))); + evaluationContext.Properties["Principal"] = this.principal; + return true; + } + + #endregion } - - #region IAuthorizationComponent Members - - /// <summary> - /// Gets a unique ID for this instance. - /// </summary> - public string Id { - get { return this.uniqueId.ToString(); } - } - - #endregion - - #region IAuthorizationPolicy Members - - public ClaimSet Issuer { - get { return ClaimSet.System; } - } - - public bool Evaluate(EvaluationContext evaluationContext, ref object state) { - evaluationContext.AddClaimSet(this, new DefaultClaimSet(Claim.CreateNameClaim(this.principal.Identity.Name))); - evaluationContext.Properties["Principal"] = this.principal; - return true; - } - - #endregion -} +}
\ No newline at end of file diff --git a/samples/OAuthServiceProvider/Code/OAuthToken.cs b/samples/OAuthServiceProvider/Code/OAuthToken.cs index ea18b2b..182a3e3 100644 --- a/samples/OAuthServiceProvider/Code/OAuthToken.cs +++ b/samples/OAuthServiceProvider/Code/OAuthToken.cs @@ -4,61 +4,63 @@ // </copyright> //----------------------------------------------------------------------- -using System; -using System.Collections.Generic; -using System.Linq; -using System.Web; -using DotNetOpenAuth.OAuth.ChannelElements; +namespace OAuthServiceProvider.Code { + using System; + using System.Collections.Generic; + using System.Linq; + using System.Web; + using DotNetOpenAuth.OAuth.ChannelElements; -public partial class OAuthToken : IServiceProviderRequestToken, IServiceProviderAccessToken { - #region IServiceProviderRequestToken Members + public partial class OAuthToken : IServiceProviderRequestToken, IServiceProviderAccessToken { + #region IServiceProviderRequestToken Members - string IServiceProviderRequestToken.Token { - get { return this.Token; } - } + string IServiceProviderRequestToken.Token { + get { return this.Token; } + } - string IServiceProviderRequestToken.ConsumerKey { - get { return this.OAuthConsumer.ConsumerKey; } - } + string IServiceProviderRequestToken.ConsumerKey { + get { return this.OAuthConsumer.ConsumerKey; } + } - DateTime IServiceProviderRequestToken.CreatedOn { - get { return this.IssueDate; } - } + DateTime IServiceProviderRequestToken.CreatedOn { + get { return this.IssueDate; } + } - Uri IServiceProviderRequestToken.Callback { - get { return string.IsNullOrEmpty(this.RequestTokenCallback) ? null : new Uri(this.RequestTokenCallback); } - set { this.RequestTokenCallback = value.AbsoluteUri; } - } + Uri IServiceProviderRequestToken.Callback { + get { return string.IsNullOrEmpty(this.RequestTokenCallback) ? null : new Uri(this.RequestTokenCallback); } + set { this.RequestTokenCallback = value.AbsoluteUri; } + } - string IServiceProviderRequestToken.VerificationCode { - get { return this.RequestTokenVerifier; } - set { this.RequestTokenVerifier = value; } - } + string IServiceProviderRequestToken.VerificationCode { + get { return this.RequestTokenVerifier; } + set { this.RequestTokenVerifier = value; } + } - Version IServiceProviderRequestToken.ConsumerVersion { - get { return new Version(this.ConsumerVersion); } - set { this.ConsumerVersion = value.ToString(); } - } + Version IServiceProviderRequestToken.ConsumerVersion { + get { return new Version(this.ConsumerVersion); } + set { this.ConsumerVersion = value.ToString(); } + } - #endregion + #endregion - #region IServiceProviderAccessToken Members + #region IServiceProviderAccessToken Members - string IServiceProviderAccessToken.Token { - get { return this.Token; } - } + string IServiceProviderAccessToken.Token { + get { return this.Token; } + } - DateTime? IServiceProviderAccessToken.ExpirationDate { - get { return null; } - } + DateTime? IServiceProviderAccessToken.ExpirationDate { + get { return null; } + } - string IServiceProviderAccessToken.Username { - get { return this.User.OpenIDClaimedIdentifier; } - } + string IServiceProviderAccessToken.Username { + get { return this.User.OpenIDClaimedIdentifier; } + } - string[] IServiceProviderAccessToken.Roles { - get { return this.Scope.Split('|'); } - } + string[] IServiceProviderAccessToken.Roles { + get { return this.Scope.Split('|'); } + } - #endregion -} + #endregion + } +}
\ No newline at end of file diff --git a/samples/OAuthServiceProvider/Code/RequestScopedTokenMessage.cs b/samples/OAuthServiceProvider/Code/RequestScopedTokenMessage.cs index 4cc4860..984d683 100644 --- a/samples/OAuthServiceProvider/Code/RequestScopedTokenMessage.cs +++ b/samples/OAuthServiceProvider/Code/RequestScopedTokenMessage.cs @@ -1,22 +1,25 @@ -using System; -using DotNetOpenAuth.Messaging; -using DotNetOpenAuth.OAuth.Messages; +namespace OAuthServiceProvider.Code { + using System; + using DotNetOpenAuth.Messaging; + using DotNetOpenAuth.OAuth.Messages; -/// <summary> -/// A custom web app version of the message sent to request an unauthorized token. -/// </summary> -public class RequestScopedTokenMessage : UnauthorizedTokenRequest { /// <summary> - /// Initializes a new instance of the <see cref="RequestScopedTokenMessage"/> class. + /// A custom web app version of the message sent to request an unauthorized token. /// </summary> - /// <param name="endpoint">The endpoint that will receive the message.</param> - /// <param name="version">The OAuth version.</param> - public RequestScopedTokenMessage(MessageReceivingEndpoint endpoint, Version version) : base(endpoint, version) { - } + public class RequestScopedTokenMessage : UnauthorizedTokenRequest { + /// <summary> + /// Initializes a new instance of the <see cref="RequestScopedTokenMessage"/> class. + /// </summary> + /// <param name="endpoint">The endpoint that will receive the message.</param> + /// <param name="version">The OAuth version.</param> + public RequestScopedTokenMessage(MessageReceivingEndpoint endpoint, Version version) + : base(endpoint, version) { + } - /// <summary> - /// Gets or sets the scope of the access being requested. - /// </summary> - [MessagePart("scope", IsRequired = true)] - public string Scope { get; set; } -} + /// <summary> + /// Gets or sets the scope of the access being requested. + /// </summary> + [MessagePart("scope", IsRequired = true)] + public string Scope { get; set; } + } +}
\ No newline at end of file diff --git a/samples/OAuthServiceProvider/Code/TokenAuthorizationState.cs b/samples/OAuthServiceProvider/Code/TokenAuthorizationState.cs index 8d3c8ac..a9cfa4e 100644 --- a/samples/OAuthServiceProvider/Code/TokenAuthorizationState.cs +++ b/samples/OAuthServiceProvider/Code/TokenAuthorizationState.cs @@ -1,24 +1,26 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Web; +namespace OAuthServiceProvider.Code { + using System; + using System.Collections.Generic; + using System.Linq; + using System.Web; -/// <summary> -/// Various states an OAuth token can be in. -/// </summary> -public enum TokenAuthorizationState : int { /// <summary> - /// An unauthorized request token. + /// Various states an OAuth token can be in. /// </summary> - UnauthorizedRequestToken = 0, + public enum TokenAuthorizationState : int { + /// <summary> + /// An unauthorized request token. + /// </summary> + UnauthorizedRequestToken = 0, - /// <summary> - /// An authorized request token. - /// </summary> - AuthorizedRequestToken = 1, + /// <summary> + /// An authorized request token. + /// </summary> + AuthorizedRequestToken = 1, - /// <summary> - /// An authorized access token. - /// </summary> - AccessToken = 2, -} + /// <summary> + /// An authorized access token. + /// </summary> + AccessToken = 2, + } +}
\ No newline at end of file diff --git a/samples/OAuthServiceProvider/Code/TracePageAppender.cs b/samples/OAuthServiceProvider/Code/TracePageAppender.cs index 7490f3d..8f97c89 100644 --- a/samples/OAuthServiceProvider/Code/TracePageAppender.cs +++ b/samples/OAuthServiceProvider/Code/TracePageAppender.cs @@ -1,11 +1,13 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Web; +namespace OAuthServiceProvider.Code { + using System; + using System.Collections.Generic; + using System.IO; + using System.Web; -public class TracePageAppender : log4net.Appender.AppenderSkeleton { - protected override void Append(log4net.Core.LoggingEvent loggingEvent) { - StringWriter sw = new StringWriter(Global.LogMessages); - Layout.Format(sw, loggingEvent); + public class TracePageAppender : log4net.Appender.AppenderSkeleton { + protected override void Append(log4net.Core.LoggingEvent loggingEvent) { + StringWriter sw = new StringWriter(Global.LogMessages); + Layout.Format(sw, loggingEvent); + } } -} +}
\ No newline at end of file diff --git a/samples/OAuthServiceProvider/Code/Utilities.cs b/samples/OAuthServiceProvider/Code/Utilities.cs index 2c25fe8..a225650 100644 --- a/samples/OAuthServiceProvider/Code/Utilities.cs +++ b/samples/OAuthServiceProvider/Code/Utilities.cs @@ -1,26 +1,28 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Security.Principal; -using System.Web; +namespace OAuthServiceProvider.Code { + using System; + using System.Collections.Generic; + using System.Linq; + using System.Security.Principal; + using System.Web; -/// <summary> -/// Extension methods and other helpful utility methods. -/// </summary> -public static class Utilities { /// <summary> - /// Gets the database entity representing the user identified by a given <see cref="IIdentity"/> instance. + /// Extension methods and other helpful utility methods. /// </summary> - /// <param name="identity">The identity of the user.</param> - /// <returns> - /// The database object for that user; or <c>null</c> if the user could not - /// be found or if <paramref name="identity"/> is <c>null</c> or represents an anonymous identity. - /// </returns> - public static User GetUser(this IIdentity identity) { - if (identity == null || !identity.IsAuthenticated) { - return null; - } + public static class Utilities { + /// <summary> + /// Gets the database entity representing the user identified by a given <see cref="IIdentity"/> instance. + /// </summary> + /// <param name="identity">The identity of the user.</param> + /// <returns> + /// The database object for that user; or <c>null</c> if the user could not + /// be found or if <paramref name="identity"/> is <c>null</c> or represents an anonymous identity. + /// </returns> + public static User GetUser(this IIdentity identity) { + if (identity == null || !identity.IsAuthenticated) { + return null; + } - return Global.DataContext.Users.SingleOrDefault(user => user.OpenIDClaimedIdentifier == identity.Name); + return Global.DataContext.Users.SingleOrDefault(user => user.OpenIDClaimedIdentifier == identity.Name); + } } -} +}
\ No newline at end of file diff --git a/samples/OAuthServiceProvider/DataApi.cs b/samples/OAuthServiceProvider/DataApi.cs index d5adb10..9d531e6 100644 --- a/samples/OAuthServiceProvider/DataApi.cs +++ b/samples/OAuthServiceProvider/DataApi.cs @@ -1,31 +1,34 @@ -using System.Linq; -using System.ServiceModel; +namespace OAuthServiceProvider { + using System.Linq; + using System.ServiceModel; + using OAuthServiceProvider.Code; -/// <summary> -/// The WCF service API. -/// </summary> -/// <remarks> -/// Note how there is no code here that is bound to OAuth or any other -/// credential/authorization scheme. That's all part of the channel/binding elsewhere. -/// And the reference to OperationContext.Current.ServiceSecurityContext.PrimaryIdentity -/// is the user being impersonated by the WCF client. -/// In the OAuth case, it is the user who authorized the OAuth access token that was used -/// to gain access to the service. -/// </remarks> -public class DataApi : IDataApi { - private User User { - get { return OperationContext.Current.ServiceSecurityContext.PrimaryIdentity.GetUser(); } - } + /// <summary> + /// The WCF service API. + /// </summary> + /// <remarks> + /// Note how there is no code here that is bound to OAuth or any other + /// credential/authorization scheme. That's all part of the channel/binding elsewhere. + /// And the reference to OperationContext.Current.ServiceSecurityContext.PrimaryIdentity + /// is the user being impersonated by the WCF client. + /// In the OAuth case, it is the user who authorized the OAuth access token that was used + /// to gain access to the service. + /// </remarks> + public class DataApi : IDataApi { + private User User { + get { return OperationContext.Current.ServiceSecurityContext.PrimaryIdentity.GetUser(); } + } - public int? GetAge() { - return User.Age; - } + public int? GetAge() { + return User.Age; + } - public string GetName() { - return User.FullName; - } + public string GetName() { + return User.FullName; + } - public string[] GetFavoriteSites() { - return User.FavoriteSites.Select(site => site.SiteUrl).ToArray(); + public string[] GetFavoriteSites() { + return User.FavoriteSites.Select(site => site.SiteUrl).ToArray(); + } } -} +}
\ No newline at end of file diff --git a/samples/OAuthServiceProvider/DataApi.svc b/samples/OAuthServiceProvider/DataApi.svc index 051d880..50e952c 100644 --- a/samples/OAuthServiceProvider/DataApi.svc +++ b/samples/OAuthServiceProvider/DataApi.svc @@ -1 +1 @@ -<%@ ServiceHost Language="C#" Debug="true" Service="DataApi" CodeBehind="DataApi.cs" %> +<%@ ServiceHost Language="C#" Debug="true" Service="OAuthServiceProvider.DataApi" CodeBehind="DataApi.cs" %> diff --git a/samples/OAuthServiceProvider/Default.aspx b/samples/OAuthServiceProvider/Default.aspx index e3eec9d..3e5d820 100644 --- a/samples/OAuthServiceProvider/Default.aspx +++ b/samples/OAuthServiceProvider/Default.aspx @@ -1,4 +1,4 @@ -<%@ Page Title="DotNetOpenAuth Service Provider Sample" Language="C#" MasterPageFile="~/MasterPage.master" CodeBehind="~/Default.aspx.cs" Inherits="_Default" AutoEventWireup="True" %> +<%@ Page Title="DotNetOpenAuth Service Provider Sample" Language="C#" MasterPageFile="~/MasterPage.master" CodeBehind="~/Default.aspx.cs" Inherits="OAuthServiceProvider._Default" AutoEventWireup="True" %> <%@ Import Namespace="System.IO" %> <%@ Import Namespace="System.Data.SqlClient" %> diff --git a/samples/OAuthServiceProvider/Default.aspx.cs b/samples/OAuthServiceProvider/Default.aspx.cs index c0e3a03..a08a2d2 100644 --- a/samples/OAuthServiceProvider/Default.aspx.cs +++ b/samples/OAuthServiceProvider/Default.aspx.cs @@ -1,44 +1,47 @@ - using System; +namespace OAuthServiceProvider { + using System; using System.Collections.Generic; using System.Configuration; using System.IO; using System.Linq; using System.Web; + using OAuthServiceProvider.Code; -public partial class _Default : System.Web.UI.Page { - protected void createDatabaseButton_Click(object sender, EventArgs e) { - string dbPath = Path.Combine(Server.MapPath(Request.ApplicationPath), "App_Data"); - if (!Directory.Exists(dbPath)) { - Directory.CreateDirectory(dbPath); - } - string connectionString = ConfigurationManager.ConnectionStrings["DatabaseConnectionString"].ConnectionString.Replace("|DataDirectory|", dbPath); - var dc = new DataClassesDataContext(connectionString); - if (dc.DatabaseExists()) { - dc.DeleteDatabase(); - } - try { - dc.CreateDatabase(); - // Fill with sample data. - dc.OAuthConsumers.InsertOnSubmit(new OAuthConsumer { - ConsumerKey = "sampleconsumer", - ConsumerSecret = "samplesecret", - }); - dc.Users.InsertOnSubmit(new User { - OpenIDFriendlyIdentifier = "=arnott", - OpenIDClaimedIdentifier = "=!9B72.7DD1.50A9.5CCD", - Age = 27, - FullName = "Andrew Arnott", - FavoriteSites = new System.Data.Linq.EntitySet<FavoriteSite> { + public partial class _Default : System.Web.UI.Page { + protected void createDatabaseButton_Click(object sender, EventArgs e) { + string dbPath = Path.Combine(Server.MapPath(Request.ApplicationPath), "App_Data"); + if (!Directory.Exists(dbPath)) { + Directory.CreateDirectory(dbPath); + } + string connectionString = ConfigurationManager.ConnectionStrings["DatabaseConnectionString"].ConnectionString.Replace("|DataDirectory|", dbPath); + var dc = new DataClassesDataContext(connectionString); + if (dc.DatabaseExists()) { + dc.DeleteDatabase(); + } + try { + dc.CreateDatabase(); + // Fill with sample data. + dc.OAuthConsumers.InsertOnSubmit(new OAuthConsumer { + ConsumerKey = "sampleconsumer", + ConsumerSecret = "samplesecret", + }); + dc.Users.InsertOnSubmit(new User { + OpenIDFriendlyIdentifier = "=arnott", + OpenIDClaimedIdentifier = "=!9B72.7DD1.50A9.5CCD", + Age = 27, + FullName = "Andrew Arnott", + FavoriteSites = new System.Data.Linq.EntitySet<FavoriteSite> { new FavoriteSite { SiteUrl = "http://www.microsoft.com" }, new FavoriteSite { SiteUrl = "http://www.google.com" }, }, - }); + }); - dc.SubmitChanges(); - databaseStatus.Visible = true; - } catch (System.Data.SqlClient.SqlException ex) { - foreach (System.Data.SqlClient.SqlError error in ex.Errors) { - Response.Write(error.Message); + dc.SubmitChanges(); + databaseStatus.Visible = true; + } catch (System.Data.SqlClient.SqlException ex) { + foreach (System.Data.SqlClient.SqlError error in ex.Errors) { + Response.Write(error.Message); + } } } } diff --git a/samples/OAuthServiceProvider/Default.aspx.designer.cs b/samples/OAuthServiceProvider/Default.aspx.designer.cs index 5c5276e..afa79c0 100644 --- a/samples/OAuthServiceProvider/Default.aspx.designer.cs +++ b/samples/OAuthServiceProvider/Default.aspx.designer.cs @@ -7,25 +7,27 @@ // </auto-generated> //------------------------------------------------------------------------------ - - -public partial class _Default { +namespace OAuthServiceProvider { - /// <summary> - /// createDatabaseButton control. - /// </summary> - /// <remarks> - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// </remarks> - protected global::System.Web.UI.WebControls.Button createDatabaseButton; - /// <summary> - /// databaseStatus control. - /// </summary> - /// <remarks> - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// </remarks> - protected global::System.Web.UI.WebControls.Label databaseStatus; + public partial class _Default { + + /// <summary> + /// createDatabaseButton control. + /// </summary> + /// <remarks> + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// </remarks> + protected global::System.Web.UI.WebControls.Button createDatabaseButton; + + /// <summary> + /// databaseStatus control. + /// </summary> + /// <remarks> + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// </remarks> + protected global::System.Web.UI.WebControls.Label databaseStatus; + } } diff --git a/samples/OAuthServiceProvider/Global.asax b/samples/OAuthServiceProvider/Global.asax index e9ae062..3007bd3 100644 --- a/samples/OAuthServiceProvider/Global.asax +++ b/samples/OAuthServiceProvider/Global.asax @@ -1 +1 @@ -<%@ Application Inherits="Global" CodeBehind="App_Code\Global.cs" %>
\ No newline at end of file +<%@ Application Inherits="OAuthServiceProvider.Code.Global" CodeBehind="Code\Global.cs" %>
\ No newline at end of file diff --git a/samples/OAuthServiceProvider/Members/Authorize.aspx b/samples/OAuthServiceProvider/Members/Authorize.aspx index 7a2a753..b3e2c6a 100644 --- a/samples/OAuthServiceProvider/Members/Authorize.aspx +++ b/samples/OAuthServiceProvider/Members/Authorize.aspx @@ -1,4 +1,4 @@ -<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" Inherits="Authorize" Codebehind="Authorize.aspx.cs" %> +<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" Inherits="OAuthServiceProvider.Authorize" Codebehind="Authorize.aspx.cs" %> <asp:Content ID="Content2" ContentPlaceHolderID="Body" runat="Server"> <asp:MultiView runat="server" ActiveViewIndex="0" ID="multiView"> diff --git a/samples/OAuthServiceProvider/Members/Authorize.aspx.cs b/samples/OAuthServiceProvider/Members/Authorize.aspx.cs index 1e981a3..ec98ddf 100644 --- a/samples/OAuthServiceProvider/Members/Authorize.aspx.cs +++ b/samples/OAuthServiceProvider/Members/Authorize.aspx.cs @@ -1,77 +1,80 @@ -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 DotNetOpenAuth; -using DotNetOpenAuth.OAuth; -using DotNetOpenAuth.OAuth.Messages; +namespace OAuthServiceProvider { + 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 DotNetOpenAuth; + using DotNetOpenAuth.OAuth; + using DotNetOpenAuth.OAuth.Messages; + using OAuthServiceProvider.Code; -/// <summary> -/// Conducts the user through a Consumer authorization process. -/// </summary> -public partial class Authorize : System.Web.UI.Page { - private static readonly RandomNumberGenerator CryptoRandomDataGenerator = new RNGCryptoServiceProvider(); + /// <summary> + /// Conducts the user through a Consumer authorization process. + /// </summary> + public partial class Authorize : System.Web.UI.Page { + private static readonly RandomNumberGenerator CryptoRandomDataGenerator = new RNGCryptoServiceProvider(); - private string AuthorizationSecret { - get { return Session["OAuthAuthorizationSecret"] as string; } - set { Session["OAuthAuthorizationSecret"] = value; } - } + private string AuthorizationSecret { + get { return Session["OAuthAuthorizationSecret"] as string; } + set { Session["OAuthAuthorizationSecret"] = value; } + } - protected void Page_Load(object sender, EventArgs e) { - if (!IsPostBack) { - if (Global.PendingOAuthAuthorization == null) { - Response.Redirect("~/Members/AuthorizedConsumers.aspx"); - } 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; + protected void Page_Load(object sender, EventArgs e) { + if (!IsPostBack) { + if (Global.PendingOAuthAuthorization == null) { + Response.Redirect("~/Members/AuthorizedConsumers.aspx"); + } 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; - // 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 - // being scripted by an evil Consumer. - byte[] randomData = new byte[8]; - CryptoRandomDataGenerator.GetBytes(randomData); - this.AuthorizationSecret = Convert.ToBase64String(randomData); - OAuthAuthorizationSecToken.Value = this.AuthorizationSecret; + // 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 + // being scripted by an evil Consumer. + byte[] randomData = new byte[8]; + CryptoRandomDataGenerator.GetBytes(randomData); + this.AuthorizationSecret = Convert.ToBase64String(randomData); + OAuthAuthorizationSecToken.Value = this.AuthorizationSecret; - OAuth10ConsumerWarning.Visible = Global.PendingOAuthAuthorization.IsUnsafeRequest; + OAuth10ConsumerWarning.Visible = Global.PendingOAuthAuthorization.IsUnsafeRequest; + } } } - } - protected void allowAccessButton_Click(object sender, EventArgs e) { - if (this.AuthorizationSecret != OAuthAuthorizationSecToken.Value) { - throw new ArgumentException(); // probably someone trying to hack in. - } - this.AuthorizationSecret = null; // clear one time use secret - var pending = Global.PendingOAuthAuthorization; - Global.AuthorizePendingRequestToken(); - multiView.ActiveViewIndex = 1; + protected void allowAccessButton_Click(object sender, EventArgs e) { + if (this.AuthorizationSecret != OAuthAuthorizationSecToken.Value) { + throw new ArgumentException(); // probably someone trying to hack in. + } + this.AuthorizationSecret = null; // clear one time use secret + var pending = Global.PendingOAuthAuthorization; + Global.AuthorizePendingRequestToken(); + multiView.ActiveViewIndex = 1; - ServiceProvider sp = new ServiceProvider(Constants.SelfDescription, Global.TokenManager); - var response = sp.PrepareAuthorizationResponse(pending); - if (response != null) { - sp.Channel.Send(response); - } else { - if (pending.IsUnsafeRequest) { - verifierMultiView.ActiveViewIndex = 1; + ServiceProvider sp = new ServiceProvider(Constants.SelfDescription, Global.TokenManager); + var response = sp.PrepareAuthorizationResponse(pending); + if (response != null) { + sp.Channel.Send(response); } else { - string verifier = ServiceProvider.CreateVerificationCode(VerificationCodeFormat.AlphaNumericNoLookAlikes, 10); - verificationCodeLabel.Text = verifier; - ITokenContainingMessage requestTokenMessage = pending; - var requestToken = Global.TokenManager.GetRequestToken(requestTokenMessage.Token); - requestToken.VerificationCode = verifier; - Global.TokenManager.UpdateToken(requestToken); + if (pending.IsUnsafeRequest) { + verifierMultiView.ActiveViewIndex = 1; + } else { + string verifier = ServiceProvider.CreateVerificationCode(VerificationCodeFormat.AlphaNumericNoLookAlikes, 10); + verificationCodeLabel.Text = verifier; + ITokenContainingMessage requestTokenMessage = pending; + var requestToken = Global.TokenManager.GetRequestToken(requestTokenMessage.Token); + requestToken.VerificationCode = verifier; + Global.TokenManager.UpdateToken(requestToken); + } } } - } - protected void denyAccessButton_Click(object sender, EventArgs e) { - // erase the request token. - multiView.ActiveViewIndex = 2; + protected void denyAccessButton_Click(object sender, EventArgs e) { + // erase the request token. + multiView.ActiveViewIndex = 2; + } } -} +}
\ No newline at end of file diff --git a/samples/OAuthServiceProvider/Members/Authorize.aspx.designer.cs b/samples/OAuthServiceProvider/Members/Authorize.aspx.designer.cs index 44d801f..8aaf94d 100644 --- a/samples/OAuthServiceProvider/Members/Authorize.aspx.designer.cs +++ b/samples/OAuthServiceProvider/Members/Authorize.aspx.designer.cs @@ -7,97 +7,99 @@ // </auto-generated> //------------------------------------------------------------------------------ - - -public partial class Authorize { - - /// <summary> - /// multiView control. - /// </summary> - /// <remarks> - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// </remarks> - protected global::System.Web.UI.WebControls.MultiView multiView; - - /// <summary> - /// OAuthAuthorizationSecToken control. - /// </summary> - /// <remarks> - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// </remarks> - protected global::System.Web.UI.WebControls.HiddenField OAuthAuthorizationSecToken; - - /// <summary> - /// consumerLabel control. - /// </summary> - /// <remarks> - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// </remarks> - protected global::System.Web.UI.WebControls.Label consumerLabel; - - /// <summary> - /// desiredAccessLabel control. - /// </summary> - /// <remarks> - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// </remarks> - protected global::System.Web.UI.WebControls.Label desiredAccessLabel; - - /// <summary> - /// allowAccessButton control. - /// </summary> - /// <remarks> - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// </remarks> - protected global::System.Web.UI.WebControls.Button allowAccessButton; - - /// <summary> - /// denyAccessButton control. - /// </summary> - /// <remarks> - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// </remarks> - protected global::System.Web.UI.WebControls.Button denyAccessButton; - - /// <summary> - /// OAuth10ConsumerWarning control. - /// </summary> - /// <remarks> - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// </remarks> - protected global::System.Web.UI.WebControls.Panel OAuth10ConsumerWarning; - - /// <summary> - /// verifierMultiView control. - /// </summary> - /// <remarks> - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// </remarks> - protected global::System.Web.UI.WebControls.MultiView verifierMultiView; +namespace OAuthServiceProvider { - /// <summary> - /// verificationCodeLabel control. - /// </summary> - /// <remarks> - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// </remarks> - protected global::System.Web.UI.WebControls.Label verificationCodeLabel; - /// <summary> - /// View1 control. - /// </summary> - /// <remarks> - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// </remarks> - protected global::System.Web.UI.WebControls.View View1; + public partial class Authorize { + + /// <summary> + /// multiView control. + /// </summary> + /// <remarks> + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// </remarks> + protected global::System.Web.UI.WebControls.MultiView multiView; + + /// <summary> + /// OAuthAuthorizationSecToken control. + /// </summary> + /// <remarks> + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// </remarks> + protected global::System.Web.UI.WebControls.HiddenField OAuthAuthorizationSecToken; + + /// <summary> + /// consumerLabel control. + /// </summary> + /// <remarks> + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// </remarks> + protected global::System.Web.UI.WebControls.Label consumerLabel; + + /// <summary> + /// desiredAccessLabel control. + /// </summary> + /// <remarks> + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// </remarks> + protected global::System.Web.UI.WebControls.Label desiredAccessLabel; + + /// <summary> + /// allowAccessButton control. + /// </summary> + /// <remarks> + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// </remarks> + protected global::System.Web.UI.WebControls.Button allowAccessButton; + + /// <summary> + /// denyAccessButton control. + /// </summary> + /// <remarks> + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// </remarks> + protected global::System.Web.UI.WebControls.Button denyAccessButton; + + /// <summary> + /// OAuth10ConsumerWarning control. + /// </summary> + /// <remarks> + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// </remarks> + protected global::System.Web.UI.WebControls.Panel OAuth10ConsumerWarning; + + /// <summary> + /// verifierMultiView control. + /// </summary> + /// <remarks> + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// </remarks> + protected global::System.Web.UI.WebControls.MultiView verifierMultiView; + + /// <summary> + /// verificationCodeLabel control. + /// </summary> + /// <remarks> + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// </remarks> + protected global::System.Web.UI.WebControls.Label verificationCodeLabel; + + /// <summary> + /// View1 control. + /// </summary> + /// <remarks> + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// </remarks> + protected global::System.Web.UI.WebControls.View View1; + } } diff --git a/samples/OAuthServiceProvider/Members/AuthorizedConsumers.aspx b/samples/OAuthServiceProvider/Members/AuthorizedConsumers.aspx index 91ebd10..3506eb9 100644 --- a/samples/OAuthServiceProvider/Members/AuthorizedConsumers.aspx +++ b/samples/OAuthServiceProvider/Members/AuthorizedConsumers.aspx @@ -1,6 +1,6 @@ -<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" Inherits="AuthorizedConsumers" Codebehind="AuthorizedConsumers.aspx.cs" %> +<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" Inherits="OAuthServiceProvider.AuthorizedConsumers" Codebehind="AuthorizedConsumers.aspx.cs" %> <asp:Content ID="Content2" ContentPlaceHolderID="Body" runat="Server"> - <h2>The following consumers have access to your data</h2> - <p>TODO</p> + <h2>The following consumers have access to your data</h2> + <p>TODO</p> </asp:Content> diff --git a/samples/OAuthServiceProvider/Members/AuthorizedConsumers.aspx.cs b/samples/OAuthServiceProvider/Members/AuthorizedConsumers.aspx.cs index e7af629..fe647a8 100644 --- a/samples/OAuthServiceProvider/Members/AuthorizedConsumers.aspx.cs +++ b/samples/OAuthServiceProvider/Members/AuthorizedConsumers.aspx.cs @@ -1,15 +1,17 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Web; -using System.Web.UI; -using System.Web.UI.WebControls; +namespace OAuthServiceProvider { + using System; + using System.Collections.Generic; + using System.Linq; + using System.Web; + using System.Web.UI; + using System.Web.UI.WebControls; -/// <summary> -/// Lists the consumers that have active request or access tokens -/// and provides a mechanism for the user to revoke permissions. -/// </summary> -public partial class AuthorizedConsumers : System.Web.UI.Page { - protected void Page_Load(object sender, EventArgs e) { + /// <summary> + /// Lists the consumers that have active request or access tokens + /// and provides a mechanism for the user to revoke permissions. + /// </summary> + public partial class AuthorizedConsumers : System.Web.UI.Page { + protected void Page_Load(object sender, EventArgs e) { + } } -} +}
\ No newline at end of file diff --git a/samples/OAuthServiceProvider/Members/AuthorizedConsumers.aspx.designer.cs b/samples/OAuthServiceProvider/Members/AuthorizedConsumers.aspx.designer.cs index 6c8c691..419c114 100644 --- a/samples/OAuthServiceProvider/Members/AuthorizedConsumers.aspx.designer.cs +++ b/samples/OAuthServiceProvider/Members/AuthorizedConsumers.aspx.designer.cs @@ -7,7 +7,9 @@ // </auto-generated> //------------------------------------------------------------------------------ - - -public partial class AuthorizedConsumers { +namespace OAuthServiceProvider { + + + public partial class AuthorizedConsumers { + } } diff --git a/samples/OAuthServiceProvider/OAuth.ashx b/samples/OAuthServiceProvider/OAuth.ashx index 46a516f..8a74926 100644 --- a/samples/OAuthServiceProvider/OAuth.ashx +++ b/samples/OAuthServiceProvider/OAuth.ashx @@ -8,6 +8,7 @@ using DotNetOpenAuth.OAuth; using DotNetOpenAuth.OAuth.ChannelElements; using DotNetOpenAuth.OAuth.Messages; using DotNetOpenAuth.Messaging; +using OAuthServiceProvider.Code; public class OAuth : IHttpHandler, IRequiresSessionState { ServiceProvider sp; diff --git a/samples/OAuthServiceProvider/OAuthServiceProvider.csproj b/samples/OAuthServiceProvider/OAuthServiceProvider.csproj index 2c2f28f..68b2d90 100644 --- a/samples/OAuthServiceProvider/OAuthServiceProvider.csproj +++ b/samples/OAuthServiceProvider/OAuthServiceProvider.csproj @@ -82,7 +82,6 @@ <Compile Include="Code\Constants.cs" /> <Compile Include="Code\CustomOAuthTypeProvider.cs" /> <Compile Include="Code\DatabaseTokenManager.cs" /> - <Compile Include="Code\DataClasses.designer.cs" /> <Compile Include="Code\Global.cs" /> <Compile Include="Code\IDataApi.cs" /> <Compile Include="Code\OAuthAuthorizationManager.cs" /> @@ -93,7 +92,7 @@ <Compile Include="Code\TokenAuthorizationState.cs" /> <Compile Include="Code\TracePageAppender.cs" /> <Compile Include="Code\Utilities.cs" /> - <Compile Include="Code\DataClasses1.designer.cs"> + <Compile Include="Code\DataClasses.designer.cs"> <AutoGen>True</AutoGen> <DesignTime>True</DesignTime> <DependentUpon>DataClasses.dbml</DependentUpon> @@ -130,7 +129,7 @@ <ItemGroup> <None Include="Code\DataClasses.dbml"> <Generator>MSLinqToSQLGenerator</Generator> - <LastGenOutput>DataClasses1.designer.cs</LastGenOutput> + <LastGenOutput>DataClasses.designer.cs</LastGenOutput> <SubType>Designer</SubType> </None> <Content Include="Members\Web.config" /> diff --git a/samples/OAuthServiceProvider/TracePage.aspx b/samples/OAuthServiceProvider/TracePage.aspx index 1b686db..e83adc3 100644 --- a/samples/OAuthServiceProvider/TracePage.aspx +++ b/samples/OAuthServiceProvider/TracePage.aspx @@ -1,4 +1,4 @@ -<%@ Page Language="C#" AutoEventWireup="true" Inherits="TracePage" Codebehind="TracePage.aspx.cs" %> +<%@ Page Language="C#" AutoEventWireup="true" Inherits="OAuthServiceProvider.TracePage" Codebehind="TracePage.aspx.cs" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> diff --git a/samples/OAuthServiceProvider/TracePage.aspx.cs b/samples/OAuthServiceProvider/TracePage.aspx.cs index 52848f2..fcfade5 100644 --- a/samples/OAuthServiceProvider/TracePage.aspx.cs +++ b/samples/OAuthServiceProvider/TracePage.aspx.cs @@ -1,21 +1,24 @@ -using System; -using System.Collections.Generic; -using System.Web; -using System.Web.UI; -using System.Web.UI.WebControls; +namespace OAuthServiceProvider { + using System; + using System.Collections.Generic; + using System.Web; + using System.Web.UI; + using System.Web.UI.WebControls; + using OAuthServiceProvider.Code; -/// <summary> -/// A page to display recent log messages. -/// </summary> -public partial class TracePage : System.Web.UI.Page { - protected void Page_Load(object sender, EventArgs e) { - this.placeHolder1.Controls.Add(new Label { Text = HttpUtility.HtmlEncode(Global.LogMessages.ToString()) }); - } + /// <summary> + /// A page to display recent log messages. + /// </summary> + public partial class TracePage : System.Web.UI.Page { + protected void Page_Load(object sender, EventArgs e) { + this.placeHolder1.Controls.Add(new Label { Text = HttpUtility.HtmlEncode(Global.LogMessages.ToString()) }); + } - protected void clearLogButton_Click(object sender, EventArgs e) { - Global.LogMessages.Length = 0; + protected void clearLogButton_Click(object sender, EventArgs e) { + Global.LogMessages.Length = 0; - // clear the page immediately, and allow for F5 without a Postback warning. - Response.Redirect(Request.Url.AbsoluteUri); + // clear the page immediately, and allow for F5 without a Postback warning. + Response.Redirect(Request.Url.AbsoluteUri); + } } -} +}
\ No newline at end of file diff --git a/samples/OAuthServiceProvider/TracePage.aspx.designer.cs b/samples/OAuthServiceProvider/TracePage.aspx.designer.cs index 6a0028b..3cd04be 100644 --- a/samples/OAuthServiceProvider/TracePage.aspx.designer.cs +++ b/samples/OAuthServiceProvider/TracePage.aspx.designer.cs @@ -7,34 +7,36 @@ // </auto-generated> //------------------------------------------------------------------------------ - - -public partial class TracePage { - - /// <summary> - /// form1 control. - /// </summary> - /// <remarks> - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// </remarks> - protected global::System.Web.UI.HtmlControls.HtmlForm form1; +namespace OAuthServiceProvider { - /// <summary> - /// clearLogButton control. - /// </summary> - /// <remarks> - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// </remarks> - protected global::System.Web.UI.WebControls.Button clearLogButton; - /// <summary> - /// placeHolder1 control. - /// </summary> - /// <remarks> - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// </remarks> - protected global::System.Web.UI.WebControls.PlaceHolder placeHolder1; + public partial class TracePage { + + /// <summary> + /// form1 control. + /// </summary> + /// <remarks> + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// </remarks> + protected global::System.Web.UI.HtmlControls.HtmlForm form1; + + /// <summary> + /// clearLogButton control. + /// </summary> + /// <remarks> + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// </remarks> + protected global::System.Web.UI.WebControls.Button clearLogButton; + + /// <summary> + /// placeHolder1 control. + /// </summary> + /// <remarks> + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// </remarks> + protected global::System.Web.UI.WebControls.PlaceHolder placeHolder1; + } } diff --git a/samples/OAuthServiceProvider/Web.config b/samples/OAuthServiceProvider/Web.config index 88cd118..dc440fd 100644 --- a/samples/OAuthServiceProvider/Web.config +++ b/samples/OAuthServiceProvider/Web.config @@ -129,7 +129,7 @@ </assemblyBinding> </runtime> <log4net> - <appender name="TracePageAppender" type="TracePageAppender, OAuthServiceProvider"> + <appender name="TracePageAppender" type="OAuthServiceProvider.Code.TracePageAppender, OAuthServiceProvider"> <layout type="log4net.Layout.PatternLayout"> <conversionPattern value="%date (GMT%date{%z}) [%thread] %-5level %logger - %message%newline"/> </layout> @@ -151,13 +151,13 @@ <behavior name="DataApiBehavior"> <serviceMetadata httpGetEnabled="true"/> <serviceDebug includeExceptionDetailInFaults="true"/> - <serviceAuthorization serviceAuthorizationManagerType="OAuthAuthorizationManager, OAuthServiceProvider" principalPermissionMode="Custom"/> + <serviceAuthorization serviceAuthorizationManagerType="OAuthServiceProvider.Code.OAuthAuthorizationManager, OAuthServiceProvider" principalPermissionMode="Custom"/> </behavior> </serviceBehaviors> </behaviors> <services> - <service behaviorConfiguration="DataApiBehavior" name="DataApi"> - <endpoint address="" binding="wsHttpBinding" contract="IDataApi"> + <service behaviorConfiguration="DataApiBehavior" name="OAuthServiceProvider.DataApi"> + <endpoint address="" binding="wsHttpBinding" contract="OAuthServiceProvider.Code.IDataApi"> <identity> <dns value="localhost"/> </identity> |