Ejemplo n.º 1
0
 public void OnAuthenticationChallenge(AuthenticationChallengeContext filterContext)
 {
     filterContext.HttpContext.Response.Write("<p>AuthenticationFilter - OnAuthenticationChallenge</p>");
 }
Ejemplo n.º 2
0
 public void OnAuthenticationChallenge(AuthenticationChallengeContext filterContext)
 {
     this._wrappedFilter.OnAuthenticationChallenge(filterContext);
 }
Ejemplo n.º 3
0
 public void OnAuthenticationChallenge(AuthenticationChallengeContext filterContext)
 {
     LogManager.AuthenticationLog("On AuthenticationChallenge", filterContext.Result.ToString());
 }
Ejemplo n.º 4
0
 public void OnAuthenticationChallenge(AuthenticationChallengeContext filterContext)
 {
     //这个方法是在Action执行之后调用
 }
 public abstract void OnAuthenticationChallenge(AuthenticationChallengeContext filterContext);
Ejemplo n.º 6
0
 public void OnAuthenticationChallenge(AuthenticationChallengeContext context)
 {
     context.Result = new AddOAuthChallengeResult(context.Result, Realm);
 }
Ejemplo n.º 7
0
 void IAuthenticationFilter.OnAuthenticationChallenge(AuthenticationChallengeContext filterContext)
 {
     OnAuthenticationChallenge(filterContext);
 }
Ejemplo n.º 8
0
 public void OnAuthenticationChallenge(AuthenticationChallengeContext filterContext)
 {
     Console.WriteLine("OnAuthenticationChallenge");
 }
Ejemplo n.º 9
0
 protected override void OnAuthenticationChallenge(AuthenticationChallengeContext filterContext)
 {
     //custom authentication challenge logic
 }
Ejemplo n.º 10
0
 public void OnAuthenticationChallenge(AuthenticationChallengeContext filterContext)
 {
     SessionManager.StoreInSession(filterContext, "OnAuthenticationChallenge");
 }
 public void OnAuthenticationChallenge(AuthenticationChallengeContext filterContext)
 {
     Log.Debug("", filterContext.Controller, filterContext.ActionDescriptor, filterContext.DisplayMode);
 }
 public void OnAuthenticationChallenge(AuthenticationChallengeContext filterContext)
 {
     //This method is responsible for validating the current principal and permitting the execution of the current action/request.
     //Here you should validate if the current principle is valid / permitted to invoke the current action. (However I would place this logic to an authorization filter)
     //filterContext.Result = new RedirectToRouteResult("CustomErrorPage",null);
 }
        protected async Task <bool> InvokeActionAsync(ControllerContext controllerContext, ActionDescriptor actionDescriptor)
        {
            if (controllerContext == null)
            {
                throw new ArgumentNullException("controllerContext");
            }

            FilterInfo       filterInfo       = GetFilters(controllerContext, actionDescriptor);
            ExceptionContext exceptionContext = null;

            try
            {
                AuthenticationContext authenticationContext = InvokeAuthenticationFilters(controllerContext,
                                                                                          filterInfo.AuthenticationFilters, actionDescriptor);
                if (authenticationContext.Result != null)
                {
                    // An authentication filter signaled that we should short-circuit the request. Let all
                    // authentication filters contribute to an action result (to combine authentication
                    // challenges). Then, run this action result.
                    AuthenticationChallengeContext challengeContext =
                        InvokeAuthenticationFiltersChallenge(controllerContext,
                                                             filterInfo.AuthenticationFilters, actionDescriptor, authenticationContext.Result);
                    await InvokeActionResultAsync(controllerContext,
                                                  challengeContext.Result ?? authenticationContext.Result).ConfigureAwait(false);
                }
                else
                {
                    AuthorizationContext authorizationContext = InvokeAuthorizationFilters(controllerContext, filterInfo.AuthorizationFilters, actionDescriptor);
                    if (authorizationContext.Result != null)
                    {
                        // An authorization filter signaled that we should short-circuit the request. Let all
                        // authentication filters contribute to an action result (to combine authentication
                        // challenges). Then, run this action result.
                        AuthenticationChallengeContext challengeContext =
                            InvokeAuthenticationFiltersChallenge(controllerContext,
                                                                 filterInfo.AuthenticationFilters, actionDescriptor, authorizationContext.Result);
                        await InvokeActionResultAsync(controllerContext,
                                                      challengeContext.Result ?? authorizationContext.Result).ConfigureAwait(false);
                    }
                    else
                    {
                        if (controllerContext.Controller.ValidateRequest)
                        {
                            ValidateRequest(controllerContext);
                        }

                        IDictionary <string, object> parameters        = GetParameterValues(controllerContext, actionDescriptor);
                        ActionExecutedContext        postActionContext =
                            await Task <ActionExecutedContext> .Factory.FromAsync(
                                delegate(AsyncCallback asyncCallback, object asyncState)
                        {
                            return(BeginInvokeActionMethodWithFilters(controllerContext, filterInfo.ActionFilters, actionDescriptor, parameters, asyncCallback, asyncState));
                        },
                                EndInvokeActionMethodWithFilters,
                                null);

                        // The action succeeded. Let all authentication filters contribute to an action
                        // result (to combine authentication challenges; some authentication filters need
                        // to do negotiation even on a successful result). Then, run this action result.
                        AuthenticationChallengeContext challengeContext =
                            InvokeAuthenticationFiltersChallenge(controllerContext,
                                                                 filterInfo.AuthenticationFilters, actionDescriptor,
                                                                 postActionContext.Result);
                        await InvokeActionResultWithFiltersAsync(controllerContext, filterInfo.ResultFilters,
                                                                 challengeContext.Result ?? postActionContext.Result).ConfigureAwait(false);
                    }
                }
            }
            catch (ThreadAbortException)
            {
                // This type of exception occurs as a result of Response.Redirect(), but we special-case so that
                // the filters don't see this as an error.
                throw;
            }
            catch (Exception ex)
            {
                // something blew up, so execute the exception filters
                exceptionContext = InvokeExceptionFilters(controllerContext, filterInfo.ExceptionFilters, ex);
                if (!exceptionContext.ExceptionHandled)
                {
                    throw;
                }
            }
            if (exceptionContext != null)
            {
                await InvokeActionResultAsync(controllerContext, exceptionContext.Result).ConfigureAwait(false);
            }
            return(true);
        }
 public void OnAuthenticationChallenge(AuthenticationChallengeContext filterContext)
 {
     // modify filterContext.Result to go somewhere special...if you do
     // nothing here they will just go to the site's default login
 }
