//----------------------------------------------------------------------- // // Copyright (c) Outercurve Foundation. All rights reserved. // //----------------------------------------------------------------------- namespace DotNetOpenAuth { using System; using System.Collections.Generic; using System.Linq; using System.Text; using DotNetOpenAuth.Messaging.Bindings; using DotNetOpenAuth.OAuth; using DotNetOpenAuth.OAuth.ChannelElements; using Validation; /// /// Utility methods specific to OAuth feature reporting. /// internal class OAuthReporting : Reporting { /// /// Records the feature and dependency use. /// /// The consumer or service provider. /// The service. /// The token manager. /// The nonce store. internal static void RecordFeatureAndDependencyUse(object value, ServiceProviderHostDescription service, ITokenManager tokenManager, INonceStore nonceStore) { Requires.NotNull(value, "value"); Requires.NotNull(service, "service"); Requires.NotNull(tokenManager, "tokenManager"); // In release builds, just quietly return. if (value == null || service == null || tokenManager == null) { return; } if (Reporting.Enabled && Reporting.Configuration.IncludeFeatureUsage) { StringBuilder builder = new StringBuilder(); builder.Append(value.GetType().Name); builder.Append(" "); builder.Append(tokenManager.GetType().Name); if (nonceStore != null) { builder.Append(" "); builder.Append(nonceStore.GetType().Name); } builder.Append(" "); builder.Append(service.UserAuthorizationEndpoint != null ? service.UserAuthorizationEndpoint.Location.AbsoluteUri : string.Empty); Reporting.ObservedFeatures.Add(builder.ToString()); Reporting.Touch(); } } } }