예제 #1
0
 public SmtpService(EntityApp app, SmtpSettings settings)
 {
     _app      = app;
     _settings = settings;
     _app.RegisterService <ISmtpService>(this);
     _app.RegisterConfig(settings);
 }
예제 #2
0
        public VitaJwtTokenHandler(EntityApp entityApp, IServiceCollection services, string jwtSecret)
        {
            _entityApp = entityApp;
            _entityApp.RegisterService <IAuthenticationTokenHandler>(this);
            var secretBytes = Encoding.ASCII.GetBytes(jwtSecret);

            _jwtKey = new SymmetricSecurityKey(secretBytes);
            // some cryptic code copied from samples somewhere
            services.AddAuthentication(x => {
                x.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme;
                x.DefaultChallengeScheme    = JwtBearerDefaults.AuthenticationScheme;
            })
            .AddJwtBearer(x => {
                x.Events = new JwtBearerEvents {
                    OnTokenValidated = OnJwtTokenValidated
                };

                x.RequireHttpsMetadata      = false;
                x.SaveToken                 = true;
                x.TokenValidationParameters = new TokenValidationParameters {
                    ValidateIssuerSigningKey = true,
                    IssuerSigningKey         = _jwtKey,
                    ValidateIssuer           = false,
                    ValidateAudience         = false
                };
            });
        }
예제 #3
0
 public WebCallContextHandler(EntityApp app, WebCallContextHandlerSettings settings) {
   App = app;
   Settings = settings ?? new WebCallContextHandlerSettings();
   App.RegisterConfig(Settings);
   _webCallLog = App.GetService<IWebCallLogService>();
   _errorLog = App.GetService<IErrorLogService>();
   App.RegisterService<IWebCallNotificationService>(this); 
 }
예제 #4
0
 public WebCallContextHandler(EntityApp app, WebCallContextHandlerSettings settings)
 {
     App      = app;
     Settings = settings ?? new WebCallContextHandlerSettings();
     App.RegisterConfig(Settings);
     _webCallLog     = App.GetService <IWebCallLogService>();
     _errorLog       = App.GetService <IErrorLogService>();
     _sessionService = App.GetService <IUserSessionService>();
     App.RegisterService <IWebCallNotificationService>(this);
 }
예제 #5
0
        public static ILogBatchingService GetCreateLogBatchingService(EntityApp app)
        {
            var iServ = (ILogBatchingService)app.GetService(typeof(ILogBatchingService));

            if (iServ != null)
            {
                return(iServ);
            }
            // create and register it
            var batchingServ = new LogBatchingService();

            app.RegisterService <ILogBatchingService>(batchingServ);
            batchingServ.Init(app);
            return(batchingServ);
        }
예제 #6
0
        public static void ConfigureWebApi(HttpConfiguration httpConfiguration, EntityApp app,
                                           LogLevel logLevel = LogLevel.Basic,
                                           WebHandlerOptions webHandlerOptions = WebHandlerOptions.DefaultDebug,
                                           ApiNameMapping nameMapping          = ApiNameMapping.Default)
        {
            // Logging message handler
            var webHandlerStt     = new WebCallContextHandlerSettings(logLevel, webHandlerOptions);
            var webContextHandler = new WebCallContextHandler(app, webHandlerStt);

            httpConfiguration.MessageHandlers.Add(webContextHandler);

            // Exception handling filter - to handle/save exceptions
            httpConfiguration.Filters.Add(new ExceptionHandlingFilter());

            // Formatters - add formatters with spies, to catch/log deserialization failures
            httpConfiguration.Formatters.Clear();
            httpConfiguration.Formatters.Add(new StreamMediaTypeFormatter("image/jpeg", "image/webp")); //webp is for Chrome
            var xmlFmter = new XmlMediaTypeFormatter();

            httpConfiguration.Formatters.Add(xmlFmter);
            var jsonFmter = new JsonMediaTypeFormatter();

            // add converter that will serialize all enums as strings, not integers
            jsonFmter.SerializerSettings.Converters.Add(new Newtonsoft.Json.Converters.StringEnumConverter());
            jsonFmter.SerializerSettings.ContractResolver     = new JsonNameContractResolver(nameMapping);
            jsonFmter.SerializerSettings.DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Unspecified;
            httpConfiguration.Formatters.Add(jsonFmter);

            //Api configuration
            if (app.ApiConfiguration.ControllerInfos.Count > 0)
            {
                ConfigureSlimApiControllers(httpConfiguration, app);
            }

            app.RegisterService <IBackgroundTaskService>(new WebBackgroundTaskService(app));
        }
예제 #7
0
 public SmtpService(EntityApp app, SmtpSettings settings)  {
   _app = app; 
   _settings = settings;
   _app.RegisterService<IEmailSendService>(this);
   _app.RegisterConfig(settings); 
 }
예제 #8
0
 public NotificationService(EntityApp app)
 {
     _app = app;
     _app.RegisterService <INotificationService>(this);
 }
예제 #9
0
 public AuthorizationService(EntityApp app)
 {
     _app = app;
       _app.RegisterService<IAuthorizationService>(this);
       _builder = new AuthorityBuilder(_app);
 }
예제 #10
0
 public DataAccessService(EntityApp app, EntityCache sharedCache = null) {
   _app = app;
   _events = new DataSourceEvents(this);
   app.RegisterService<IDataAccessService>(this); 
 }
예제 #11
0
 public NotificationService(EntityApp app) {
   _app = app;
   _app.RegisterService<INotificationService>(this); 
 }
예제 #12
0
 public VitaWebMiddleware(RequestDelegate next, EntityApp app)
 {
     _next = next;
     App   = app;
     App.RegisterService <IWebCallNotificationService>(this);
 }