Exemple #1
0
 public DataTypeService(
     IDataValueEditorFactory dataValueEditorFactory,
     ICoreScopeProvider provider,
     ILoggerFactory loggerFactory,
     IEventMessagesFactory eventMessagesFactory,
     IDataTypeRepository dataTypeRepository,
     IDataTypeContainerRepository dataTypeContainerRepository,
     IAuditRepository auditRepository,
     IEntityRepository entityRepository,
     IContentTypeRepository contentTypeRepository,
     IIOHelper ioHelper,
     ILocalizedTextService localizedTextService,
     ILocalizationService localizationService,
     IShortStringHelper shortStringHelper,
     IJsonSerializer jsonSerializer,
     IEditorConfigurationParser editorConfigurationParser)
     : base(provider, loggerFactory, eventMessagesFactory)
 {
     _dataValueEditorFactory      = dataValueEditorFactory;
     _dataTypeRepository          = dataTypeRepository;
     _dataTypeContainerRepository = dataTypeContainerRepository;
     _auditRepository             = auditRepository;
     _entityRepository            = entityRepository;
     _contentTypeRepository       = contentTypeRepository;
     _ioHelper                  = ioHelper;
     _localizedTextService      = localizedTextService;
     _localizationService       = localizationService;
     _shortStringHelper         = shortStringHelper;
     _jsonSerializer            = jsonSerializer;
     _editorConfigurationParser = editorConfigurationParser;
 }
