Beispiel #1
0
 public PackageUploadService(
     IPackageService packageService,
     IPackageFileService packageFileService,
     IEntitiesContext entitiesContext,
     IReservedNamespaceService reservedNamespaceService,
     IValidationService validationService,
     IAppConfiguration config,
     ITyposquattingService typosquattingService,
     ITelemetryService telemetryService,
     ICoreLicenseFileService coreLicenseFileService,
     IDiagnosticsService diagnosticsService,
     IFeatureFlagService featureFlagService,
     IPackageVulnerabilityService vulnerabilityService)
 {
     _packageService           = packageService ?? throw new ArgumentNullException(nameof(packageService));
     _packageFileService       = packageFileService ?? throw new ArgumentNullException(nameof(packageFileService));
     _entitiesContext          = entitiesContext ?? throw new ArgumentNullException(nameof(entitiesContext));
     _reservedNamespaceService = reservedNamespaceService ?? throw new ArgumentNullException(nameof(reservedNamespaceService));
     _validationService        = validationService ?? throw new ArgumentNullException(nameof(validationService));
     _config = config ?? throw new ArgumentNullException(nameof(config));
     _typosquattingService   = typosquattingService ?? throw new ArgumentNullException(nameof(typosquattingService));
     _telemetryService       = telemetryService ?? throw new ArgumentNullException(nameof(telemetryService));
     _coreLicenseFileService = coreLicenseFileService ?? throw new ArgumentNullException(nameof(coreLicenseFileService));
     if (diagnosticsService == null)
     {
         throw new ArgumentNullException(nameof(diagnosticsService));
     }
     _trace = diagnosticsService.GetSource(nameof(PackageUploadService));
     _featureFlagService   = featureFlagService ?? throw new ArgumentNullException(nameof(featureFlagService));
     _vulnerabilityService = vulnerabilityService ?? throw new ArgumentNullException(nameof(vulnerabilityService));
 }
Beispiel #2
0
        public static IDisposable Activity(this IDiagnosticsSource self,
                                           string name,
                                           [CallerMemberName] string member = null,
                                           [CallerFilePath] string file     = null,
                                           [CallerLineNumber] int line      = 0)
        {
            var thisActivityId = Interlocked.Increment(ref _activityId);
            var start          = DateTime.UtcNow;

            self.TraceEvent(TraceEventType.Start,
                            id: thisActivityId,
                            message: String.Format(CultureInfo.CurrentCulture, "Starting {0}", name),
                            member: member,
                            file: file,
                            line: line);
            return(new DisposableAction(() =>
            {
                var diff = DateTime.UtcNow - start;
                var stopMessage = String.Format(CultureInfo.CurrentCulture, "Finished {0}. Duration {1:0.00}ms", name, diff.TotalMilliseconds);
                self.TraceEvent(TraceEventType.Stop,
                                id: thisActivityId,
                                message: stopMessage,
                                member: member,
                                file: file,
                                line: line);
            }));
        }
Beispiel #3
0
 public UserService(
     IAppConfiguration config,
     IEntityRepository <User> userRepository,
     IEntityRepository <Credential> credentialRepository,
     IEntityRepository <Organization> organizationRepository,
     IAuditingService auditing,
     IEntitiesContext entitiesContext,
     IContentObjectService contentObjectService,
     ISecurityPolicyService securityPolicyService,
     IDateTimeProvider dateTimeProvider,
     ICredentialBuilder credentialBuilder,
     ITelemetryService telemetryService,
     IDiagnosticsService diagnosticsService)
     : this()
 {
     Config                 = config;
     UserRepository         = userRepository;
     CredentialRepository   = credentialRepository;
     OrganizationRepository = organizationRepository;
     Auditing               = auditing;
     EntitiesContext        = entitiesContext;
     ContentObjectService   = contentObjectService;
     SecurityPolicyService  = securityPolicyService;
     DateTimeProvider       = dateTimeProvider;
     TelemetryService       = telemetryService;
     DiagnosticsSource      = diagnosticsService.SafeGetSource(nameof(UserService));
 }