Ejemplo n.º 15
0
 public void OnAuthenticationChallenge(AuthenticationChallengeContext filterContext)
 {
     // Impletation for this isn't require
 }
Ejemplo n.º 16
0
        public virtual IAsyncResult BeginInvokeAction(ControllerContext controllerContext, string actionName, AsyncCallback callback, object state)
        {
            if (controllerContext == null)
            {
                throw new ArgumentNullException("controllerContext");
            }

            Contract.Assert(controllerContext.RouteData != null);
            if (String.IsNullOrEmpty(actionName) && !controllerContext.RouteData.HasDirectRouteMatch())
            {
                throw Error.ParameterCannotBeNullOrEmpty("actionName");
            }

            ControllerDescriptor controllerDescriptor = GetControllerDescriptor(controllerContext);
            ActionDescriptor     actionDescriptor     = FindAction(controllerContext, controllerDescriptor, actionName);

            if (actionDescriptor != null)
            {
                FilterInfo filterInfo   = GetFilters(controllerContext, actionDescriptor);
                Action     continuation = null;

                BeginInvokeDelegate beginDelegate = delegate(AsyncCallback asyncCallback, object asyncState)
                {
                    try
                    {
                        AuthenticationContext authenticationContext = InvokeAuthenticationFilters(controllerContext,
                                                                                                  filterInfo.AuthenticationFilters, actionDescriptor);
                        if (authenticationContext.Result != null)
                        {
                            // An authentication filter signaled that we should short-circuit the request. Let all
                            // authentication filters contribute to an action result (to combine authentication
                            // challenges). Then, run this action result.
                            AuthenticationChallengeContext challengeContext =
                                InvokeAuthenticationFiltersChallenge(controllerContext,
                                                                     filterInfo.AuthenticationFilters, actionDescriptor, authenticationContext.Result);
                            continuation = () => InvokeActionResult(controllerContext,
                                                                    challengeContext.Result ?? authenticationContext.Result);
                        }
                        else
                        {
                            AuthorizationContext authorizationContext = InvokeAuthorizationFilters(controllerContext, filterInfo.AuthorizationFilters, actionDescriptor);
                            if (authorizationContext.Result != null)
                            {
                                // An authorization filter signaled that we should short-circuit the request. Let all
                                // authentication filters contribute to an action result (to combine authentication
                                // challenges). Then, run this action result.
                                AuthenticationChallengeContext challengeContext =
                                    InvokeAuthenticationFiltersChallenge(controllerContext,
                                                                         filterInfo.AuthenticationFilters, actionDescriptor, authorizationContext.Result);
                                continuation = () => InvokeActionResult(controllerContext,
                                                                        challengeContext.Result ?? authorizationContext.Result);
                            }
                            else
                            {
                                if (controllerContext.Controller.ValidateRequest)
                                {
                                    ValidateRequest(controllerContext);
                                }

                                IDictionary <string, object> parameters = GetParameterValues(controllerContext, actionDescriptor);
                                IAsyncResult asyncResult = BeginInvokeActionMethodWithFilters(controllerContext, filterInfo.ActionFilters, actionDescriptor, parameters, asyncCallback, asyncState);
                                continuation = () =>
                                {
                                    ActionExecutedContext postActionContext = EndInvokeActionMethodWithFilters(asyncResult);
                                    // The action succeeded. Let all authentication filters contribute to an action
                                    // result (to combine authentication challenges; some authentication filters need
                                    // to do negotiation even on a successful result). Then, run this action result.
                                    AuthenticationChallengeContext challengeContext =
                                        InvokeAuthenticationFiltersChallenge(controllerContext,
                                                                             filterInfo.AuthenticationFilters, actionDescriptor,
                                                                             postActionContext.Result);
                                    InvokeActionResultWithFilters(controllerContext, filterInfo.ResultFilters,
                                                                  challengeContext.Result ?? postActionContext.Result);
                                };
                                return(asyncResult);
                            }
                        }
                    }
                    catch (ThreadAbortException)
                    {
                        // This type of exception occurs as a result of Response.Redirect(), but we special-case so that
                        // the filters don't see this as an error.
                        throw;
                    }
                    catch (Exception ex)
                    {
                        // something blew up, so execute the exception filters
                        ExceptionContext exceptionContext = InvokeExceptionFilters(controllerContext, filterInfo.ExceptionFilters, ex);
                        if (!exceptionContext.ExceptionHandled)
                        {
                            throw;
                        }

                        continuation = () => InvokeActionResult(controllerContext, exceptionContext.Result);
                    }

                    return(BeginInvokeAction_MakeSynchronousAsyncResult(asyncCallback, asyncState));
                };

                EndInvokeDelegate <bool> endDelegate = delegate(IAsyncResult asyncResult)
                {
                    try
                    {
                        continuation();
                    }
                    catch (ThreadAbortException)
                    {
                        // This type of exception occurs as a result of Response.Redirect(), but we special-case so that
                        // the filters don't see this as an error.
                        throw;
                    }
                    catch (Exception ex)
                    {
                        // something blew up, so execute the exception filters
                        ExceptionContext exceptionContext = InvokeExceptionFilters(controllerContext, filterInfo.ExceptionFilters, ex);
                        if (!exceptionContext.ExceptionHandled)
                        {
                            throw;
                        }
                        InvokeActionResult(controllerContext, exceptionContext.Result);
                    }

                    return(true);
                };

                return(AsyncResultWrapper.Begin(callback, state, beginDelegate, endDelegate, _invokeActionTag));
            }
            else
            {
                // Notify the controller that no action was found.
                return(BeginInvokeAction_ActionNotFound(callback, state));
            }
        }
