示例#1
0
        public virtual bool IsAuthenticationRequested(HttpHost host, HttpResponse response
                                                      , AuthenticationStrategy authStrategy, AuthState authState, HttpContext context)
        {
            if (authStrategy.IsAuthenticationRequested(host, response, context))
            {
                this.log.Debug("Authentication required");
                if (authState.GetState() == AuthProtocolState.Success)
                {
                    authStrategy.AuthFailed(host, authState.GetAuthScheme(), context);
                }
                return(true);
            }
            else
            {
                switch (authState.GetState())
                {
                case AuthProtocolState.Challenged:
                case AuthProtocolState.Handshake:
                {
                    this.log.Debug("Authentication succeeded");
                    authState.SetState(AuthProtocolState.Success);
                    authStrategy.AuthSucceeded(host, authState.GetAuthScheme(), context);
                    break;
                }

                case AuthProtocolState.Success:
                {
                    break;
                }

                default:
                {
                    authState.SetState(AuthProtocolState.Unchallenged);
                    break;
                }
                }
                return(false);
            }
        }