Beispiel #4
0
        public AuthenticationService(
            IEntitiesContext entities, IAppConfiguration config, IDiagnosticsService diagnostics,
            IAuditingService auditing, IEnumerable <Authenticator> providers, ICredentialBuilder credentialBuilder,
            ICredentialValidator credentialValidator, IDateTimeProvider dateTimeProvider,
            ILdapService ldapService)
        {
            if (entities == null)
            {
                throw new ArgumentNullException(nameof(entities));
            }

            if (config == null)
            {
                throw new ArgumentNullException(nameof(config));
            }

            if (diagnostics == null)
            {
                throw new ArgumentNullException(nameof(diagnostics));
            }

            if (auditing == null)
            {
                throw new ArgumentNullException(nameof(auditing));
            }

            if (providers == null)
            {
                throw new ArgumentNullException(nameof(providers));
            }

            if (credentialBuilder == null)
            {
                throw new ArgumentNullException(nameof(credentialBuilder));
            }

            if (credentialValidator == null)
            {
                throw new ArgumentNullException(nameof(credentialValidator));
            }

            if (dateTimeProvider == null)
            {
                throw new ArgumentNullException(nameof(dateTimeProvider));
            }

            InitCredentialFormatters();

            Entities             = entities;
            _config              = config;
            Auditing             = auditing;
            _trace               = diagnostics.SafeGetSource("AuthenticationService");
            Authenticators       = providers.ToDictionary(p => p.Name, StringComparer.OrdinalIgnoreCase);
            _credentialBuilder   = credentialBuilder;
            _credentialValidator = credentialValidator;
            _dateTimeProvider    = dateTimeProvider;

            this.Ldap = ldapService;
        }
Beispiel #5
0
 public static void Error(this IDiagnosticsSource self,
                             string message,
                             [CallerMemberName] string member = null,
                             [CallerFilePath] string file = null,
                             [CallerLineNumber] int line = 0)
 {
     self.TraceEvent(LogLevel.Error, eventId: 0, message: message, member: member, file: file, line: line);
 }
Beispiel #6
0
 public static void Warning(this IDiagnosticsSource self,
                            string message,
                            [CallerMemberName] string member = null,
                            [CallerFilePath] string file     = null,
                            [CallerLineNumber] int line      = 0)
 {
     self.TraceEvent(TraceEventType.Warning, id: 0, message: message, member: member, file: file, line: line);
 }
 public CloudBlobCoreFileStorageService(
     ICloudBlobClient client,
     IDiagnosticsService diagnosticsService,
     ICloudBlobContainerInformationProvider cloudBlobFolderInformationProvider)
 {
     _client = client ?? throw new ArgumentNullException(nameof(client));
     _trace  = diagnosticsService?.SafeGetSource(nameof(CloudBlobCoreFileStorageService)) ?? throw new ArgumentNullException(nameof(diagnosticsService));
     _cloudBlobFolderInformationProvider = cloudBlobFolderInformationProvider ?? throw new ArgumentNullException(nameof(cloudBlobFolderInformationProvider));
 }
Beispiel #8
0
 public static void Warning(this IDiagnosticsSource self,
                             string message,
                             EventId eventId,
                             [CallerMemberName] string member = null,
                             [CallerFilePath] string file = null,
                             [CallerLineNumber] int line = 0)
 {
     self.TraceEvent(LogLevel.Warning, eventId, message, member, file, line);
 }
        public TelemetryService(IDiagnosticsService diagnosticsService)
        {
            if (diagnosticsService == null)
            {
                throw new ArgumentNullException(nameof(diagnosticsService));
            }

            _trace = diagnosticsService.GetSource("TelemetryService");
        }
Beispiel #10
0
 public static void Error(this IDiagnosticsSource self,
                          string message,
                          int id,
                          [CallerMemberName] string member = null,
                          [CallerFilePath] string file     = null,
                          [CallerLineNumber] int line      = 0)
 {
     self.TraceEvent(TraceEventType.Error, id, message, member, file, line);
 }
Beispiel #11
0
        public SecurePushSubscription(IAuditingService auditing, IDiagnosticsService diagnostics)
        {
            _auditing = auditing ?? throw new ArgumentNullException(nameof(auditing));

            if (diagnostics == null)
            {
                throw new ArgumentNullException(nameof(diagnostics));
            }

            _diagnostics = diagnostics.SafeGetSource(nameof(SecurePushSubscription));
        }
        public LuceneIndexingService(
            IEntityRepository<Package> packageSource,
            IEntityRepository<CuratedPackage> curatedPackageSource,
            Lucene.Net.Store.Directory directory,
			IDiagnosticsService diagnostics)
        {
            _packageRepository = packageSource;
            _curatedPackageRepository = curatedPackageSource;
            _directory = directory;
            Trace = diagnostics.SafeGetSource("LuceneIndexingService");
        }
 public LuceneIndexingService(
     IEntityRepository <Package> packageSource,
     IEntityRepository <CuratedPackage> curatedPackageSource,
     Lucene.Net.Store.Directory directory,
     IDiagnosticsService diagnostics)
 {
     _packageRepository        = packageSource;
     _curatedPackageRepository = curatedPackageSource;
     _directory = directory;
     Trace      = diagnostics.SafeGetSource("LuceneIndexingService");
 }