Exemple #2
0
 public PropertyTypeUsageService(
     IPropertyTypeUsageRepository propertyTypeUsageRepository,
     ICoreScopeProvider scopeProvider)
 {
     _propertyTypeUsageRepository = propertyTypeUsageRepository;
     _scopeProvider = scopeProvider;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="MemberController"/> class.
 /// </summary>
 /// <param name="cultureDictionary">The culture dictionary</param>
 /// <param name="loggerFactory">The logger factory</param>
 /// <param name="shortStringHelper">The string helper</param>
 /// <param name="eventMessages">The event messages factory</param>
 /// <param name="localizedTextService">The entry point for localizing key services</param>
 /// <param name="propertyEditors">The property editors</param>
 /// <param name="umbracoMapper">The mapper</param>
 /// <param name="memberService">The member service</param>
 /// <param name="memberTypeService">The member type service</param>
 /// <param name="memberManager">The member manager</param>
 /// <param name="dataTypeService">The data-type service</param>
 /// <param name="backOfficeSecurityAccessor">The back office security accessor</param>
 /// <param name="jsonSerializer">The JSON serializer</param>
 /// <param name="passwordChanger">The password changer</param>
 public MemberController(
     ICultureDictionary cultureDictionary,
     ILoggerFactory loggerFactory,
     IShortStringHelper shortStringHelper,
     IEventMessagesFactory eventMessages,
     ILocalizedTextService localizedTextService,
     PropertyEditorCollection propertyEditors,
     IUmbracoMapper umbracoMapper,
     IMemberService memberService,
     IMemberTypeService memberTypeService,
     IMemberManager memberManager,
     IDataTypeService dataTypeService,
     IBackOfficeSecurityAccessor backOfficeSecurityAccessor,
     IJsonSerializer jsonSerializer,
     IPasswordChanger <MemberIdentityUser> passwordChanger,
     ICoreScopeProvider scopeProvider)
     : base(cultureDictionary, loggerFactory, shortStringHelper, eventMessages, localizedTextService, jsonSerializer)
 {
     _propertyEditors            = propertyEditors;
     _umbracoMapper              = umbracoMapper;
     _memberService              = memberService;
     _memberTypeService          = memberTypeService;
     _memberManager              = memberManager;
     _dataTypeService            = dataTypeService;
     _localizedTextService       = localizedTextService;
     _backOfficeSecurityAccessor = backOfficeSecurityAccessor;
     _jsonSerializer             = jsonSerializer;
     _shortStringHelper          = shortStringHelper;
     _passwordChanger            = passwordChanger;
     _scopeProvider              = scopeProvider;
 }
Exemple #4
0
 public MemberTypeService(ICoreScopeProvider provider, ILoggerFactory loggerFactory, IEventMessagesFactory eventMessagesFactory, IMemberService memberService,
                          IMemberTypeRepository memberTypeRepository, IAuditRepository auditRepository, IEntityRepository entityRepository, IEventAggregator eventAggregator)
     : base(provider, loggerFactory, eventMessagesFactory, memberTypeRepository, auditRepository, null, entityRepository, eventAggregator)
 {
     MemberService         = memberService;
     _memberTypeRepository = memberTypeRepository;
 }
Exemple #5
0
        public void NestedWriteLocking3()
        {
            var d = new SnapDictionary <int, string>();

            SnapDictionary <int, string> .TestHelper t = d.Test;
            t.CollectAuto = false;

            Assert.AreEqual(0, d.CreateSnapshot().Gen);

            var scopeContext = new ScopeContext();
            ICoreScopeProvider scopeProvider1 = GetScopeProvider();
            ICoreScopeProvider scopeProvider2 = GetScopeProvider(scopeContext);

            using (IDisposable w1 = d.GetScopedWriteLock(scopeProvider1))
            {
                Assert.AreEqual(1, t.LiveGen);
                Assert.IsTrue(t.IsLocked);
                Assert.IsTrue(t.NextGen);

                Assert.Throws <InvalidOperationException>(() =>
                {
                    using (IDisposable w2 = d.GetScopedWriteLock(scopeProvider2))
                    {
                    }
                });
            }
        }
        public void Can_Perform_Delete_On_UserRepository()
        {
            // Arrange
            ICoreScopeProvider provider = ScopeProvider;

            using (ICoreScope scope = provider.CreateCoreScope())
            {
                UserRepository repository = CreateRepository(provider);

                User user = UserBuilderInstance.Build();

                // Act
                repository.Save(user);

                int id = user.Id;

                Mock <IRuntimeState> mockRuntimeState = CreateMockRuntimeState(RuntimeLevel.Run);

                var repository2 = new UserRepository((IScopeAccessor)provider, AppCaches.Disabled, LoggerFactory.CreateLogger <UserRepository>(), Mock.Of <IMapperCollection>(), Options.Create(GlobalSettings), Options.Create(new UserPasswordConfigurationSettings()), new JsonNetSerializer(), mockRuntimeState.Object);

                repository2.Delete(user);

                IUser resolved = repository2.Get((int)id);

                // Assert
                Assert.That(resolved, Is.Null);
            }
        }
    public void Can_Invalidate_SecurityStamp_On_Username_Change()
    {
        // Arrange
        ICoreScopeProvider provider = ScopeProvider;

        using (var scope = provider.CreateCoreScope())
        {
            var repository          = CreateRepository(provider);
            var userGroupRepository = CreateUserGroupRepository(provider);

            var user = CreateAndCommitUserWithGroup(repository, userGroupRepository);
            var originalSecurityStamp = user.SecurityStamp;

            // Ensure when user generated a security stamp is present
            Assert.That(user.SecurityStamp, Is.Not.Null);
            Assert.That(user.SecurityStamp, Is.Not.Empty);

            // Update username
            user.Username += "UPDATED";
            repository.Save(user);

            // Get the user
            var updatedUser = repository.Get(user.Id);

            // Ensure the Security Stamp is invalidated & no longer the same
            Assert.AreNotEqual(originalSecurityStamp, updatedUser.SecurityStamp);
        }
    }
Exemple #8
0
 public FileService(
     ICoreScopeProvider uowProvider,
     ILoggerFactory loggerFactory,
     IEventMessagesFactory eventMessagesFactory,
     IStylesheetRepository stylesheetRepository,
     IScriptRepository scriptRepository,
     ITemplateRepository templateRepository,
     IPartialViewRepository partialViewRepository,
     IPartialViewMacroRepository partialViewMacroRepository,
     IAuditRepository auditRepository,
     IShortStringHelper shortStringHelper,
     IOptions <GlobalSettings> globalSettings,
     IHostingEnvironment hostingEnvironment)
     : base(uowProvider, loggerFactory, eventMessagesFactory)
 {
     _stylesheetRepository       = stylesheetRepository;
     _scriptRepository           = scriptRepository;
     _templateRepository         = templateRepository;
     _partialViewRepository      = partialViewRepository;
     _partialViewMacroRepository = partialViewMacroRepository;
     _auditRepository            = auditRepository;
     _shortStringHelper          = shortStringHelper;
     _globalSettings             = globalSettings.Value;
     _hostingEnvironment         = hostingEnvironment;
 }
Exemple #9
0
        /// <summary>
        /// Initializes a new instance of the <see cref="HealthCheckNotifier"/> class.
        /// </summary>
        /// <param name="healthChecksSettings">The configuration for health check settings.</param>
        /// <param name="healthChecks">The collection of healthchecks.</param>
        /// <param name="notifications">The collection of healthcheck notification methods.</param>
        /// <param name="runtimeState">Representation of the state of the Umbraco runtime.</param>
        /// <param name="serverRegistrar">Provider of server registrations to the distributed cache.</param>
        /// <param name="mainDom">Representation of the main application domain.</param>
        /// <param name="scopeProvider">Provides scopes for database operations.</param>
        /// <param name="logger">The typed logger.</param>
        /// <param name="profilingLogger">The profiling logger.</param>
        /// <param name="cronTabParser">Parser of crontab expressions.</param>
        public HealthCheckNotifier(
            IOptionsMonitor <HealthChecksSettings> healthChecksSettings,
            HealthCheckCollection healthChecks,
            HealthCheckNotificationMethodCollection notifications,
            IRuntimeState runtimeState,
            IServerRoleAccessor serverRegistrar,
            IMainDom mainDom,
            ICoreScopeProvider scopeProvider,
            ILogger <HealthCheckNotifier> logger,
            IProfilingLogger profilingLogger,
            ICronTabParser cronTabParser)
            : base(
                logger,
                healthChecksSettings.CurrentValue.Notification.Period,
                healthChecksSettings.CurrentValue.GetNotificationDelay(cronTabParser, DateTime.Now, DefaultDelay))
        {
            _healthChecksSettings = healthChecksSettings.CurrentValue;
            _healthChecks         = healthChecks;
            _notifications        = notifications;
            _runtimeState         = runtimeState;
            _serverRegistrar      = serverRegistrar;
            _mainDom         = mainDom;
            _scopeProvider   = scopeProvider;
            _logger          = logger;
            _profilingLogger = profilingLogger;

            healthChecksSettings.OnChange(x =>
            {
                _healthChecksSettings = x;
                ChangePeriod(x.Notification.Period);
            });
        }
    public void Validate_Login_Session()
    {
        // Arrange
        ICoreScopeProvider provider = ScopeProvider;
        var user = UserBuilder.CreateUser();

        using (var scope = provider.CreateCoreScope(autoComplete: true))
        {
            var repository = CreateRepository(provider);
            repository.Save(user);
        }

        using (var scope = provider.CreateCoreScope(autoComplete: true))
        {
            var repository = CreateRepository(provider);
            var sessionId  = repository.CreateLoginSession(user.Id, "1.2.3.4");

            // manually update this record to be in the past
            ScopeAccessor.AmbientScope.Database.Execute(ScopeAccessor.AmbientScope.SqlContext.Sql()
                                                        .Update <UserLoginDto>(u => u.Set(x => x.LoggedOutUtc, DateTime.UtcNow.AddDays(-100)))
                                                        .Where <UserLoginDto>(x => x.SessionId == sessionId));

            var isValid = repository.ValidateLoginSession(user.Id, sessionId);
            Assert.IsFalse(isValid);

            // create a new one
            sessionId = repository.CreateLoginSession(user.Id, "1.2.3.4");
            isValid   = repository.ValidateLoginSession(user.Id, sessionId);
            Assert.IsTrue(isValid);
        }
    }
Exemple #11
0
 public MediaTypeService(ICoreScopeProvider provider, ILoggerFactory loggerFactory, IEventMessagesFactory eventMessagesFactory, IMediaService mediaService,
                         IMediaTypeRepository mediaTypeRepository, IAuditRepository auditRepository, IMediaTypeContainerRepository entityContainerRepository,
                         IEntityRepository entityRepository, IEventAggregator eventAggregator)
     : base(provider, loggerFactory, eventMessagesFactory, mediaTypeRepository, auditRepository, entityContainerRepository, entityRepository, eventAggregator)
 {
     MediaService = mediaService;
 }
 public ContentTypeService(ICoreScopeProvider provider, ILoggerFactory loggerFactory, IEventMessagesFactory eventMessagesFactory, IContentService contentService,
                           IContentTypeRepository repository, IAuditRepository auditRepository, IDocumentTypeContainerRepository entityContainerRepository, IEntityRepository entityRepository,
                           IEventAggregator eventAggregator)
     : base(provider, loggerFactory, eventMessagesFactory, repository, auditRepository, entityContainerRepository, entityRepository, eventAggregator)
 {
     ContentService = contentService;
 }
Exemple #13
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DatabaseBuilder"/> class.
 /// </summary>
 public DatabaseBuilder(
     ICoreScopeProvider scopeProvider,
     IScopeAccessor scopeAccessor,
     IUmbracoDatabaseFactory databaseFactory,
     IRuntimeState runtimeState,
     ILoggerFactory loggerFactory,
     IKeyValueService keyValueService,
     IDbProviderFactoryCreator dbProviderFactoryCreator,
     IConfigManipulator configManipulator,
     IOptionsMonitor <GlobalSettings> globalSettings,
     IOptionsMonitor <ConnectionStrings> connectionStrings,
     IMigrationPlanExecutor migrationPlanExecutor,
     DatabaseSchemaCreatorFactory databaseSchemaCreatorFactory,
     IEnumerable <IDatabaseProviderMetadata> databaseProviderMetadata)
 {
     _scopeProvider                = scopeProvider;
     _scopeAccessor                = scopeAccessor;
     _databaseFactory              = databaseFactory;
     _runtimeState                 = runtimeState;
     _logger                       = loggerFactory.CreateLogger <DatabaseBuilder>();
     _keyValueService              = keyValueService;
     _dbProviderFactoryCreator     = dbProviderFactoryCreator;
     _configManipulator            = configManipulator;
     _globalSettings               = globalSettings;
     _connectionStrings            = connectionStrings;
     _migrationPlanExecutor        = migrationPlanExecutor;
     _databaseSchemaCreatorFactory = databaseSchemaCreatorFactory;
     _databaseProviderMetadata     = databaseProviderMetadata;
 }
Exemple #14
0
 public DataTypeUsageService(
     IDataTypeUsageRepository dataTypeUsageRepository,
     ICoreScopeProvider scopeProvider)
 {
     _dataTypeUsageRepository = dataTypeUsageRepository;
     _scopeProvider           = scopeProvider;
 }
Exemple #15
0
        private ICoreScopeProvider GetScopeProvider(ScopeContext scopeContext = null)
        {
            ICoreScopeProvider scopeProvider = Mock.Of <ICoreScopeProvider>();

            Mock.Get(scopeProvider)
            .Setup(x => x.Context).Returns(scopeContext);
            return(scopeProvider);
        }
Exemple #16
0
 public AuditService(ICoreScopeProvider provider, ILoggerFactory loggerFactory, IEventMessagesFactory eventMessagesFactory,
                     IAuditRepository auditRepository, IAuditEntryRepository auditEntryRepository)
     : base(provider, loggerFactory, eventMessagesFactory)
 {
     _auditRepository      = auditRepository;
     _auditEntryRepository = auditEntryRepository;
     _isAvailable          = new Lazy <bool>(DetermineIsAvailable);
 }
Exemple #17
0
 public RelationService(ICoreScopeProvider uowProvider, ILoggerFactory loggerFactory, IEventMessagesFactory eventMessagesFactory, IEntityService entityService, IRelationRepository relationRepository, IRelationTypeRepository relationTypeRepository, IAuditRepository auditRepository)
     : base(uowProvider, loggerFactory, eventMessagesFactory)
 {
     _relationRepository     = relationRepository;
     _relationTypeRepository = relationTypeRepository;
     _auditRepository        = auditRepository;
     _entityService          = entityService ?? throw new ArgumentNullException(nameof(entityService));
 }
Exemple #18
0
 public TrackedReferencesService(
     ITrackedReferencesRepository trackedReferencesRepository,
     ICoreScopeProvider scopeProvider,
     IEntityService entityService)
 {
     _trackedReferencesRepository = trackedReferencesRepository;
     _scopeProvider = scopeProvider;
     _entityService = entityService;
 }
        public EntityService(ICoreScopeProvider provider, ILoggerFactory loggerFactory, IEventMessagesFactory eventMessagesFactory, IIdKeyMap idKeyMap, IEntityRepository entityRepository)
            : base(provider, loggerFactory, eventMessagesFactory)
        {
            _idKeyMap         = idKeyMap;
            _entityRepository = entityRepository;

            _objectTypes = new Dictionary <string, UmbracoObjectTypes>
            {
                { typeof(IDataType).FullName !, UmbracoObjectTypes.DataType },
Exemple #20
0
 /// <inheritdoc/>
 public FirstBootAppStartingHandler(
     ICoreScopeProvider scopeProvider,
     IKeyValueService keyValueService,
     IMigrationPlanExecutor migrationPlanExecutor)
 {
     _scopeProvider         = scopeProvider;
     _keyValueService       = keyValueService;
     _migrationPlanExecutor = migrationPlanExecutor;
 }
Exemple #21
0
 public MemberUserStore(
     IMemberService memberService,
     IUmbracoMapper mapper,
     ICoreScopeProvider scopeProvider,
     IdentityErrorDescriber describer,
     IPublishedSnapshotAccessor publishedSnapshotAccessor)
     : this(memberService, mapper, scopeProvider, describer, publishedSnapshotAccessor, StaticServiceProvider.Instance.GetRequiredService <IExternalLoginWithKeyService>(), StaticServiceProvider.Instance.GetRequiredService <ITwoFactorLoginService>())
 {
 }
        private UserRepository CreateRepository(ICoreScopeProvider provider)
        {
            var accessor = (IScopeAccessor)provider;
            Mock <IRuntimeState> mockRuntimeState = CreateMockRuntimeState(RuntimeLevel.Run);

            var repository = new UserRepository(accessor, AppCaches.Disabled, LoggerFactory.CreateLogger <UserRepository>(), Mappers, Options.Create(GlobalSettings), Options.Create(new UserPasswordConfigurationSettings()), new JsonNetSerializer(), mockRuntimeState.Object);

            return(repository);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="UmbracoMapper"/> class.
        /// </summary>
        /// <param name="profiles"></param>
        /// <param name="scopeProvider"></param>
        public UmbracoMapper(MapDefinitionCollection profiles, ICoreScopeProvider scopeProvider)
        {
            _scopeProvider = scopeProvider;

            foreach (var profile in profiles)
            {
                profile.DefineMaps(this);
            }
        }
 public DefaultContentVersionCleanupPolicy(
     IOptions <ContentSettings> contentSettings,
     ICoreScopeProvider scopeProvider,
     IDocumentVersionRepository documentVersionRepository)
 {
     _contentSettings           = contentSettings ?? throw new ArgumentNullException(nameof(contentSettings));
     _scopeProvider             = scopeProvider ?? throw new ArgumentNullException(nameof(scopeProvider));
     _documentVersionRepository = documentVersionRepository ??
                                  throw new ArgumentNullException(nameof(documentVersionRepository));
 }
Exemple #25
0
 /// <summary>
 ///     Initializes a new instance of the <see cref="ServerRegistrationService" /> class.
 /// </summary>
 public ServerRegistrationService(
     ICoreScopeProvider scopeProvider,
     ILoggerFactory loggerFactory,
     IEventMessagesFactory eventMessagesFactory,
     IServerRegistrationRepository serverRegistrationRepository,
     IHostingEnvironment hostingEnvironment)
     : base(scopeProvider, loggerFactory, eventMessagesFactory)
 {
     _serverRegistrationRepository = serverRegistrationRepository;
     _hostingEnvironment           = hostingEnvironment;
 }
 protected ContentTypeServiceBase(ICoreScopeProvider provider, ILoggerFactory loggerFactory, IEventMessagesFactory eventMessagesFactory,
                                  TRepository repository, IAuditRepository auditRepository, IEntityContainerRepository?containerRepository, IEntityRepository entityRepository,
                                  IEventAggregator eventAggregator)
     : base(provider, loggerFactory, eventMessagesFactory)
 {
     Repository           = repository;
     _auditRepository     = auditRepository;
     _containerRepository = containerRepository;
     _entityRepository    = entityRepository;
     _eventAggregator     = eventAggregator;
 }
Exemple #27
0
 public MacroService(
     ICoreScopeProvider provider,
     ILoggerFactory loggerFactory,
     IEventMessagesFactory eventMessagesFactory,
     IMacroRepository macroRepository,
     IAuditRepository auditRepository)
     : base(provider, loggerFactory, eventMessagesFactory)
 {
     _macroRepository = macroRepository;
     _auditRepository = auditRepository;
 }
Exemple #28
0
 public MigrationPlanExecutor(
     ICoreScopeProvider scopeProvider,
     IScopeAccessor scopeAccessor,
     ILoggerFactory loggerFactory,
     IMigrationBuilder migrationBuilder)
 {
     _scopeProvider    = scopeProvider;
     _scopeAccessor    = scopeAccessor;
     _loggerFactory    = loggerFactory;
     _migrationBuilder = migrationBuilder;
     _logger           = _loggerFactory.CreateLogger <MigrationPlanExecutor>();
 }
 public LocalizationService(
     ICoreScopeProvider provider,
     ILoggerFactory loggerFactory,
     IEventMessagesFactory eventMessagesFactory,
     IDictionaryRepository dictionaryRepository,
     IAuditRepository auditRepository,
     ILanguageRepository languageRepository)
     : base(provider, loggerFactory, eventMessagesFactory)
 {
     _dictionaryRepository = dictionaryRepository;
     _auditRepository      = auditRepository;
     _languageRepository   = languageRepository;
 }
 public TwoFactorLoginService(
     ITwoFactorLoginRepository twoFactorLoginRepository,
     ICoreScopeProvider scopeProvider,
     IEnumerable <ITwoFactorProvider> twoFactorSetupGenerators,
     IOptions <IdentityOptions> identityOptions,
     IOptions <BackOfficeIdentityOptions> backOfficeIdentityOptions)
     : this(twoFactorLoginRepository,
            scopeProvider,
            twoFactorSetupGenerators,
            identityOptions,
            backOfficeIdentityOptions,
            StaticServiceProvider.Instance.GetRequiredService <ILogger <TwoFactorLoginService> >())
 {
 }