Exemple #1
0
        public Broker(string metadataDir = null, IRegistryProvider registryProvider = null)
        {
            _workingDir = Directory.GetCurrentDirectory();
            var binDir    = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
            var studioDir = Path.Combine(binDir, "studio");

            Log.Info("Studio dir: {0}", studioDir);
            metadataDir = Path.GetFullPath(metadataDir ?? Path.Combine(_workingDir, "metadata"));
            Log.Info("Metadata dir: {0}", metadataDir);
            var metadataFile = Path.Combine(metadataDir, "interop.json");

            _transportServers = new[]
            {
                TransportServerFactory.Instance.Create(
                    PipeTransmissionServerFactory.Instance.Create(_workingDir), DefaultTransportSerializationProvider),
                TransportServerFactory.Instance.Create(
                    WebSocketTransmissionServerFactory.Instance.Create(
                        _workingDir,
                        new Dictionary <string, string> {
                    { "/metadata/interop", metadataFile }, { "/studio", studioDir }
                }),
                    DefaultTransportSerializationProvider)
            };
            _connectionListener  = new ServerConnectionListener(_transportServers);
            registryProvider     = registryProvider ?? JsonRegistryProvider.Initialize(Path.Combine(metadataDir, "interop.json"));
            _appLifecycleManager = AppLifecycleManagerFactory.Instance.Create(metadataDir);
            _brokerProcessor     = BrokerProcessorFactory.Instance.Create(
                _connectionListener.In,
                registryProvider,
                DefaultProtocolSerializationProvider,
                _appLifecycleManager);
            OnStop(_connectionListener.Stop);
        }
        public InteropContext(string metadataDir, IRegistryProvider registryProvider)
        {
            RegistryProvider = registryProvider;
            var appRegistryProvider = JsonFileAppRegistryProvider.Initialize(Path.Combine(metadataDir, "apps.json"));

            _nativeAppLauncherClient = new NativeAppLauncherClient(metadataDir);

            var clientLazy = new Lazy <IClient>(() => _lifecycleManagerClient);

            _appLifecycleManager = new AppLifecycleManager(appRegistryProvider, clientLazy);
            var appLaunchedEventProvider = new AppLaunchedEventProvider(_appLifecycleManager, registryProvider, clientLazy);

            var appMetadataService = new AppMetadataServiceImpl(appRegistryProvider, registryProvider);

            _appLifecycleService   = new AppLifecycleServiceImpl(_appLifecycleManager);
            _contextLinkageService = new ContextLinkageServiceImpl(registryProvider, _appLifecycleManager, appLaunchedEventProvider);

            _lifecycleManagerClient = new AppLifecycleManagerClient(
                _appLifecycleService,
                appMetadataService,
                _contextLinkageService,
                s => s.WithBrokerWorkingDir(Directory.GetCurrentDirectory()));

            OnStop(_nativeAppLauncherClient.Stop);
            OnStop(_lifecycleManagerClient.Disconnect);
        }
Exemple #3
0
        public InteropContext(Plexus.UniqueId trustedLauncherId, string metadataDir, IRegistryProvider registryProvider)
        {
            RegistryProvider = registryProvider;
            var appRegistryProvider = new JsonFileAppRegistryProvider(Path.Combine(metadataDir, "apps.json"));

            _appLifecycleManagerClientClientRepository = new AppLifecycleManagerClientClientRepository();
            var appLaunchedEventProvider = new AppLaunchedEventProvider();

            _appLifecycleManager = new AppLifecycleManager(appRegistryProvider, appLaunchedEventProvider, _appLifecycleManagerClientClientRepository);
            _appLifecycleManager.RegisterAppInstance(trustedLauncherId);
            _appLaunchedEventSubscriber = new AppLaunchedEventSubscriber(_appLifecycleManager, registryProvider, appLaunchedEventProvider, _appLifecycleManagerClientClientRepository);

            var nativeLauncherInstanceId = Plexus.UniqueId.Generate();

            _appLifecycleManager.RegisterAppInstanceConnection(Generated.NativeAppLauncherClient.Id, nativeLauncherInstanceId);
            _nativeAppLauncherClient = new NativeAppLauncherClient(metadataDir, nativeLauncherInstanceId);

            _appMetadataService     = new AppMetadataServiceImpl(appRegistryProvider, registryProvider);
            _appLifecycleService    = new AppLifecycleServiceImpl(_appLifecycleManager);
            _contextLinkageService  = new ContextLinkageServiceImpl(registryProvider, _appLifecycleManager, appLaunchedEventProvider);
            _appRegistrationService = new AppRegistrationServiceImpl(_appLifecycleManager);

            OnStop(_nativeAppLauncherClient.Stop);
            OnStop(_appLifecycleManagerClientClientRepository.Stop);
        }
