public virtual Credentials GetCredentials(AuthScope authscope)
        {
            Args.NotNull(authscope, "Auth scope");
            Credentials localcreds = @internal.GetCredentials(authscope);

            if (localcreds != null)
            {
                return(localcreds);
            }
            if (authscope.GetHost() != null)
            {
                PasswordAuthentication systemcreds = GetSystemCreds(authscope, Authenticator.RequestorType
                                                                    .Server);
                if (systemcreds == null)
                {
                    systemcreds = GetSystemCreds(authscope, Authenticator.RequestorType.Proxy);
                }
                if (systemcreds != null)
                {
                    return(new UsernamePasswordCredentials(systemcreds.GetUserName(), new string(systemcreds
                                                                                                 .GetPassword())));
                }
            }
            return(null);
        }
 private static PasswordAuthentication GetSystemCreds(AuthScope authscope, Authenticator.RequestorType
                                                      requestorType)
 {
     return(Authenticator.RequestPasswordAuthentication(authscope.GetHost(), null, authscope
                                                        .GetPort(), "http", null, TranslateScheme(authscope.GetScheme()), null, requestorType
                                                        ));
 }