Пример #1
0
        public Authorization Authenticate(string challenge, WebRequest webRequest, ICredentials credentials)
        {
            if (authObject == null)
            {
                return(null);
            }

            return(authObject.Authenticate(challenge, webRequest, credentials));
        }
        /// <include file='doc\AuthenticationManager.uex' path='docs/doc[@for="AuthenticationManager.Authenticate"]/*' />
        /// <devdoc>
        ///    <para>Call each registered authentication module to determine the first module that
        ///       can respond to the authentication request.</para>
        /// </devdoc>
        public static Authorization Authenticate(string challenge, WebRequest request, ICredentials credentials)
        {
            //
            // parameter validation
            //
            if (request == null)
            {
                throw new ArgumentNullException("request");
            }
            if (credentials == null)
            {
                throw new ArgumentNullException("credentials");
            }
            if (challenge == null)
            {
                throw new ArgumentNullException("challenge");
            }

            GlobalLog.Print("AuthenticationManager::Authenticate() challenge:[" + challenge + "]");

            Authorization response = null;

            lock (typeof(AuthenticationManager)) {
                //
                // fastest way of iterating on the ArryList
                //
                for (int i = 0; i < ModuleList.Count; i++)
                {
                    IAuthenticationModule authenticationModule = (IAuthenticationModule)ModuleList[i];
                    //
                    // the AuthenticationModule will
                    // 1) return a valid string on success
                    // 2) return null if it knows it cannot respond
                    // 3) throw if it could have responded but unexpectedly failed to do so
                    //

                    HttpWebRequest httpWebRequest = request as HttpWebRequest;
                    if (httpWebRequest != null)
                    {
                        httpWebRequest.CurrentAuthenticationState.Module = authenticationModule;
                    }
                    response = authenticationModule.Authenticate(challenge, request, credentials);

                    if (response != null)
                    {
                        //
                        // fond the Authentication Module, return it
                        //
                        response.Module = authenticationModule;
                        GlobalLog.Print("AuthenticationManager::Authenticate() found IAuthenticationModule:[" + authenticationModule.AuthenticationType + "]");
                        break;
                    }
                }
            }

            return(response);
        }
        private static Authorization DoAuthenticate(string challenge, WebRequest request, ICredentials credentials)
        {
            AuthenticationManager.EnsureModules();
            ArrayList obj = AuthenticationManager.modules;

            lock (obj)
            {
                foreach (object obj2 in AuthenticationManager.modules)
                {
                    IAuthenticationModule authenticationModule = (IAuthenticationModule)obj2;
                    Authorization         authorization        = authenticationModule.Authenticate(challenge, request, credentials);
                    if (authorization != null)
                    {
                        authorization.Module = authenticationModule;
                        return(authorization);
                    }
                }
            }
            return(null);
        }
        public static Authorization Authenticate(string challenge, WebRequest request, ICredentials credentials)
        {
            if (request == null)
            {
                throw new ArgumentNullException("request");
            }
            if (credentials == null)
            {
                throw new ArgumentNullException("credentials");
            }
            if (challenge == null)
            {
                throw new ArgumentNullException("challenge");
            }
            Authorization  authorization = null;
            HttpWebRequest request2      = request as HttpWebRequest;

            if ((request2 != null) && (request2.CurrentAuthenticationState.Module != null))
            {
                return(request2.CurrentAuthenticationState.Module.Authenticate(challenge, request, credentials));
            }
            lock (s_ModuleBinding)
            {
                for (int i = 0; i < ModuleList.Count; i++)
                {
                    IAuthenticationModule module = (IAuthenticationModule)ModuleList[i];
                    if (request2 != null)
                    {
                        request2.CurrentAuthenticationState.Module = module;
                    }
                    authorization = module.Authenticate(challenge, request, credentials);
                    if (authorization != null)
                    {
                        return(authorization);
                    }
                }
            }
            return(authorization);
        }
        /// <devdoc>
        ///    <para>Call each registered authentication module to determine the first module that
        ///       can respond to the authentication request.</para>
        /// </devdoc>
        public override Authorization Authenticate(string challenge, WebRequest request, ICredentials credentials)
        {
            if (request == null)
            {
                throw new ArgumentNullException("request");
            }
            if (credentials == null)
            {
                throw new ArgumentNullException("credentials");
            }
            if (challenge == null)
            {
                throw new ArgumentNullException("challenge");
            }

            GlobalLog.Print("AuthenticationManager::Authenticate() challenge:[" + challenge + "]");

            Authorization response = null;

            HttpWebRequest httpWebRequest = request as HttpWebRequest;

            if (httpWebRequest != null && httpWebRequest.CurrentAuthenticationState.Module != null)
            {
                response = httpWebRequest.CurrentAuthenticationState.Module.Authenticate(challenge, request, credentials);
            }
            else
            {
                // This is the case where we would try to find the module on the first server challenge
                lock (moduleBinding)
                {
                    //
                    // fastest way of iterating on the ArrayList
                    //
                    for (int i = 0; i < ModuleList.Count; i++)
                    {
                        IAuthenticationModule authenticationModule = (IAuthenticationModule)ModuleList[i];
                        //
                        // the AuthenticationModule will
                        // 1) return a valid string on success
                        // 2) return null if it knows it cannot respond
                        // 3) throw if it could have responded but unexpectedly failed to do so
                        //
                        if (httpWebRequest != null)
                        {
                            httpWebRequest.CurrentAuthenticationState.Module = authenticationModule;
                        }
                        response = authenticationModule.Authenticate(challenge, request, credentials);

                        if (response != null)
                        {
                            //
                            // found the Authentication Module, return it
                            //
                            GlobalLog.Print("AuthenticationManager::Authenticate() found IAuthenticationModule:[" + authenticationModule.AuthenticationType + "]");
                            break;
                        }
                    }
                }
            }

            return(response);
        }
Пример #6
0
 private ModuleResult InvokeAuthenticate(IAuthenticationModule arg1, IHttpContext arg2)
 {
     return arg1.Authenticate(arg2);
 }
 private ModuleResult InvokeAuthenticate(IAuthenticationModule arg1, IHttpContext arg2)
 {
     return(arg1.Authenticate(arg2));
 }
 public bool Authenticate(string email, string password)
 {
     return(_module.Authenticate(email, password));
 }