示例#1
0
        public override void OnActionExecuting(HttpActionContext filterContext)
        {
            //  Get API key provider
            var provider = ServicesFactory.GetTokenServices();

            if (filterContext.Request.Headers.Contains(Token))
            {
                var tokenValue = filterContext.Request.Headers.GetValues(Token).First();

                // Validate Token
                if (provider != null && !provider.ValidateToken(tokenValue))
                {
                    var responseMessage = new HttpResponseMessage(HttpStatusCode.Unauthorized)
                    {
                        ReasonPhrase = "Invalid Request"
                    };
                    filterContext.Response = responseMessage;
                }
            }
            else
            {
                filterContext.Response = new HttpResponseMessage(HttpStatusCode.Unauthorized);
            }

            base.OnActionExecuting(filterContext);
        }
示例#2
0
 /// <summary>
 /// Public constructor to initialize product service instance
 /// </summary>
 public QuoteController()
 {
     _quoteServices = ServicesFactory.GetQuoteServices();
     _tokenServices = ServicesFactory.GetTokenServices();
 }
示例#3
0
 /// <summary>
 /// Public constructor to initialize product service instance
 /// </summary>
 public AuthenticateController()
 {
     _tokenServices = ServicesFactory.GetTokenServices();
     _userServices  = ServicesFactory.GetUserServices();
 }