예제 #1
0
        /// <summary>
        /// Gets the credentials for the specified requests using the credential provider
        /// </summary>
        /// <param name="reqInfo"></param>
        /// <param name="isProxy"></param>
        /// <returns></returns>
        public HttpAuthenticationInfo GetCredentials(HttpRequestInfo reqInfo, bool isProxy)
        {
            HttpAuthenticationInfo authInfo = null;
            string domain, userName, password;

            if (_credentialsProvider != null && _credentialsProvider.Execute(out domain, out userName, out password))
            {
                //encrypt
                string encryptedPassword = Encryptor.EncryptToString(password);

                authInfo = new HttpAuthenticationInfo(new NetworkCredential(userName, encryptedPassword, domain), isProxy);
                //store the auth info in the cache
                this.Add(reqInfo.HostAndPort.GetHashCode(), new CacheEntry((ICloneable)authInfo.Clone()));
            }
            return(authInfo);
        }