Beispiel #14
0
        public TelemetryService(IDiagnosticsService diagnosticsService, ITelemetryClient telemetryClient = null)
        {
            if (diagnosticsService == null)
            {
                throw new ArgumentNullException(nameof(diagnosticsService));
            }

            _telemetryClient = telemetryClient ?? throw new ArgumentNullException(nameof(telemetryClient));

            _diagnosticsSource = diagnosticsService.GetSource("TelemetryService");
        }
        public virtual Task InitializeAsync(string domain, IDiagnosticsService diagnostics, CancellationToken cancellationToken)
        {
            // Service should only be initialized once.
            if (_domain != null)
            {
                throw new InvalidOperationException(CoreStrings.CookieComplianceServiceAlreadyInitialized);
            }

            _domain      = domain;
            _diagnostics = diagnostics.GetSource(GetType().Name);

            return(Task.Delay(0));
        }
        public AuthenticationService(
            IEntitiesContext entities, IAppConfiguration config, IDiagnosticsService diagnostics,
            AuditingService auditing, IEnumerable<Authenticator> providers, ICredentialBuilder credentialBuilder,
            ICredentialValidator credentialValidator)
        {
            if (entities == null)
            {
                throw new ArgumentNullException(nameof(entities));
            }

            if (config == null)
            {
                throw new ArgumentNullException(nameof(config));
            }

            if (diagnostics == null)
            {
                throw new ArgumentNullException(nameof(diagnostics));
            }

            if (auditing == null)
            {
                throw new ArgumentNullException(nameof(auditing));
            }

            if (providers == null)
            {
                throw new ArgumentNullException(nameof(providers));
            }

            if (credentialBuilder == null)
            {
                throw new ArgumentNullException(nameof(credentialBuilder));
            }

            if (credentialValidator == null)
            {
                throw new ArgumentNullException(nameof(credentialValidator));
            }

            InitCredentialFormatters();

            Entities = entities;
            _config = config;
            Auditing = auditing;
            _trace = diagnostics.SafeGetSource("AuthenticationService");
            Authenticators = providers.ToDictionary(p => p.Name, StringComparer.OrdinalIgnoreCase);
            _credentialBuilder = credentialBuilder;
            _credentialValidator = credentialValidator;
        }
        public AuthenticationService(IEntitiesContext entities, IAppConfiguration config, IDiagnosticsService diagnostics, AuditingService auditing, IEnumerable<Authenticator> providers)
        {
            _credentialFormatters = new Dictionary<string, Func<string, string>>(StringComparer.OrdinalIgnoreCase) {
                { "password", _ => Strings.CredentialType_Password },
                { "apikey", _ => Strings.CredentialType_ApiKey },
                { "external", FormatExternalCredentialType }
            };

            Entities = entities;
            Config = config;
            Auditing = auditing;
            Trace = diagnostics.SafeGetSource("AuthenticationService");
            Authenticators = providers.ToDictionary(p => p.Name, StringComparer.OrdinalIgnoreCase);
        }