Exemple #4
0
 public CertificateExpiryCheckJob(IHttpSysConfigurationProvider httpSysConfigProvider, ILogger <CertificateExpiryCheckJob> logger, IRegistryProvider registryProvider, ISmtpProvider smtpProvider, IOptionsMonitor <AdminNotificationOptions> emailOptions)
 {
     this.httpSysConfigProvider = httpSysConfigProvider;
     this.logger                   = logger;
     this.registryProvider         = registryProvider;
     this.smtpProvider             = smtpProvider;
     this.adminNotificationOptions = emailOptions;
 }
Exemple #5
0
        public AppMetadataServiceImpl(IAppRegistryProvider appRegistryProvider, IRegistryProvider registryProvider)
        {
            _appRegistrySubject = new BehaviorSubject<AppRegistry>(appRegistryProvider.Current);
            appRegistryProvider.Updated += registry => _appRegistrySubject.OnNext(registry);

            _metamodelSubject = new BehaviorSubject<IRegistry>(registryProvider.Current);
            registryProvider.Updated += registry => _metamodelSubject.OnNext(registry);
        }
Exemple #6
0
 public NewVersionCheckJob(IApplicationUpgradeProvider appUpgradeProvider, ILogger <NewVersionCheckJob> logger, ISmtpProvider smtpProvider, IOptionsMonitor <AdminNotificationOptions> adminNotificationOptions, IRegistryProvider registryProvider)
 {
     this.appUpgradeProvider       = appUpgradeProvider;
     this.logger                   = logger;
     this.registryProvider         = registryProvider;
     this.smtpProvider             = smtpProvider;
     this.adminNotificationOptions = adminNotificationOptions;
 }
 public RegistryService(IRegistryProvider registryProvider)
 {
     _registryProvider          = new BrokerRegistryProvider(registryProvider);
     _registryProvider.Updated += OnUpdated;
     if (_registry == null)
     {
         OnUpdated(_registryProvider.Current);
     }
 }
        public ContextLinkageServiceImpl(IRegistryProvider appRegistryProvider, IAppLifecycleManager appLifecycleManager, IAppLaunchedEventProvider appLaunchedEventProvider)
        {
            _appRegistryProvider = appRegistryProvider;
            _appLifecycleManager = appLifecycleManager;
            _contextsSet         = new ContextsSet(appLifecycleManager);

            appLaunchedEventProvider.AppLaunchedStream.Subscribe(OnAppLaunched);
            appLifecycleManager.ConnectionEventsStream.Subscribe(OnAppConnectedOrDisconnected);
        }
