diff options
Diffstat (limited to 'src/InfoCard')
-rw-r--r-- | src/InfoCard/InfoCardRelyingParty/App_Code/Logging.cs | 16 | ||||
-rw-r--r-- | src/InfoCard/InfoCardRelyingParty/App_Code/TracePageAppender.cs | 8 | ||||
-rw-r--r-- | src/InfoCard/InfoCardRelyingParty/Default.aspx | 11 | ||||
-rw-r--r-- | src/InfoCard/InfoCardRelyingParty/Global.asax | 58 | ||||
-rw-r--r-- | src/InfoCard/InfoCardRelyingParty/Login.aspx | 34 | ||||
-rw-r--r-- | src/InfoCard/InfoCardRelyingParty/MembersOnly/Default.aspx | 12 | ||||
-rw-r--r-- | src/InfoCard/InfoCardRelyingParty/MembersOnly/Web.config | 18 | ||||
-rw-r--r-- | src/InfoCard/InfoCardRelyingParty/Site.Master | 31 | ||||
-rw-r--r-- | src/InfoCard/InfoCardRelyingParty/TracePage.aspx | 18 | ||||
-rw-r--r-- | src/InfoCard/InfoCardRelyingParty/TracePage.aspx.cs | 21 | ||||
-rw-r--r-- | src/InfoCard/InfoCardRelyingParty/favicon.ico | bin | 0 -> 1150 bytes | |||
-rw-r--r-- | src/InfoCard/InfoCardRelyingParty/images/DotNetOpenAuth.png | bin | 0 -> 25212 bytes | |||
-rw-r--r-- | src/InfoCard/InfoCardRelyingParty/packages.config | 9 | ||||
-rw-r--r-- | src/InfoCard/InfoCardRelyingParty/styles.css | 10 | ||||
-rw-r--r-- | src/InfoCard/InfoCardRelyingParty/web.config | 119 |
15 files changed, 365 insertions, 0 deletions
diff --git a/src/InfoCard/InfoCardRelyingParty/App_Code/Logging.cs b/src/InfoCard/InfoCardRelyingParty/App_Code/Logging.cs new file mode 100644 index 0000000..64ecebc --- /dev/null +++ b/src/InfoCard/InfoCardRelyingParty/App_Code/Logging.cs @@ -0,0 +1,16 @@ +using System.Text; + +/// <summary> +/// Logging tools for this sample. +/// </summary> +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.InfoCardRelyingParty"); +} diff --git a/src/InfoCard/InfoCardRelyingParty/App_Code/TracePageAppender.cs b/src/InfoCard/InfoCardRelyingParty/App_Code/TracePageAppender.cs new file mode 100644 index 0000000..91ccee5 --- /dev/null +++ b/src/InfoCard/InfoCardRelyingParty/App_Code/TracePageAppender.cs @@ -0,0 +1,8 @@ +using System.IO; + +public class TracePageAppender : log4net.Appender.AppenderSkeleton { + protected override void Append(log4net.Core.LoggingEvent loggingEvent) { + StringWriter sw = new StringWriter(Logging.LogMessages); + Layout.Format(sw, loggingEvent); + } +} diff --git a/src/InfoCard/InfoCardRelyingParty/Default.aspx b/src/InfoCard/InfoCardRelyingParty/Default.aspx new file mode 100644 index 0000000..2962605 --- /dev/null +++ b/src/InfoCard/InfoCardRelyingParty/Default.aspx @@ -0,0 +1,11 @@ +<%@ Page Title="" Language="VB" MasterPageFile="~/Site.Master" %> + +<script runat="server"> + +</script> + +<asp:Content ID="Content2" ContentPlaceHolderID="Main" runat="Server"> + <h2>InfoCard Relying Party </h2> + <p>Visit the <asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl="~/MembersOnly/Default.aspx" + Text="Members Only" /> area. (This will trigger a login demo). </p> +</asp:Content> diff --git a/src/InfoCard/InfoCardRelyingParty/Global.asax b/src/InfoCard/InfoCardRelyingParty/Global.asax new file mode 100644 index 0000000..4d35280 --- /dev/null +++ b/src/InfoCard/InfoCardRelyingParty/Global.asax @@ -0,0 +1,58 @@ +<%@ Application Language="C#" %> +<%@ Import Namespace="System.IO" %> + +<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 Application_BeginRequest(object sender, EventArgs e) { + Logging.Logger.DebugFormat("Processing {0} on {1} ", Request.HttpMethod, stripQueryString(Request.Url)); + if (Request.QueryString.Count > 0) { + Logging.Logger.DebugFormat("Querystring follows: \n{0}", ToString(Request.QueryString)); + } + if (Request.Form.Count > 0) { + Logging.Logger.DebugFormat("Posted form follows: \n{0}", ToString(Request.Form)); + } + } + + 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. + + } + + private static string ToString(NameValueCollection collection) { + using (StringWriter sw = new StringWriter()) { + foreach (string key in collection.Keys) { + sw.WriteLine("{0} = '{1}'", key, collection[key]); + } + return sw.ToString(); + } + } + + private static string stripQueryString(Uri uri) { + UriBuilder builder = new UriBuilder(uri); + builder.Query = null; + return builder.ToString(); + } + + </script> diff --git a/src/InfoCard/InfoCardRelyingParty/Login.aspx b/src/InfoCard/InfoCardRelyingParty/Login.aspx new file mode 100644 index 0000000..b4b7f2f --- /dev/null +++ b/src/InfoCard/InfoCardRelyingParty/Login.aspx @@ -0,0 +1,34 @@ +<%@ Page Title="" Language="VB" MasterPageFile="~/Site.Master" AutoEventWireup="false" + ValidateRequest="false" %> + +<%@ Import Namespace="DotNetOpenAuth.InfoCard" %> + +<script runat="server"> + Protected Sub InfoCardSelector1_ReceivedToken(ByVal sender As Object, ByVal e As ReceivedTokenEventArgs) Handles InfoCardSelector1.ReceivedToken + Session("SiteSpecificID") = e.Token.SiteSpecificId + FormsAuthentication.RedirectFromLoginPage(e.Token.UniqueId, False) + End Sub + + Protected Sub InfoCardSelector1_TokenProcessingError(ByVal sender As Object, ByVal e As TokenProcessingErrorEventArgs) Handles InfoCardSelector1.TokenProcessingError + errorLabel.Text = HttpUtility.HtmlEncode(e.Exception.Message) + errorLabel.Visible = True + End Sub +</script> + +<%@ Register Assembly="DotNetOpenAuth.InfoCard.UI" Namespace="DotNetOpenAuth.InfoCard" TagPrefix="ic" %> +<asp:Content ID="Content2" ContentPlaceHolderID="Main" runat="Server"> + <p>This login page demonstrates logging in using the InfoCard selector. Click the InfoCard + image below to login. </p> + <ic:InfoCardSelector runat="server" ID="InfoCardSelector1"> + <ClaimsRequested> + <ic:ClaimType Name="http://schemas.xmlsoap.org/ws/2005/05/identity/claims/privatepersonalidentifier" /> + </ClaimsRequested> + <UnsupportedTemplate> + <p>You're using a browser that doesn't seem to have Information Card Selector support. + </p> + <p>In a real web application you might want to put an alternate login method here, or + a link to find out how to enable the user's browser to use InfoCards. </p> + </UnsupportedTemplate> + </ic:InfoCardSelector> + <asp:Label runat="server" EnableViewState="false" Visible="false" ForeColor="Red" ID="errorLabel" /> +</asp:Content> diff --git a/src/InfoCard/InfoCardRelyingParty/MembersOnly/Default.aspx b/src/InfoCard/InfoCardRelyingParty/MembersOnly/Default.aspx new file mode 100644 index 0000000..1c6cae9 --- /dev/null +++ b/src/InfoCard/InfoCardRelyingParty/MembersOnly/Default.aspx @@ -0,0 +1,12 @@ +<%@ Page Language="VB" AutoEventWireup="true" MasterPageFile="~/Site.Master" %> + +<asp:Content ID="Content1" runat="server" ContentPlaceHolderID="Main"> + <h2> + Members Only Area + </h2> + <p> + Congratulations, <b><%= Session("SiteSpecificID") %></b>. + You have completed the InfoCard login process. + </p> + <p>Your secure unique ID on this site is <asp:LoginName ID="LoginName1" runat="server" />.</p> +</asp:Content> diff --git a/src/InfoCard/InfoCardRelyingParty/MembersOnly/Web.config b/src/InfoCard/InfoCardRelyingParty/MembersOnly/Web.config new file mode 100644 index 0000000..3cfad05 --- /dev/null +++ b/src/InfoCard/InfoCardRelyingParty/MembersOnly/Web.config @@ -0,0 +1,18 @@ +<?xml version="1.0"?> +<!-- + Note: As an alternative to hand editing this file you can use the + web admin tool to configure settings for your application. Use + the Website->Asp.Net Configuration option in Visual Studio. + A full list of settings and comments can be found in + machine.config.comments usually located in + \Windows\Microsoft.Net\Framework\v2.x\Config +--> +<configuration> + <appSettings/> + <connectionStrings/> + <system.web> + <authorization> + <deny users="?"/> + </authorization> + </system.web> +</configuration> diff --git a/src/InfoCard/InfoCardRelyingParty/Site.Master b/src/InfoCard/InfoCardRelyingParty/Site.Master new file mode 100644 index 0000000..bd3f896 --- /dev/null +++ b/src/InfoCard/InfoCardRelyingParty/Site.Master @@ -0,0 +1,31 @@ +<%@ Master Language="C#" AutoEventWireup="true" %> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> + +<script runat="server"> + protected void Page_Load(object sender, EventArgs e) { + } +</script> + +<html xmlns="http://www.w3.org/1999/xhtml"> +<head runat="server"> + <title>InfoCard Relying Party, by DotNetOpenAuth</title> + <link href="styles.css" rel="stylesheet" type="text/css" /> + <asp:ContentPlaceHolder ID="head" runat="server" /> +</head> +<body> + <form id="form1" runat="server"> + <span style="float: right"> + <asp:Label runat="server" ID="friendlyUsername" Text="" EnableViewState="false" /> + <asp:LoginStatus ID="LoginStatus1" runat="server" /> + </span> + <div> + <a href="http://dotnetopenauth.net"> + <img runat="server" src="~/images/DotNetOpenAuth.png" title="Jump to the project web site." + alt="DotNetOpenAuth" border='0' /></a> + </div> + <div> + <asp:ContentPlaceHolder ID="Main" runat="server" /> + </div> + </form> +</body> +</html> diff --git a/src/InfoCard/InfoCardRelyingParty/TracePage.aspx b/src/InfoCard/InfoCardRelyingParty/TracePage.aspx new file mode 100644 index 0000000..4d6ecc5 --- /dev/null +++ b/src/InfoCard/InfoCardRelyingParty/TracePage.aspx @@ -0,0 +1,18 @@ +<%@ Page Language="C#" AutoEventWireup="true" CodeFile="TracePage.aspx.cs" Inherits="TracePage" %> + +<!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"> +<head runat="server"> + <title></title> +</head> +<body> + <form id="form1" runat="server"> + <p align="right"> + <asp:Button runat="server" Text="Clear log" ID="clearLogButton" OnClick="clearLogButton_Click" /> + </p> + <pre> + <asp:PlaceHolder runat="server" ID="placeHolder1" /> + </pre> + </form> +</body> +</html> diff --git a/src/InfoCard/InfoCardRelyingParty/TracePage.aspx.cs b/src/InfoCard/InfoCardRelyingParty/TracePage.aspx.cs new file mode 100644 index 0000000..7075ce3 --- /dev/null +++ b/src/InfoCard/InfoCardRelyingParty/TracePage.aspx.cs @@ -0,0 +1,21 @@ +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()) }); + } + + 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); + } +} diff --git a/src/InfoCard/InfoCardRelyingParty/favicon.ico b/src/InfoCard/InfoCardRelyingParty/favicon.ico Binary files differnew file mode 100644 index 0000000..e227dbe --- /dev/null +++ b/src/InfoCard/InfoCardRelyingParty/favicon.ico diff --git a/src/InfoCard/InfoCardRelyingParty/images/DotNetOpenAuth.png b/src/InfoCard/InfoCardRelyingParty/images/DotNetOpenAuth.png Binary files differnew file mode 100644 index 0000000..442b986 --- /dev/null +++ b/src/InfoCard/InfoCardRelyingParty/images/DotNetOpenAuth.png diff --git a/src/InfoCard/InfoCardRelyingParty/packages.config b/src/InfoCard/InfoCardRelyingParty/packages.config new file mode 100644 index 0000000..4e74ce2 --- /dev/null +++ b/src/InfoCard/InfoCardRelyingParty/packages.config @@ -0,0 +1,9 @@ +<?xml version="1.0" encoding="utf-8"?> +<packages> + <package id="CodeContracts.Unofficial" version="1.0.0.2" /> + <package id="DotNetOpenAuth.Core" version="4.0.0-RC1" /> + <package id="DotNetOpenAuth.Core.UI" version="4.0.0-RC1" /> + <package id="DotNetOpenAuth.InfoCard" version="4.0.0-RC1" /> + <package id="DotNetOpenAuth.InfoCard.UI" version="4.0.0-RC1" /> + <package id="log4net" version="2.0.0" /> +</packages>
\ No newline at end of file diff --git a/src/InfoCard/InfoCardRelyingParty/styles.css b/src/InfoCard/InfoCardRelyingParty/styles.css new file mode 100644 index 0000000..2e4d3db --- /dev/null +++ b/src/InfoCard/InfoCardRelyingParty/styles.css @@ -0,0 +1,10 @@ +h2 +{ + font-style: italic; +} + +body +{ + font-family: Cambria, Arial, Times New Roman; + font-size: 12pt; +}
\ No newline at end of file diff --git a/src/InfoCard/InfoCardRelyingParty/web.config b/src/InfoCard/InfoCardRelyingParty/web.config new file mode 100644 index 0000000..c381f33 --- /dev/null +++ b/src/InfoCard/InfoCardRelyingParty/web.config @@ -0,0 +1,119 @@ +<?xml version="1.0" encoding="utf-8"?> +<configuration> + <configSections> + <section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler" requirePermission="false" /> + <sectionGroup name="dotNetOpenAuth" type="DotNetOpenAuth.Configuration.DotNetOpenAuthSection, DotNetOpenAuth.Core"> + <section name="oauth" type="DotNetOpenAuth.Configuration.OAuthElement, DotNetOpenAuth.OAuth" requirePermission="false" allowLocation="true" /> + <section name="messaging" type="DotNetOpenAuth.Configuration.MessagingElement, DotNetOpenAuth.Core" requirePermission="false" allowLocation="true" /> + <section name="reporting" type="DotNetOpenAuth.Configuration.ReportingElement, DotNetOpenAuth.Core" requirePermission="false" allowLocation="true" /> + </sectionGroup> + </configSections> + <!-- this is an optional configuration section where aspects of dotnetopenauth can be customized --> + <dotNetOpenAuth> + <!-- Allow DotNetOpenAuth to publish usage statistics to library authors to improve the library. --> + <reporting enabled="true" /> + <messaging> + <untrustedWebRequest> + <whitelistHosts> + <!-- Uncomment to enable communication with localhost (should generally not activate in production!) --> + <!--<add name="localhost" />--> + </whitelistHosts> + </untrustedWebRequest> + </messaging> + </dotNetOpenAuth> + <log4net> + <appender name="TracePageAppender" type="TracePageAppender, __code"> + <layout type="log4net.Layout.PatternLayout"> + <conversionPattern value="%date (GMT%date{%z}) [%thread] %-5level %logger - %message%newline" /> + </layout> + </appender> + <!-- Setup the root category, add the appenders and set the default level --> + <root> + <level value="INFO" /> + <!--<appender-ref ref="RollingFileAppender" />--> + <appender-ref ref="TracePageAppender" /> + </root> + <!-- Specify the level for some specific categories --> + <logger name="DotNetOpenAuth"> + <level value="ALL" /> + </logger> + </log4net> + <system.net> + <defaultProxy enabled="true" /> + <settings> + <!-- This setting causes .NET to check certificate revocation lists (CRL) + before trusting HTTPS certificates. But this setting tends to not + be allowed in shared hosting environments. --> + <!--<servicePointManager checkCertificateRevocationList="true"/>--> + </settings> + </system.net> + <appSettings /> + <connectionStrings /> + <system.web> + <!-- + Set compilation debug="true" to insert debugging + symbols into the compiled page. Because this + affects performance, set this value to true only + during development. + + Visual Basic options: + Set strict="true" to disallow all data type conversions + where data loss can occur. + Set explicit="true" to force declaration of all variables. + --> + <compilation debug="true" strict="false" explicit="true" targetFramework="4.0"> + <assemblies> + <remove assembly="DotNetOpenAuth.Contracts" /> + </assemblies> + </compilation> + <pages controlRenderingCompatibilityVersion="3.5" clientIDMode="AutoID"> + <namespaces> + <clear /> + <add namespace="System" /> + <add namespace="System.Collections" /> + <add namespace="System.Collections.Generic" /> + <add namespace="System.Collections.Specialized" /> + <add namespace="System.Configuration" /> + <add namespace="System.Text" /> + <add namespace="System.Text.RegularExpressions" /> + <add namespace="System.Linq" /> + <add namespace="System.Xml.Linq" /> + <add namespace="System.Web" /> + <add namespace="System.Web.Caching" /> + <add namespace="System.Web.SessionState" /> + <add namespace="System.Web.Security" /> + <add namespace="System.Web.Profile" /> + <add namespace="System.Web.UI" /> + <add namespace="System.Web.UI.WebControls" /> + <add namespace="System.Web.UI.WebControls.WebParts" /> + <add namespace="System.Web.UI.HtmlControls" /> + </namespaces> + </pages> + <!-- + The <authentication> section enables configuration + of the security authentication mode used by + ASP.NET to identify an incoming user. + --> + <authentication mode="Forms" /> + <!-- + The <customErrors> section enables configuration + of what to do if/when an unhandled error occurs + during the execution of a request. Specifically, + it enables developers to configure html error pages + to be displayed in place of a error stack trace. + + <customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm"> + <error statusCode="403" redirect="NoAccess.htm" /> + <error statusCode="404" redirect="FileNotFound.htm" /> + </customErrors> + --> + </system.web> + <!-- + The system.webServer section is required for running ASP.NET AJAX under Internet + Information Services 7.0. It is not necessary for previous version of IIS. + --> + <runtime> + <!-- This prevents the Windows Event Log from frequently logging that HMAC1 is being used (when the other party needs it). --> + <legacyHMACWarning enabled="0" /> + </runtime> +</configuration>
\ No newline at end of file |