public ActiveDirectoryMetadatasController(IConfigurationRepository configurationRepository, IActiveDirectoryRepository activeDirectory, IOpenIdConnectIdentityProviderLogic oidcLogic)
 {
     this.oidcLogic = oidcLogic;
     this.configurationRepository = configurationRepository;
     this.http            = new HttpResponseHandler(this);
     this.activeDirectory = activeDirectory;
 }
Ejemplo n.º 2
0
        private void InitializeApp(IServiceCollection services, AppSettings appSettings)
        {
            //singleton pattern here was a huge mistake, i'm going to fix this.

            LiteDbConfigurationRepository configurationRepository = new LiteDbConfigurationRepository(databaseLocator.GetConfigurationRepositoryConnectionString());

            appConfig = configurationRepository.GetAppConfig();

            ActiveDirectoryRepository activeDirectory = new ActiveDirectoryRepository();

            EncryptionProvider cipher = new EncryptionProvider(appConfig.EncryptionKey);

            services.AddSingleton <EncryptionProvider>(cipher);

            services.AddSingleton <IActiveDirectoryAuthenticator>(activeDirectory);
            services.AddSingleton <IActiveDirectoryRepository>(activeDirectory);

            IdentityAuthenticationLogic identityAuthenticationLogic = new IdentityAuthenticationLogic(configurationRepository, activeDirectory);

            services.AddSingleton <IdentityAuthenticationLogic>();

            ICertificateRepository certificateRepository = new LiteDbCertificateRepository(databaseLocator.GetCertificateRepositoryConnectionString());

            RuntimeCacheRepository runtimeCacheRepository = null;

            LiteDbAuditRepository auditRepository = new LiteDbAuditRepository(databaseLocator.GetAuditRepositoryConnectionString());

            IAuditLogic auditLogic = new AuditLogic(auditRepository, configurationRepository);

            services.AddSingleton <IAuditLogic>(auditLogic);

            IAuthorizationLogic authorizationLogic = new AuthorizationLogic(configurationRepository, auditLogic);

            IScriptManagementLogic scriptManagement = new ScriptManagementLogic(configurationRepository, authorizationLogic);

            services.AddSingleton <IScriptManagementLogic>(scriptManagement);

            IPowershellEngine powershellEngine = new PowershellEngine(auditLogic, scriptManagement);

            services.AddSingleton <IPowershellEngine>(powershellEngine);

            RoleManagementLogic roleManagementLogic = new RoleManagementLogic(configurationRepository, authorizationLogic);

            services.AddSingleton <RoleManagementLogic>(roleManagementLogic);

            UserManagementLogic userManagementLogic = new UserManagementLogic(configurationRepository, authorizationLogic);

            services.AddSingleton <UserManagementLogic>(userManagementLogic);

            SecurityPrincipalLogic securityPrincipalLogic = new SecurityPrincipalLogic(roleManagementLogic, userManagementLogic);

            services.AddSingleton <SecurityPrincipalLogic>();

            AdcsTemplateLogic adcsTemplateLogic = new AdcsTemplateLogic(configurationRepository, activeDirectory);

            services.AddSingleton <AdcsTemplateLogic>(adcsTemplateLogic);

            services.AddSingleton <IAuthorizationLogic>(authorizationLogic);

            services.AddSingleton <IConfigurationRepository>(configurationRepository);

            ICertificateProvider certificateProvider = new Win32CertificateProvider();

            services.AddSingleton <ICertificateProvider>(certificateProvider);

            services.AddSingleton <ICertificateRepository>(certificateRepository);

            ActiveDirectoryIdentityProviderLogic activeDirectoryIdentityProviderLogic = new ActiveDirectoryIdentityProviderLogic(configurationRepository);

            services.AddSingleton <ActiveDirectoryIdentityProviderLogic>(activeDirectoryIdentityProviderLogic);

            certificateManagementLogic = new CertificateManagementLogic(
                configurationRepository,
                certificateRepository,
                authorizationLogic,
                auditLogic,
                securityPrincipalLogic,
                cipher);

            services.AddSingleton <CertificateManagementLogic>(certificateManagementLogic);

            PrivateCertificateProcessing privateCertificateProcessing = new PrivateCertificateProcessing(certificateRepository, configurationRepository, certificateProvider, authorizationLogic, adcsTemplateLogic, auditLogic);

            services.AddSingleton <IPrivateCertificateProcessing>(privateCertificateProcessing);

            services.AddSingleton <NodeLogic>(new NodeLogic(configurationRepository, authorizationLogic, activeDirectoryIdentityProviderLogic, powershellEngine, auditLogic, certificateManagementLogic, privateCertificateProcessing));

            services.AddSingleton <IRuntimeConfigurationState>(
                new RuntimeConfigurationState(configurationRepository, runtimeCacheRepository)
            {
                InitialSetupComplete = initialSetupComplete
            });

            services.AddSingleton <IClientsideConfigurationProvider>(new ClientsideConfigurationProvider(configurationRepository));



            services.AddSingleton <AnalyticsLogic>(new AnalyticsLogic(configurationRepository, certificateRepository, auditRepository));

            services.AddSingleton <DataRenderingProvider>(new DataRenderingProvider());

            oidcLogic = new OpenIdConnectIdentityProviderLogic(configurationRepository, authorizationLogic);
            services.AddSingleton <IOpenIdConnectIdentityProviderLogic>(oidcLogic);
        }