Exemple #9
0
        public Broker(string metadataDir = null, IRegistryProvider registryProvider = null)
        {
            _workingDir = Directory.GetCurrentDirectory();
            var binDir    = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
            var studioDir = Path.Combine(binDir, "studio");

            Log.Info("Studio dir: {0}", studioDir);
            metadataDir       = metadataDir ?? Path.Combine(_workingDir, "metadata");
            _transportServers = new[]
Exemple #10
0
        public BrokerRegistryProvider(IRegistryProvider baseRegistryProvider)
        {
            _baseRegistryProvider = baseRegistryProvider;
            var type = typeof(BrokerRegistryProvider);

            _embeddedRegistry              = JsonRegistry.LoadRegistry(type.GetTypeInfo().Assembly.GetManifestResourceStream(type.Namespace + ".interop.json"));
            Current                        = _embeddedRegistry.MergeWith(baseRegistryProvider.Current);
            _baseRegistryProvider.Updated += OnUpdated;
        }
 public AppLaunchedEventSubscriber(IAppLifecycleManager appConnectedEventProvider, IRegistryProvider registryProvider, IAppLaunchedEventConsumer appLaunchedEventConsumer, Lazy <IClient> client)
 {
     _registryProvider         = registryProvider;
     _appLaunchedEventConsumer = appLaunchedEventConsumer;
     _client = client;
     appConnectedEventProvider.ConnectionEventsStream
     .Where(ev => ev.Type == ConnectionEventType.AppConnected)
     .Select(ev => ev.Connection)
     .Subscribe(OnAppConnected);
 }
Exemple #12
0
 public BrokerRunner(string metadataDir = null, IRegistryProvider registryProvider = null)
 {
     _workingDir       = Path.GetFullPath(Directory.GetCurrentDirectory());
     metadataDir       = metadataDir ?? _workingDir;
     _registryProvider = registryProvider ??
                         JsonRegistryProvider.Initialize(Path.Combine(metadataDir, "interop.json"));
     _instanceSemaphore   = new Semaphore(1, 1, $"Global{Path.DirectorySeparatorChar}plexus-interop-broker-semaphore-{_workingDir.Replace(Path.DirectorySeparatorChar, ':')}");
     _transportServer     = new CompositeTransportServer(new[] { CreateNamedPipeServer(), CreateWebSocketServer() });
     _appLifecycleManager = new AppLifecycleManager(metadataDir, _workingDir);
 }
Exemple #13
0
 public LearningProviderManagementGroupLoader(
     IRegistryProvider registryProvider,
     IEntityRepository entityRepository,
     IGraphExecutionContextManager executionContextManager,
     ILoggerWrapper logger)
 {
     _registryProvider        = registryProvider;
     _entityRepository        = entityRepository;
     _executionContextManager = executionContextManager;
     _logger = logger;
 }
 public CensusResolver(
     IEntityRepository entityRepository,
     IRegistryProvider registryProvider,
     IGraphExecutionContextManager executionContextManager,
     ILoggerWrapper logger)
 {
     _entityRepository        = entityRepository;
     _registryProvider        = registryProvider;
     _executionContextManager = executionContextManager;
     _logger = logger;
 }
Exemple #15
0
        public AppLaunchedEventProvider(IAppConnectedEventProvider appConnectedEventProvider, IRegistryProvider registryProvider, Lazy <IClient> client)
        {
            _registryProvider = registryProvider;
            _client           = client;
            appConnectedEventProvider.ConnectionEventsStream
            .Where(ev => ev.Type == ConnectionEventType.AppConnected)
            .Select(ev => ev.Connection)
            .Subscribe(OnAppConnected);

            AppLaunchedStream = _appLaunchedSubject;
        }
 public IBrokerProcessor Create(
     IReadableChannel <ITransportConnection> incomingConnections,
     IRegistryProvider registryProvider,
     IProtocolSerializerFactory protocolSerializerFactory,
     IAppLifecycleManager appLifecycleManager)
 {
     return(new BrokerProcessor(
                incomingConnections,
                registryProvider,
                protocolSerializerFactory,
                appLifecycleManager));
 }
Exemple #17
0
        public BrokerProcessor(
            IReadableChannel <ITransportConnection> incomingConnections,
            IRegistryProvider registryProvider,
            IProtocolSerializerFactory serializerFactory,
            IAppLifecycleManager connectionTracker)
        {
            _incomingConnections = incomingConnections;
            var registryService = new RegistryService(registryProvider);
            var protocol        = new ProtocolImplementation(DefaultProtocolMessageFactory, serializerFactory);

            _authenticationHandler = new AuthenticationHandler(connectionTracker, protocol, registryService);
            _clientRequestHandler  = new ClientRequestHandler(connectionTracker, protocol, registryService);
        }
        public SqlLocalDbInstanceProvider(IAppPathProvider appPathProvider, ILogger <SqlLocalDbInstanceProvider> logger, IHostApplicationLifetime appLifeTime, IRegistryProvider registryProvider)
        {
            this.appPathProvider = appPathProvider;
            this.logger          = logger;
            this.appLifeTime     = appLifeTime;

            this.registryProvider = registryProvider;
            this.localDbApi       = new SqlLocalDbApi();
            this.localDbPath      = Path.Combine(this.appPathProvider.DbPath, $"{dbFileNamePrefix}.mdf");
            this.localDbLogPath   = Path.Combine(this.appPathProvider.DbPath, $"{dbFileNamePrefix}_log.ldf");

            this.appLifeTime.ApplicationStopped.Register(StopLocalDbInstance);
        }
 public AppLaunchedEventSubscriber(
     IAppLifecycleManager appConnectedEventProvider,
     IRegistryProvider registryProvider,
     IAppLaunchedEventConsumer appLaunchedEventConsumer,
     IAppLifecycleManagerClientClientRepository lifecycleManagerClientRepo)
 {
     _registryProvider           = registryProvider;
     _appLaunchedEventConsumer   = appLaunchedEventConsumer;
     _lifecycleManagerClientRepo = lifecycleManagerClientRepo;
     appConnectedEventProvider.ConnectionEventsStream
     .Where(ev => ev.Type == ConnectionEventType.AppConnected)
     .Select(ev => ev.Connection)
     .Subscribe(OnAppConnected);
 }
Exemple #20
0
        /// <summary>
        /// Attempts to get the Sansar installation directory
        /// </summary>
        /// <param name="registryProvider">Registry provider</param>
        /// <returns>Sansar installation directory on success, otherwise null</returns>
        public static string GetSansarDirectory(IRegistryProvider registryProvider)
        {
            var installLocation = registryProvider.GetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Sansar", "InstallLocation", null) as string;

            if (installLocation == null)
            {
                var iconPath = registryProvider.GetValue(@"HKEY_CLASSES_ROOT\sansar\DefaultIcon", "", null) as string;
                if (iconPath != null)
                {
                    installLocation = Path.GetFullPath(iconPath + @"\..\..");
                }
            }

            return(installLocation);
        }
Exemple #21
0
 public ManagementGroupResolver(
     IRegistryProvider registryProvider,
     IEntityRepository entityRepository,
     IDataLoaderContextAccessor accessor,
     ILoader <LearningProviderPointer, ManagementGroup> loader,
     IGraphExecutionContextManager executionContextManager,
     ILoggerWrapper logger)
 {
     _registryProvider        = registryProvider;
     _entityRepository        = entityRepository;
     _accessor                = accessor;
     _loader                  = loader;
     _executionContextManager = executionContextManager;
     _logger                  = logger;
 }
Exemple #22
0
        public WebAppPathProvider(IHostEnvironment env, IRegistryProvider registryProvider)
        {
            string appPath    = registryProvider.BasePath ?? env.ContentRootPath;
            string configPath = registryProvider.ConfigPath ?? Path.Combine(appPath, "config");

            configPath   = configPath.TrimEnd('\\');
            this.AppPath = appPath.TrimEnd('\\');

            this.TemplatesPath     = $"{configPath}\\audit-templates";
            this.ConfigFile        = $"{configPath}\\appsettings.json";
            this.HostingConfigFile = $"{configPath}\\apphost.json";
            this.ScriptsPath       = $"{configPath}\\scripts";
            this.LogoPath          = $"{configPath}\\logo.png";
            this.DbPath            = $"{configPath}\\db";
        }
        public BrokerProcessor(
            IReadableChannel <ITransportConnection> incomingConnections,
            IRegistryProvider registryProvider,
            IProtocolSerializerFactory serializerFactory,
            IAppLifecycleManager appLifecycleManager = null)
        {
            _incomingConnections = incomingConnections;
            var registryService = new RegistryService(registryProvider);
            var protocol        = new ProtocolImplementation(DefaultProtocolMessageFactory, serializerFactory);

            _appLifecycleManager = appLifecycleManager ?? new NoopAppLifecycleManager();
            var connectionTracker = new ClientConnectionTracker(_appLifecycleManager);

            _authenticationHandler = new AuthenticationHandler(connectionTracker, protocol, registryService);
            _clientRequestHandler  = new ClientRequestHandler(connectionTracker, protocol, registryService);
            Completion             = TaskRunner.RunInBackground(ProcessAsync);
        }
        public MainWindowViewModel(IApplicationConfig model, AuthenticationViewModel authentication, AuthorizationViewModel authorization, UserInterfaceViewModel ui, RateLimitsViewModel rate, IpDetectionViewModel ip,
                                   AuditingViewModel audit, EmailViewModel mail, HostingViewModel hosting, ActiveDirectoryConfigurationViewModel ad,
                                   JitConfigurationViewModel jit, LapsConfigurationViewModel laps, HelpViewModel help, BitLockerViewModel bitLocker, LicensingViewModel lic, HighAvailabilityViewModel havm, IEventAggregator eventAggregator, IDialogCoordinator dialogCoordinator, ILogger <MainWindowViewModel> logger, IShellExecuteProvider shellExecuteProvider, IWindowsServiceProvider windowsServiceProvider, IRegistryProvider registryProvider, ICertificateSynchronizationProvider certSyncProvider, IAmsLicenseManager licenseManager, IClusterProvider clusterProvider)
        {
            this.model = model;
            this.shellExecuteProvider = shellExecuteProvider;
            this.logger                 = logger;
            this.dialogCoordinator      = dialogCoordinator;
            this.windowsServiceProvider = windowsServiceProvider;
            this.hosting                = hosting;
            this.registryProvider       = registryProvider;
            this.eventAggregator        = eventAggregator;
            this.certSyncProvider       = certSyncProvider;
            this.dialogCoordinator      = dialogCoordinator;
            this.licenseManager         = licenseManager;
            this.clusterProvider        = clusterProvider;
            this.clusterWaitSemaphore   = new SemaphoreSlim(0, 1);

            this.eventAggregator.Subscribe(this);
            this.DisplayName = Constants.AppName;

            this.Items.Add(hosting);
            this.Items.Add(authentication);
            this.Items.Add(ui);
            this.Items.Add(mail);
            this.Items.Add(rate);
            this.Items.Add(ip);
            this.Items.Add(ad);
            this.Items.Add(audit);
            this.Items.Add(laps);
            this.Items.Add(jit);
            this.Items.Add(bitLocker);
            this.Items.Add(authorization);
            this.Items.Add(lic);
            this.Items.Add(havm);

            this.OptionItems = new BindableCollection <PropertyChangedBase> {
                help
            };

            this.ActiveItem = this.Items.First();

            this.UpdateIsConfigured();
            this.SetupClusterMonitor();
        }
Exemple #25
0
 public BrokerRunner(string metadataDir = null, IRegistryProvider registryProvider = null)
 {
     _workingDir       = Directory.GetCurrentDirectory();
     metadataDir       = metadataDir ?? Path.Combine(_workingDir, "metadata");
     _transportServers = new ITransportServer[]
     {
         new TransportServer(new PipeTransmissionServer(_workingDir), DefaultTransportSerializationProvider),
         new TransportServer(new WebSocketTransmissionServer(_workingDir), DefaultTransportSerializationProvider)
     };
     _connectionListener = new ServerConnectionListener(_transportServers);
     registryProvider    = registryProvider ?? JsonRegistryProvider.Initialize(Path.Combine(metadataDir, "interop.json"));
     _connectionTracker  = new AppLifecycleManager(metadataDir);
     _brokerProcessor    = new BrokerProcessor(
         _connectionListener.In,
         registryProvider,
         DefaultProtocolSerializationProvider,
         _connectionTracker);
     OnStop(_connectionListener.Stop);
 }
        public HostingViewModel(HostingOptions model, IDialogCoordinator dialogCoordinator, IWindowsServiceProvider windowsServiceProvider, ILogger <HostingViewModel> logger, IModelValidator <HostingViewModel> validator, IAppPathProvider pathProvider, INotifyModelChangedEventPublisher eventPublisher, ICertificateProvider certProvider, IShellExecuteProvider shellExecuteProvider, IEventAggregator eventAggregator, IDirectory directory, IScriptTemplateProvider scriptTemplateProvider, ICertificatePermissionProvider certPermissionProvider, IRegistryProvider registryProvider, ISecretRekeyProvider rekeyProvider, IObjectSelectionProvider objectSelectionProvider, IDiscoveryServices discoveryServices, IAmsLicenseManager licenseManager, IApplicationUpgradeProvider appUpgradeProvider, IHttpSysConfigurationProvider certificateBindingProvider, IFirewallProvider firewallProvider)
        {
            this.logger                     = logger;
            this.pathProvider               = pathProvider;
            this.OriginalModel              = model;
            this.certProvider               = certProvider;
            this.dialogCoordinator          = dialogCoordinator;
            this.windowsServiceProvider     = windowsServiceProvider;
            this.shellExecuteProvider       = shellExecuteProvider;
            this.eventAggregator            = eventAggregator;
            this.Validator                  = validator;
            this.directory                  = directory;
            this.scriptTemplateProvider     = scriptTemplateProvider;
            this.certPermissionProvider     = certPermissionProvider;
            this.registryProvider           = registryProvider;
            this.rekeyProvider              = rekeyProvider;
            this.objectSelectionProvider    = objectSelectionProvider;
            this.discoveryServices          = discoveryServices;
            this.licenseManager             = licenseManager;
            this.appUpgradeProvider         = appUpgradeProvider;
            this.certificateBindingProvider = certificateBindingProvider;
            this.firewallProvider           = firewallProvider;

            this.WorkingModel        = this.CloneModel(model);
            this.Certificate         = this.certificateBindingProvider.GetCertificate();
            this.OriginalCertificate = this.Certificate;
            this.ServiceAccount      = this.windowsServiceProvider.GetServiceAccountSid();
            this.ServiceStatus       = this.windowsServiceProvider.Status.ToString();
            this.DisplayName         = "Web hosting";

            this.licenseManager.OnLicenseDataChanged += delegate
            {
                this.NotifyOfPropertyChange(nameof(this.IsEnterpriseEdition));
                this.NotifyOfPropertyChange(nameof(this.IsStandardEdition));
            };

            eventPublisher.Register(this);
        }
Exemple #27
0
 public Migrator(IRegistryProvider registryProvider)
 {
     _registryProvider = registryProvider;
 }
 public IBroker Create(BrokerOptions options, IRegistryProvider registryProvider = null)
 {
     return(new Internal.Broker(options, registryProvider));
 }
 /// <summary>
 /// Initializes a new instance of <see cref="RegistryHookHandler"/>.
 /// </summary>
 /// <param name="registryProvider">The virtual registry to query when processing intercepted registry calls.</param>
 public RegistryHookHandler(IRegistryProvider registryProvider)
   : base(registryProvider)
 {
   _registry = registryProvider;
 }
 public RegistryValueController(IRegistryProvider registryProvider, INetworkShare networkShare)
 {
     _registryProvider = registryProvider;
     _networkShare = networkShare;
 }
Exemple #31
0
 public Startup(IConfiguration configuration)
 {
     this.Configuration    = configuration;
     this.registryProvider = new RegistryProvider(true);
 }
 public IInteropContext Create(UniqueId trustedLauncherId, string metadataDir, IRegistryProvider registryProvider)
 {
     return(new InteropContext(trustedLauncherId, metadataDir, registryProvider));
 }
Exemple #33
0
 /// <summary>
 /// Initializes a new instance of <see cref="RegistryHookHandler"/>.
 /// </summary>
 /// <param name="registryProvider">The virtual registry to query when processing intercepted registry calls.</param>
 public RegistryHookHandler(IRegistryProvider registryProvider)
     : base(registryProvider)
 {
     _registry = registryProvider;
 }