summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/DotNetOpenAuth/Configuration/DotNetOpenAuth.xsd5
-rw-r--r--src/DotNetOpenAuth/Configuration/DotNetOpenAuthSection.cs14
-rw-r--r--src/DotNetOpenAuth/Configuration/ReportingElement.cs39
-rw-r--r--src/DotNetOpenAuth/DotNetOpenAuth.csproj2
-rw-r--r--src/DotNetOpenAuth/OpenId/RelyingParty/PositiveAuthenticationResponse.cs1
-rw-r--r--src/DotNetOpenAuth/Properties/AssemblyInfo.cs4
-rw-r--r--src/DotNetOpenAuth/Reporting.cs49
7 files changed, 113 insertions, 1 deletions
diff --git a/src/DotNetOpenAuth/Configuration/DotNetOpenAuth.xsd b/src/DotNetOpenAuth/Configuration/DotNetOpenAuth.xsd
index a637d1f..873ae0e 100644
--- a/src/DotNetOpenAuth/Configuration/DotNetOpenAuth.xsd
+++ b/src/DotNetOpenAuth/Configuration/DotNetOpenAuth.xsd
@@ -313,6 +313,11 @@
</xs:choice>
</xs:complexType>
</xs:element>
+ <xs:element name="reporting">
+ <xs:complexType>
+ <xs:attribute name="enabled" type="xs:boolean" />
+ </xs:complexType>
+ </xs:element>
</xs:choice>
</xs:complexType>
</xs:element>
diff --git a/src/DotNetOpenAuth/Configuration/DotNetOpenAuthSection.cs b/src/DotNetOpenAuth/Configuration/DotNetOpenAuthSection.cs
index 7bd84d9..aa956d1 100644
--- a/src/DotNetOpenAuth/Configuration/DotNetOpenAuthSection.cs
+++ b/src/DotNetOpenAuth/Configuration/DotNetOpenAuthSection.cs
@@ -35,6 +35,11 @@ namespace DotNetOpenAuth.Configuration {
private const string OAuthElementName = "oauth";
/// <summary>
+ /// The name of the &lt;reporting&gt; sub-element.
+ /// </summary>
+ private const string ReportingElementName = "reporting";
+
+ /// <summary>
/// Initializes a new instance of the <see cref="DotNetOpenAuthSection"/> class.
/// </summary>
internal DotNetOpenAuthSection() {
@@ -75,5 +80,14 @@ namespace DotNetOpenAuth.Configuration {
get { return (OAuthElement)this[OAuthElementName] ?? new OAuthElement(); }
set { this[OAuthElementName] = value; }
}
+
+ /// <summary>
+ /// Gets or sets the configuration for reporting.
+ /// </summary>
+ [ConfigurationProperty(ReportingElementName)]
+ internal ReportingElement Reporting {
+ get { return (ReportingElement)this[ReportingElementName] ?? new ReportingElement(); }
+ set { this[ReportingElementName] = value; }
+ }
}
}
diff --git a/src/DotNetOpenAuth/Configuration/ReportingElement.cs b/src/DotNetOpenAuth/Configuration/ReportingElement.cs
new file mode 100644
index 0000000..68bee74
--- /dev/null
+++ b/src/DotNetOpenAuth/Configuration/ReportingElement.cs
@@ -0,0 +1,39 @@
+//-----------------------------------------------------------------------
+// <copyright file="ReportingElement.cs" company="Andrew Arnott">
+// Copyright (c) Andrew Arnott. All rights reserved.
+// </copyright>
+//-----------------------------------------------------------------------
+
+namespace DotNetOpenAuth.Configuration {
+ using System;
+ using System.Collections.Generic;
+ using System.Linq;
+ using System.Text;
+ using System.Configuration;
+
+ /// <summary>
+ /// Represents the &lt;reporting&gt; element in the host's .config file.
+ /// </summary>
+ internal class ReportingElement : ConfigurationElement {
+ /// <summary>
+ /// The name of the @enabled attribute.
+ /// </summary>
+ private const string EnabledAttributeName = "enabled";
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="ReportingElement"/> class.
+ /// </summary>
+ internal ReportingElement() {
+ }
+
+ /// <summary>
+ /// Gets or sets a value indicating whether this reporting is enabled.
+ /// </summary>
+ /// <value><c>true</c> if enabled; otherwise, <c>false</c>.</value>
+ [ConfigurationProperty(EnabledAttributeName, DefaultValue = true)]
+ internal bool Enabled {
+ get { return (bool)this[EnabledAttributeName]; }
+ set { this[EnabledAttributeName] = value; }
+ }
+ }
+}
diff --git a/src/DotNetOpenAuth/DotNetOpenAuth.csproj b/src/DotNetOpenAuth/DotNetOpenAuth.csproj
index 42b99fd..4b73c05 100644
--- a/src/DotNetOpenAuth/DotNetOpenAuth.csproj
+++ b/src/DotNetOpenAuth/DotNetOpenAuth.csproj
@@ -229,6 +229,7 @@ http://opensource.org/licenses/ms-pl.html
<Compile Include="Configuration\OpenIdProviderSecuritySettingsElement.cs" />
<Compile Include="Configuration\OpenIdRelyingPartyElement.cs" />
<Compile Include="Configuration\OpenIdRelyingPartySecuritySettingsElement.cs" />
+ <Compile Include="Configuration\ReportingElement.cs" />
<Compile Include="Configuration\TypeConfigurationCollection.cs" />
<Compile Include="Configuration\TypeConfigurationElement.cs" />
<Compile Include="Configuration\UntrustedWebRequestElement.cs" />
@@ -556,6 +557,7 @@ http://opensource.org/licenses/ms-pl.html
<Compile Include="OAuth\ChannelElements\RsaSha1SigningBindingElement.cs" />
<Compile Include="Messaging\StandardWebRequestHandler.cs" />
<Compile Include="Messaging\MessageReceivingEndpoint.cs" />
+ <Compile Include="Reporting.cs" />
<Compile Include="Util.cs" />
<Compile Include="OAuth\Protocol.cs" />
<Compile Include="OAuth\ServiceProvider.cs" />
diff --git a/src/DotNetOpenAuth/OpenId/RelyingParty/PositiveAuthenticationResponse.cs b/src/DotNetOpenAuth/OpenId/RelyingParty/PositiveAuthenticationResponse.cs
index e809205..d4d0cdc 100644
--- a/src/DotNetOpenAuth/OpenId/RelyingParty/PositiveAuthenticationResponse.cs
+++ b/src/DotNetOpenAuth/OpenId/RelyingParty/PositiveAuthenticationResponse.cs
@@ -37,6 +37,7 @@ namespace DotNetOpenAuth.OpenId.RelyingParty {
null);
this.VerifyDiscoveryMatchesAssertion(relyingParty);
+ Reporting.OnAuthenticated();
}
#region IAuthenticationResponse Properties
diff --git a/src/DotNetOpenAuth/Properties/AssemblyInfo.cs b/src/DotNetOpenAuth/Properties/AssemblyInfo.cs
index 51d146c..0bba853 100644
--- a/src/DotNetOpenAuth/Properties/AssemblyInfo.cs
+++ b/src/DotNetOpenAuth/Properties/AssemblyInfo.cs
@@ -83,13 +83,15 @@ using System.Web.UI;
// match the one used by hosting providers. Listing them individually seems to be more common.
[assembly: WebPermission(SecurityAction.RequestMinimum, ConnectPattern = @"http://.*")]
[assembly: WebPermission(SecurityAction.RequestMinimum, ConnectPattern = @"https://.*")]
-
#if PARTIAL_TRUST
// Allows hosting this assembly in an ASP.NET setting. Not all applications
// will host this using ASP.NET, so this is optional. Besides, we need at least
// one optional permission to activate CAS permission shrinking.
[assembly: AspNetHostingPermission(SecurityAction.RequestOptional, Level = AspNetHostingPermissionLevel.Medium)]
+// Allows this assembly to store reporting data.
+[assembly: IsolatedStorageFilePermission(SecurityAction.RequestOptional, UsageAllowed = IsolatedStorageContainment.AssemblyIsolationByUser)]
+
// The following are only required for diagnostic logging (Trace.Write, Debug.Assert, etc.).
#if TRACE || DEBUG
[assembly: KeyContainerPermission(SecurityAction.RequestOptional, Unrestricted = true)]
diff --git a/src/DotNetOpenAuth/Reporting.cs b/src/DotNetOpenAuth/Reporting.cs
new file mode 100644
index 0000000..e325993
--- /dev/null
+++ b/src/DotNetOpenAuth/Reporting.cs
@@ -0,0 +1,49 @@
+//-----------------------------------------------------------------------
+// <copyright file="Reporting.cs" company="Andrew Arnott">
+// Copyright (c) Andrew Arnott. All rights reserved.
+// </copyright>
+//-----------------------------------------------------------------------
+
+namespace DotNetOpenAuth {
+ using System;
+ using System.Collections.Generic;
+ using System.Linq;
+ using System.Text;
+ using DotNetOpenAuth.Configuration;
+ using System.IO;
+ using System.Reflection;
+ using System.Diagnostics;
+ using System.IO.IsolatedStorage;
+
+ internal static class Reporting {
+ private static StreamWriter writer;
+
+ static Reporting() {
+ Enabled = DotNetOpenAuthSection.Configuration.Reporting.Enabled;
+ if (Enabled) {
+ try {
+ IsolatedStorageFile file = IsolatedStorageFile.GetUserStoreForDomain();
+ var assemblyName = new AssemblyName(Assembly.GetExecutingAssembly().FullName);
+ var fileStream = new IsolatedStorageFileStream("reporting.txt", FileMode.OpenOrCreate, FileAccess.Write, FileShare.Read);
+ writer = new StreamWriter(fileStream, Encoding.UTF8);
+ writer.AutoFlush = true;
+ writer.WriteLine();
+ writer.WriteLine(Util.LibraryVersion);
+ } catch {
+ // This is supposed to be as low-risk as possible, so if it fails, just disable reporting.
+ Enabled = false;
+ }
+ }
+ }
+
+ internal static bool Enabled { get; set; }
+
+ internal static void OnAuthenticated() {
+ if (!Enabled) {
+ return;
+ }
+
+ writer.Write("L");
+ }
+ }
+}