public static void Register(HttpConfiguration config) { // Web API configuration and services config.Formatters.XmlFormatter.UseXmlSerializer = true; ConfigureRouting(config); var constraintsResolver = new DefaultInlineConstraintResolver(); constraintsResolver.ConstraintMap.Add("apiVersionConstraint", typeof(ApiVersionConstraint)); // Web API routes config.MapHttpAttributeRoutes(constraintsResolver); config.Services.Replace(typeof(IHttpControllerSelector), new NamespaceHttpControllerSelector(config)); //config.EnableSystemDiagnosticsTracing(); config.Services.Replace(typeof(ITraceWriter), new SimpleTraceWriter(WebContainerManager.Get <ILogManager>())); config.Services.Add(typeof(IExceptionLogger), new SimpleExceptionLogger(WebContainerManager.Get <ILogManager>())); config.Services.Replace(typeof(IExceptionHandler), new GlobalExceptionHandler()); }
public static void Register(HttpConfiguration config) { //******Dependency Registries.Register(config); //****** // Web API configuration and services config.Services.Add(typeof(IExceptionLogger), new SimpleExceptionLogger(WebContainerManager.Get <INapLogger>())); config.Services.Replace(typeof(IExceptionHandler), new GlobalExceptionHandler()); config.EnableSystemDiagnosticsTracing(); config.Services.Replace(typeof(ITraceWriter), new TraceWriter(WebContainerManager.Get <INapLogger>())); var traceWriter = config.Services.GetTraceWriter(); traceWriter.Trace(null, "Application Startup: Nap.Logger.WebApi", TraceLevel.Info, "{0}", "Application Startup: Nap.Logger.WebApi."); var constraintsResolver = new DefaultInlineConstraintResolver(); constraintsResolver.ConstraintMap.Add("apiVersionConstraint", typeof(ApiVersionConstraint)); constraintsResolver.ConstraintMap.Add("valuerangeWithStatus", typeof(ValueRangeWithStatusRouteConstraint)); config.MapHttpAttributeRoutes(constraintsResolver); var naplogger = (INapLogger)config.DependencyResolver.GetService(typeof(INapLogger)); naplogger.Fatal("Application Startup: " + ConfigurationManager.AppSettings["LogName"]); }
public static void Register(HttpConfiguration config) { // Web API configuration and services // Web API routes var constraintsResolver = new DefaultInlineConstraintResolver(); constraintsResolver.ConstraintMap.Add("apiVersionConstraint", typeof(ApiVersionConstraint)); config.MapHttpAttributeRoutes(constraintsResolver); config.Services.Replace(typeof(IHttpControllerSelector), new NamespaceHttpControllerSelector(config)); config.Services.Replace(typeof(ITraceWriter), new SimpleTraceWriter(WebContainerManager.Get <ILogManager>())); config.Services.Add(typeof(IExceptionLogger), new SimpleExceptionLogger(WebContainerManager.Get <ILogManager>())); config.Services.Replace(typeof(IExceptionHandler), new GlobalExceptionHandler()); config.EnableSystemDiagnosticsTracing(); //Matches route with the taskNum parameter //config.Routes.MapHttpRoute( // name: "FindByTaskNumberRoute", // routeTemplate: "api/{controller}/{taskNum}", // defaults: new { taskNum = RouteParameter.Optional } //); //config.Routes.MapHttpRoute( // name: "DefaultApi", // routeTemplate: "api/{controller}/{id}", // defaults: new { id = RouteParameter.Optional } //); }
public static void Register(HttpConfiguration config) { var constraintsResolver = new DefaultInlineConstraintResolver(); constraintsResolver.ConstraintMap.Add("apiVersionConstraint", typeof(ApiVersionConstraint)); config.MapHttpAttributeRoutes(constraintsResolver); config.Services.Replace(typeof(IHttpControllerSelector), new NamespaceHttpControllerSelector(config)); config.Services.Replace(typeof(ITraceWriter), new SimpleTraceWriter(WebContainerManager.Get <ILogManager>())); config.Services.Add(typeof(IExceptionLogger), new SimpleExceptionLogger( WebContainerManager.Get <ILogManager>())); config.Services.Replace(typeof(IExceptionHandler), new GlobalExceptionHandler()); //Unneeded //config.MapHttpAttributeRoutes(); //config.Routes.MapHttpRoute( // name: "DefaultApi", // routeTemplate: "api/{controller}/{id}", // defaults: new { id = RouteParameter.Optional } //); }
private void RegisterHandlers() { var logManager = WebContainerManager.Get <ILogManager>(); var userSession = WebContainerManager.Get <IUserSession>(); GlobalConfiguration.Configuration.MessageHandlers.Add( new BasicAuthenticationMessageHandler(logManager, WebContainerManager.Get <IBasicSecurityService>())); GlobalConfiguration.Configuration.MessageHandlers.Add(new TaskDataSecurityMessageHandler(logManager, userSession)); GlobalConfiguration.Configuration.MessageHandlers.Add(new PagedTaskDataSecurityMessageHandler(logManager, userSession)); var builder = new SecurityTokenBuilder(); var reader = new ConfigurationReader(); GlobalConfiguration.Configuration.MessageHandlers.Add( new JwtAuthenticationMessageHandler { AllowedAudience = reader.AllowedAudience, Issuer = reader.Issuer, SigningToken = builder.CreateFromKey(reader.SymmetricKey) }); }
public static void Register(HttpConfiguration config) { // Web API configuration and services // Web API routes var constraintsResolver = new DefaultInlineConstraintResolver(); constraintsResolver.ConstraintMap.Add("apiVersionConstraint", typeof(ApiVersionConstraint)); config.MapHttpAttributeRoutes(constraintsResolver); config.Services.Replace(typeof(IHttpControllerSelector), new NamespaceHttpControllerSelector(config)); config.Routes.MapHttpRoute( name: "DefaultApi", routeTemplate: "api/{controller}/{id}", defaults: new { id = RouteParameter.Optional } ); //Default enabling of diagnostic tracing //config.EnableSystemDiagnosticsTracing(); //overriding with a custom tracing config.Services.Replace(typeof(ITraceWriter), new SimpleTraceWriter(WebContainerManager.Get <ILogManager>())); config.Services.Add(typeof(IExceptionLogger), new SimpleExceptionLogger(WebContainerManager.Get <ILogManager>())); config.Services.Replace(typeof(IExceptionHandler), new GlobalExceptionHandler()); }
private void RegisterHandlers() { var logManager = WebContainerManager.Get <ILogManager>(); GlobalConfiguration.Configuration.MessageHandlers.Add( new BasicAuthenticationMessageHandler(logManager, WebContainerManager.Get <IBasicSecurityService>())); }
private static Client GetClientFromRepository(OAuthValidateClientAuthenticationContext context, Client client) { IAccountRepository repository = WebContainerManager.Get <IAccountRepository>(); client = repository.FindClient(context.ClientId); repository.Dispose(); return(client); }
protected void Application_Error() { var exception = Server.GetLastError(); if (exception != null) { var log = WebContainerManager.Get <ILogManager>().GetLog(typeof(WebApiApplication)); log.Error("Unhandled exception.", exception); } }
private void RegisterHandlers() { var logManager = WebContainerManager.Get <ILogManager>(); var userSession = WebContainerManager.Get <IUserSession>(); var basicSecService = WebContainerManager.Get <IBasicSecurityService>(); GlobalConfiguration.Configuration.MessageHandlers.Add( new BasicAuthenticationMessageHandler(logManager, basicSecService)); GlobalConfiguration.Configuration.MessageHandlers.Add( new TaskDataSecurityMessageHandler(logManager, userSession)); }
public static void Register(HttpConfiguration config) { var constraintsResolver = new DefaultInlineConstraintResolver(); constraintsResolver.ConstraintMap.Add("apiVersionConstraint", typeof(ApiVersionConstraint)); config.MapHttpAttributeRoutes(constraintsResolver); config.Services.Replace(typeof(IHttpControllerSelector), new NamespaceHttpControllerSelector(config)); //config.EnableSystemDiagnosticsTracing(); // replaced by custom writer config.Services.Replace(typeof(ITraceWriter), new SimpleTraceWriter(WebContainerManager.Get <ILogManager>())); config.Services.Add(typeof(IExceptionLogger), new SimpleExceptionLogger(WebContainerManager.Get <ILogManager>())); config.Services.Replace(typeof(IExceptionHandler), new GlobalExceptionHandler()); config.EnableCors(); }
public ICommand Resolve(CommandEnum commandEnum, object[] args) { if (args == null) { throw new ArgumentNullException(nameof(args)); } if (!Enum.IsDefined(typeof(CommandEnum), commandEnum)) { throw new InvalidEnumArgumentException(nameof(commandEnum), (int)commandEnum, typeof(CommandEnum)); } var commandType = _commandsDictionary[commandEnum]; return(WebContainerManager.Get <ICommand>(commandType.Name)); }
public static void Register(HttpConfiguration config) { // Registere custom Route constraint for API Versioning (via ApiVersionConstraint class) with ASP.NET Web API // so that it gets applied to incoming requests. var constraintResolver = new DefaultInlineConstraintResolver(); constraintResolver.ConstraintMap.Add("apiVersionConstraint", typeof(ApiVersionConstraint)); config.MapHttpAttributeRoutes(constraintResolver); // Replace default implementation of controller selector to use our custom controller selector config.Services.Replace(typeof(IHttpControllerSelector), new NamespaceHttpControllerSelector(config)); // config.EnableSystemDiagnosticsTracing(); // replacing this with our custom ITraceWriter config.Services.Replace(typeof(ITraceWriter), new SimpleTraceWriter(WebContainerManager.Get <ILogManager>())); config.Services.Add(typeof(IExceptionLogger), new SimpleExceptionLogger(WebContainerManager.Get <ILogManager>())); config.Services.Replace(typeof(IExceptionHandler), new GlobalExceptionHandler()); }
private void ConfigureOAuth(IAppBuilder app) { var serverOptions = new OAuthAuthorizationServerOptions() { AllowInsecureHttp = true, TokenEndpointPath = new PathString("/token"), AccessTokenExpireTimeSpan = TimeSpan.FromDays(1), Provider = new SimpleAuthorizationServerProvider(WebContainerManager.Get <IUsuarioRepository>()) }; app.UseOAuthAuthorizationServer(serverOptions); var bearerOptions = new OAuthBearerAuthenticationOptions(); app.UseOAuthBearerAuthentication(bearerOptions); }
public static void Register(HttpConfiguration config) { // Web API routes config.MapHttpAttributeRoutes(); config.Routes.MapHttpRoute( name: "DefaultApi", routeTemplate: "api/{controller}/{id}", defaults: new { id = RouteParameter.Optional } ); config.Formatters.JsonFormatter.SupportedMediaTypes.Add(new MediaTypeHeaderValue("text/html")); config.Services.Add(typeof(IExceptionLogger), new SimpleExceptionLogger(WebContainerManager.Get <ILogManager>())); config.Services.Replace(typeof(IExceptionHandler), new GlobalExceptionHandler()); config.Services.Replace(typeof(ITraceWriter), new SimpleTraceWriter(WebContainerManager.Get <ILogManager>())); config.EnableSystemDiagnosticsTracing(); }
public static void Register(HttpConfiguration config) { // http://stackoverflow.com/questions/12976352/asp-net-web-api-model-binding-not-working-with-xml-data-on-post config.Formatters.XmlFormatter.UseXmlSerializer = true; config.EnableCors(); ConfigureRouting(config); // To disable tracing in your application, please comment out or remove the following line of code // For more information, refer to: http://www.asp.net/web-api config.Services.Replace(typeof(ITraceWriter), new SimpleTraceWriter(WebContainerManager.Get <ILogManager>())); config.Services.Add(typeof(IExceptionLogger), new SimpleExceptionLogger(WebContainerManager.Get <ILogManager>())); config.Services.Replace(typeof(IExceptionHandler), new GlobalExceptionHandler()); }
public static void Register(HttpConfiguration config) { // // Web API configuration and services // // Configure Web API to use only bearer token authentication. // config.SuppressDefaultHostAuthentication(); // config.Filters.Add(new HostAuthenticationFilter(OAuthDefaults.AuthenticationType)); var constraintsResolver = new DefaultInlineConstraintResolver(); constraintsResolver.ConstraintMap.Add("apiVersionConstraint", typeof(ApiVersionConstraint)); config.MapHttpAttributeRoutes(constraintsResolver); config.Services.Replace(typeof(IHttpControllerSelector), new NamespaceHttpControllerSelector(config)); config.EnableSystemDiagnosticsTracing(); config.Services.Add(typeof(IExceptionLogger), new SimpleExceptionLogger(WebContainerManager.Get <ILogManager>())); config.Services.Replace(typeof(ITraceWriter), new SimpleTraceWriter(WebContainerManager.Get <ILogManager>())); config.Services.Replace(typeof(IExceptionHandler), new GlobalExceptionHandler()); }
public static void Register(HttpConfiguration config) { var constraintsResolver = new DefaultInlineConstraintResolver(); constraintsResolver.ConstraintMap.Add("apiVersionConstraint", typeof(ApiVersionConstraint)); config.MapHttpAttributeRoutes(constraintsResolver); config.Services.Replace(typeof(IHttpControllerSelector), new NamespaceHttpControllerSelector(config)); config.Services.Add(typeof(IExceptionLogger), new SimpleExceptionLogger(WebContainerManager.Get <ILogManager>())); config.Services.Replace(typeof(IExceptionHandler), new GlobalExceptionHandler()); config.MessageHandlers.Add(new TokenValidationHandler()); config.Routes.MapHttpRoute( name: "CatchAllUrlTo404", routeTemplate: "{*uri}" ); }
private static void ConfigureRouting(HttpConfiguration config) { config.Routes.MapHttpRoute( name: "legacyRoute", routeTemplate: "TeamTaskService.asmx", defaults: null, constraints: null, handler: new LegacyAuthenticationMessageHandler(WebContainerManager.Get <ILogManager>()) { InnerHandler = new LegacyMessageHandler { InnerHandler = new HttpControllerDispatcher(config) } }); var constraintsResolver = new DefaultInlineConstraintResolver(); constraintsResolver.ConstraintMap.Add("apiVersionConstraint", typeof(ApiVersionConstraint)); config.MapHttpAttributeRoutes(constraintsResolver); config.Services.Replace(typeof(IHttpControllerSelector), new NamespaceHttpControllerSelector(config)); }
public override async Task GrantResourceOwnerCredentials(OAuthGrantResourceOwnerCredentialsContext context) { context.OwinContext.Response.Headers.Add("Access-Control-Allow-Origin", new[] { "*" }); if (IsEmailAddressInvalid(context.UserName)) { context.SetError("invalid_grant", "incorrect_email"); return; } IAccountRepository repository = WebContainerManager.Get <IAccountRepository>(); IdentityUser emailRegistered = await repository.FindByEmailAsync(context.UserName); if (emailRegistered == null) { context.SetError("invalid_grant", "email_not_registered"); return; } IdentityUser user = await repository.FindUser(context.UserName, context.Password); repository.Dispose(); if (user == null) { context.SetError("invalid_grant", "incorrect_password"); return; } var identity = new ClaimsIdentity(context.Options.AuthenticationType); identity.AddClaim(new Claim("sub", context.UserName)); identity.AddClaim(new Claim("role", "user")); context.Validated(identity); }
public UserAuditAttribute() : this(WebContainerManager.Get <ILogManager>(), WebContainerManager.Get <IUserSession>()) { }
public void Get_Returns_Instance_Of_Class() { ITestableInterface testable = WebContainerManager.Get <ITestableInterface>(); Assert.IsInstanceOf <TestableClass>(testable); }
private void ConfigureFormatters() { var legacyFormatter = (MediaTypeFormatter)WebContainerManager.Get <ILegacyMessageTypeFormatter>(); GlobalConfiguration.Configuration.Formatters.Insert(0, legacyFormatter); }
public ValidateTaskUpdateRequestAttribute() : this(WebContainerManager.Get <ILogManager>()) { }
public static void Register(HttpConfiguration config) { ConfigureRouting(config); //config.EnableSystemDiagnosticsTracing(); config.Services.Replace(typeof(ITraceWriter), new SimpleTraceWriter(WebContainerManager.Get <ILogManager>())); }
public SimpleAuthorizationServerProvider(Func <UserManager <ApplicationUser> > userManagerFactory) { _userManagerFactory = userManagerFactory; _dbContext = WebContainerManager.Get <IDbContext>(); }
private void RegisterHandlers() { var logManager = WebContainerManager.Get <ILogManager>(); var userSession = WebContainerManager.Get <IUserSession>(); }