Ejemplo n.º 17
0
        public virtual bool InvokeAction(ControllerContext controllerContext, string actionName)
        {
            if (controllerContext == null)
            {
                throw new ArgumentNullException("controllerContext");
            }

            Contract.Assert(controllerContext.RouteData != null);
            if (String.IsNullOrEmpty(actionName) && !controllerContext.RouteData.HasDirectRouteMatch())
            {
                throw new ArgumentException(MvcResources.Common_NullOrEmpty, "actionName");
            }

            ControllerDescriptor controllerDescriptor = GetControllerDescriptor(controllerContext);
            ActionDescriptor     actionDescriptor     = FindAction(controllerContext, controllerDescriptor, actionName);

            if (actionDescriptor != null)
            {
                FilterInfo filterInfo = GetFilters(controllerContext, actionDescriptor);

                try
                {
                    AuthenticationContext authenticationContext = InvokeAuthenticationFilters(controllerContext, filterInfo.AuthenticationFilters, actionDescriptor);

                    if (authenticationContext.Result != null)
                    {
                        // An authentication filter signaled that we should short-circuit the request. Let all
                        // authentication filters contribute to an action result (to combine authentication
                        // challenges). Then, run this action result.
                        AuthenticationChallengeContext challengeContext = InvokeAuthenticationFiltersChallenge(
                            controllerContext, filterInfo.AuthenticationFilters, actionDescriptor,
                            authenticationContext.Result);
                        InvokeActionResult(controllerContext, challengeContext.Result ?? authenticationContext.Result);
                    }
                    else
                    {
                        AuthorizationContext authorizationContext = InvokeAuthorizationFilters(controllerContext, filterInfo.AuthorizationFilters, actionDescriptor);
                        if (authorizationContext.Result != null)
                        {
                            // An authorization filter signaled that we should short-circuit the request. Let all
                            // authentication filters contribute to an action result (to combine authentication
                            // challenges). Then, run this action result.
                            AuthenticationChallengeContext challengeContext = InvokeAuthenticationFiltersChallenge(
                                controllerContext, filterInfo.AuthenticationFilters, actionDescriptor,
                                authorizationContext.Result);
                            InvokeActionResult(controllerContext, challengeContext.Result ?? authorizationContext.Result);
                        }
                        else
                        {
                            if (controllerContext.Controller.ValidateRequest)
                            {
                                ValidateRequest(controllerContext);
                            }

                            IDictionary <string, object> parameters        = GetParameterValues(controllerContext, actionDescriptor);
                            ActionExecutedContext        postActionContext = InvokeActionMethodWithFilters(controllerContext, filterInfo.ActionFilters, actionDescriptor, parameters);

                            // The action succeeded. Let all authentication filters contribute to an action result (to
                            // combine authentication challenges; some authentication filters need to do negotiation
                            // even on a successful result). Then, run this action result.
                            AuthenticationChallengeContext challengeContext = InvokeAuthenticationFiltersChallenge(
                                controllerContext, filterInfo.AuthenticationFilters, actionDescriptor,
                                postActionContext.Result);
                            InvokeActionResultWithFilters(controllerContext, filterInfo.ResultFilters,
                                                          challengeContext.Result ?? postActionContext.Result);
                        }
                    }
                }
                catch (ThreadAbortException)
                {
                    // This type of exception occurs as a result of Response.Redirect(), but we special-case so that
                    // the filters don't see this as an error.
                    throw;
                }
                catch (Exception ex)
                {
                    // something blew up, so execute the exception filters
                    ExceptionContext exceptionContext = InvokeExceptionFilters(controllerContext, filterInfo.ExceptionFilters, ex);
                    if (!exceptionContext.ExceptionHandled)
                    {
                        throw;
                    }
                    InvokeActionResult(controllerContext, exceptionContext.Result);
                }

                return(true);
            }

            // notify controller that no method matched
            return(false);
        }