Beispiel #18
0
 public static void Error(this IDiagnosticsSource self,
                          Exception ex,
                          string context,
                          [CallerMemberName] string member = null,
                          [CallerFilePath] string file     = null,
                          [CallerLineNumber] int line      = 0)
 {
     Error(
         self,
         message: String.Format(CultureInfo.CurrentCulture, "{0}: {1}", context, ex),
         member: member,
         file: file,
         line: line);
 }
        public AuthenticationService(IEntitiesContext entities, IAppConfiguration config, IDiagnosticsService diagnostics, AuditingService auditing, IEnumerable <Authenticator> providers)
        {
            _credentialFormatters = new Dictionary <string, Func <string, string> >(StringComparer.OrdinalIgnoreCase)
            {
                { "password", _ => Strings.CredentialType_Password },
                { "apikey", _ => Strings.CredentialType_ApiKey },
                { "external", FormatExternalCredentialType }
            };

            Entities       = entities;
            _config        = config;
            Auditing       = auditing;
            _trace         = diagnostics.SafeGetSource("AuthenticationService");
            Authenticators = providers.ToDictionary(p => p.Name, StringComparer.OrdinalIgnoreCase);
        }
        public AsynchronousPackageValidationInitiator(
            IPackageValidationEnqueuer enqueuer,
            IAppConfiguration appConfiguration,
            IDiagnosticsService diagnosticsService)
        {
            _enqueuer         = enqueuer ?? throw new ArgumentNullException(nameof(enqueuer));
            _appConfiguration = appConfiguration ?? throw new ArgumentNullException(nameof(appConfiguration));

            if (diagnosticsService == null)
            {
                throw new ArgumentNullException(nameof(IDiagnosticsService));
            }

            _diagnosticsSource = diagnosticsService.SafeGetSource(nameof(AsynchronousPackageValidationInitiator));
        }
        public CachingSecretReader(ISecretReader secretReader, IDiagnosticsService diagnosticsService)
        {
            if (secretReader == null)
            {
                throw new ArgumentNullException(nameof(secretReader));
            }

            if (diagnosticsService == null)
            {
                throw new ArgumentNullException(nameof(diagnosticsService));
            }

            _internalReader = secretReader;
            _cache          = new Dictionary <string, string>();
            _trace          = diagnosticsService.GetSource("CachingSecretReader");
        }
Beispiel #22
0
        public static int Dump(
            this IDiagnosticsSource source,
            IDiagnosticsWriter writer)
        {
            int errorCount = 0;

            foreach (var d in source.Diagnostics)
            {
                if (d.Severity >= Severity.Error)
                {
                    errorCount++;
                }
                d.Dump(writer);
            }
            return(errorCount);
        }
        public CachingSecretReader(ISecretReader secretReader, IDiagnosticsService diagnosticsService)
        {
            if (secretReader == null)
            {
                throw new ArgumentNullException(nameof(secretReader));
            }

            if (diagnosticsService == null)
            {
                throw new ArgumentNullException(nameof(diagnosticsService));
            }

            _internalReader = secretReader;
            _cache = new Dictionary<string, string>();
            _trace = diagnosticsService.GetSource("CachingSecretReader");
        }
Beispiel #24
0
        public AuthenticationService(
            IEntitiesContext entities, IAppConfiguration config, IDiagnosticsService diagnostics,
            IAuditingService auditing, IEnumerable <Authenticator> providers, ICredentialBuilder credentialBuilder,
            ICredentialValidator credentialValidator, IDateTimeProvider dateTimeProvider, ITelemetryService telemetryService)
        {
            InitCredentialFormatters();

            Entities             = entities ?? throw new ArgumentNullException(nameof(entities));
            _config              = config ?? throw new ArgumentNullException(nameof(config));
            _trace               = diagnostics?.SafeGetSource("AuthenticationService") ?? throw new ArgumentNullException(nameof(diagnostics));
            Auditing             = auditing ?? throw new ArgumentNullException(nameof(auditing));;
            Authenticators       = providers?.ToDictionary(p => p.Name, StringComparer.OrdinalIgnoreCase) ?? throw new ArgumentNullException(nameof(providers));
            _credentialBuilder   = credentialBuilder ?? throw new ArgumentNullException(nameof(credentialBuilder));
            _credentialValidator = credentialValidator ?? throw new ArgumentNullException(nameof(credentialValidator));
            _dateTimeProvider    = dateTimeProvider ?? throw new ArgumentNullException(nameof(dateTimeProvider));
            _telemetryService    = telemetryService ?? throw new ArgumentNullException(nameof(telemetryService));
        }
 public PackageMetadataValidationService(
     IPackageService packageService,
     IAppConfiguration config,
     ITyposquattingService typosquattingService,
     ITelemetryService telemetryService,
     IDiagnosticsService diagnosticsService,
     IFeatureFlagService featureFlagService)
 {
     _packageService       = packageService ?? throw new ArgumentNullException(nameof(packageService));
     _config               = config ?? throw new ArgumentNullException(nameof(config));
     _typosquattingService = typosquattingService ?? throw new ArgumentNullException(nameof(typosquattingService));
     _telemetryService     = telemetryService ?? throw new ArgumentNullException(nameof(telemetryService));
     if (diagnosticsService == null)
     {
         throw new ArgumentNullException(nameof(diagnosticsService));
     }
     _trace = diagnosticsService.GetSource(nameof(PackageUploadService));
     _featureFlagService = featureFlagService ?? throw new ArgumentNullException(nameof(featureFlagService));
 }
        public static IDisposable Activity(this IDiagnosticsSource self,
                                           string name,
                                           [CallerMemberName] string member = null,
                                           [CallerFilePath] string file     = null,
                                           [CallerLineNumber] int line      = 0)
        {
            self.TraceEvent(TraceEventType.Start,
                            id: 0,
                            message: String.Format(CultureInfo.CurrentCulture, "Starting {0}", name),
                            member: member,
                            file: file,
                            line: line);
            var stopMessage = String.Format(CultureInfo.CurrentCulture, "Starting {0}", name);

            return(new DisposableAction(() =>
                                        self.TraceEvent(TraceEventType.Stop,
                                                        id: 0,
                                                        message: stopMessage,
                                                        member: member,
                                                        file: file,
                                                        line: line)));
        }
