Beispiel #1
0
 public void OnAuthenticationChallenge(AuthenticationChallengeContext filterContext)
 {
     filterContext.HttpContext.Response.Write("<p>AuthenticationFilter - OnAuthenticationChallenge</p>");
 }
Beispiel #2
0
 public void OnAuthenticationChallenge(AuthenticationChallengeContext filterContext)
 {
     this._wrappedFilter.OnAuthenticationChallenge(filterContext);
 }
Beispiel #3
0
 public void OnAuthenticationChallenge(AuthenticationChallengeContext filterContext)
 {
     LogManager.AuthenticationLog("On AuthenticationChallenge", filterContext.Result.ToString());
 }
 public void OnAuthenticationChallenge(AuthenticationChallengeContext filterContext)
 {
     //这个方法是在Action执行之后调用
 }
 public abstract void OnAuthenticationChallenge(AuthenticationChallengeContext filterContext);
 public void OnAuthenticationChallenge(AuthenticationChallengeContext context)
 {
     context.Result = new AddOAuthChallengeResult(context.Result, Realm);
 }
 void IAuthenticationFilter.OnAuthenticationChallenge(AuthenticationChallengeContext filterContext)
 {
     OnAuthenticationChallenge(filterContext);
 }
Beispiel #8
0
 public void OnAuthenticationChallenge(AuthenticationChallengeContext filterContext)
 {
     Console.WriteLine("OnAuthenticationChallenge");
 }
Beispiel #9
0
 protected override void OnAuthenticationChallenge(AuthenticationChallengeContext filterContext)
 {
     //custom authentication challenge logic
 }
Beispiel #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
 }
Beispiel #15
0
 public void OnAuthenticationChallenge(AuthenticationChallengeContext filterContext)
 {
     // Impletation for this isn't require
 }
Beispiel #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));
            }
        }
Beispiel #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);
        }
 protected override void OnAuthenticationChallenge(AuthenticationChallengeContext filterContext)
 {
     log.Info("OnAuthenticationChallenge 在身份认证质询时调用");
     base.OnAuthenticationChallenge(filterContext);
 }
 protected virtual void OnAuthenticationChallenge(AuthenticationChallengeContext filterContext)
 {
 }
 public void OnAuthenticationChallenge(AuthenticationChallengeContext filterContext)
 {
     filterContext.Result = new BasicChallengeActionResult {
         CurrentResult = filterContext.Result
     };
 }
 public void OnAuthenticationChallenge(AuthenticationChallengeContext filterContext)
 {
     Trace.TraceInformation("[MvcTracerFilter]:[OnAuthenticationChallenge]: {0}", filterContext.Controller);
 }
 public void OnAuthenticationChallenge(AuthenticationChallengeContext filterContext)
 {
     Write("OnAuthenticationChallenge");
 }
Beispiel #23
0
 public void OnAuthenticationChallenge(AuthenticationChallengeContext filterContext)
 {
     throw new NotImplementedException();
 }
 public void OnAuthenticationChallenge(AuthenticationChallengeContext filterContext)
 {
     //filterContext.Result = new RedirectResult("http://www.stackoverflow.com");
 }
Beispiel #25
0
 public void OnAuthenticationChallenge(AuthenticationChallengeContext filterContext)
 {
     //Check Session is Empty Then set as Result is HttpUnauthorizedResult
 }
Beispiel #26
0
 public void OnAuthenticationChallenge(AuthenticationChallengeContext filterContext)
 {
     // This is not needed, we can just skip it
 }
Beispiel #27
0
 protected override void OnAuthenticationChallenge(AuthenticationChallengeContext filterContext)
 {
     base.OnAuthenticationChallenge(filterContext);
 }
 /// <summary>
 /// The on authentication challenge.
 /// </summary>
 /// <param name="filterContext">
 /// The filter context.
 /// </param>
 public void OnAuthenticationChallenge(AuthenticationChallengeContext filterContext)
 {
     // Not applicable for Orion Federation
     return;
 }
Beispiel #29
0
 public void OnAuthenticationChallenge(AuthenticationChallengeContext filterContext)
 {
 }
 public void OnAuthenticationChallenge(AuthenticationChallengeContext filterContext)
 {
     Debug.WriteLine("Direct route access attempted");
 }