Ejemplo n.º 18
0
 protected override void OnAuthenticationChallenge(AuthenticationChallengeContext filterContext)
 {
     log.Info("OnAuthenticationChallenge 在身份认证质询时调用");
     base.OnAuthenticationChallenge(filterContext);
 }
Ejemplo n.º 19
0
 protected virtual void OnAuthenticationChallenge(AuthenticationChallengeContext filterContext)
 {
 }
 public void OnAuthenticationChallenge(AuthenticationChallengeContext filterContext)
 {
     filterContext.Result = new BasicChallengeActionResult {
         CurrentResult = filterContext.Result
     };
 }
Ejemplo n.º 21
0
 public void OnAuthenticationChallenge(AuthenticationChallengeContext filterContext)
 {
     Trace.TraceInformation("[MvcTracerFilter]:[OnAuthenticationChallenge]: {0}", filterContext.Controller);
 }
 public void OnAuthenticationChallenge(AuthenticationChallengeContext filterContext)
 {
     Write("OnAuthenticationChallenge");
 }
Ejemplo n.º 23
0
 public void OnAuthenticationChallenge(AuthenticationChallengeContext filterContext)
 {
     throw new NotImplementedException();
 }
 public void OnAuthenticationChallenge(AuthenticationChallengeContext filterContext)
 {
     //filterContext.Result = new RedirectResult("http://www.stackoverflow.com");
 }
Ejemplo n.º 25
0
 public void OnAuthenticationChallenge(AuthenticationChallengeContext filterContext)
 {
     //Check Session is Empty Then set as Result is HttpUnauthorizedResult
 }
Ejemplo n.º 26
0
 public void OnAuthenticationChallenge(AuthenticationChallengeContext filterContext)
 {
     // This is not needed, we can just skip it
 }
Ejemplo n.º 27
0
 protected override void OnAuthenticationChallenge(AuthenticationChallengeContext filterContext)
 {
     base.OnAuthenticationChallenge(filterContext);
 }
Ejemplo n.º 28
0
 /// <summary>
 /// The on authentication challenge.
 /// </summary>
 /// <param name="filterContext">
 /// The filter context.
 /// </param>
 public void OnAuthenticationChallenge(AuthenticationChallengeContext filterContext)
 {
     // Not applicable for Orion Federation
     return;
 }
Ejemplo n.º 29
0
 public void OnAuthenticationChallenge(AuthenticationChallengeContext filterContext)
 {
 }
 public void OnAuthenticationChallenge(AuthenticationChallengeContext filterContext)
 {
     Debug.WriteLine("Direct route access attempted");
 }