Example #1
0
        /// <summary>
        /// Create all components of the service and return an object which may be
        /// disposed to shut it down.
        /// </summary>
        public IDisposable StartInstance()
        {
            var instance = new Instance();

            Log.Diagnostics.Info(new ServiceStartingEvent());
            try
            {
                // Load configuration.
                const string rootUri = "https://localhost:7679/caber";

                // Start service.
                ICaberMutualAuthentication authentication = null;

                var serverBuilder = new CaberServerBuilder
                {
                    ServerUrl      = rootUri,
                    Authentication = authentication
                };

                var host = serverBuilder
                           .CreateKestrelBuilder()
                           .Build();
                host.Start();
                instance.Track(host);

                Log.Diagnostics.Info(new ServiceStartedEvent());
                return(instance);
            }
            catch
            {
                instance.Dispose();
                throw;
            }
        }
 public CaberMutualAuthenticationHandler(ICaberMutualAuthentication authentication, IOptionsMonitor <AuthenticationSchemeOptions> options, ILoggerFactory logger, UrlEncoder encoder, ISystemClock clock)
     : base(options, logger, encoder, clock)
 {
     Authentication = authentication ?? throw new ArgumentNullException(nameof(authentication));
 }