Beispiel #27
0
 public CloudBlobCoreFileStorageService(ICloudBlobClient client, IDiagnosticsService diagnosticsService)
 {
     _client = client ?? throw new ArgumentNullException(nameof(client));
     _trace  = diagnosticsService?.SafeGetSource(nameof(CloudBlobCoreFileStorageService)) ?? throw new ArgumentNullException(nameof(diagnosticsService));
 }
 public void Add(IDiagnosticsSource source)
 {
     _diagnostics.Add( source );
 }
 public AuthenticationService(IEntitiesContext entities, IAppConfiguration config, IDiagnosticsService diagnostics)
 {
     Entities = entities;
     Config   = config;
     Trace    = diagnostics.SafeGetSource("AuthenticationService");
 }
Beispiel #30
0
        public PackageService(
            IEntityRepository <PackageRegistration> packageRegistrationRepository,
            IEntityRepository <Package> packageRepository,
            IEntityRepository <PackageOwnerRequest> packageOwnerRequestRepository,
            IEntitiesContext entitiesContext,
            IAppConfiguration configuration,
            IDiagnosticsService diagnostics,
            IIndexingService indexingService,
            IPackageNamingConflictValidator packageNamingConflictValidator,
            IAuditingService auditingService)
        {
            if (packageRegistrationRepository == null)
            {
                throw new ArgumentNullException(nameof(packageRegistrationRepository));
            }

            if (packageRepository == null)
            {
                throw new ArgumentNullException(nameof(packageRepository));
            }

            if (packageOwnerRequestRepository == null)
            {
                throw new ArgumentNullException(nameof(packageOwnerRequestRepository));
            }

            if (entitiesContext == null)
            {
                throw new ArgumentNullException(nameof(entitiesContext));
            }

            if (configuration == null)
            {
                throw new ArgumentNullException(nameof(configuration));
            }

            if (indexingService == null)
            {
                throw new ArgumentNullException(nameof(indexingService));
            }

            if (packageNamingConflictValidator == null)
            {
                throw new ArgumentNullException(nameof(packageNamingConflictValidator));
            }

            if (auditingService == null)
            {
                throw new ArgumentNullException(nameof(auditingService));
            }

            _packageRegistrationRepository = packageRegistrationRepository;
            _packageRepository             = packageRepository;
            _packageOwnerRequestRepository = packageOwnerRequestRepository;
            _entitiesContext = entitiesContext;
            _configuration   = configuration;
            _indexingService = indexingService;
            _packageNamingConflictValidator = packageNamingConflictValidator;
            _auditingService = auditingService;

            _trace = diagnostics.SafeGetSource("PackageService");
        }
 public TelemetryServiceWrapper(IDiagnosticsSource diagnosticsSource, ITelemetryClient telemetryClient)
     : base(diagnosticsSource, telemetryClient)
 {
 }
Beispiel #32
0
 public TracingHttpHandler(IDiagnosticsSource trace)
 {
     Trace = trace;
 }
Beispiel #33
0
 public void AddDiagnostic(IDiagnosticsSource diagnostic)
 {
     _diagnostics.Add(diagnostic);
 }
Beispiel #34
0
 public void Add(IDiagnosticsSource source)
 {
     _diagnostics.Add(source);
 }
 public TracingHttpHandler(IDiagnosticsSource trace)
 {
     Trace = trace;
 }