Zum Hauptinhalt gehen

Connect to Secure WMS

Kommentare

1 Kommentar

  • Permanently deleted user

    Do you know ESRI's proxy page?   

    If you have someone with some programming expertise you'll have to modify the proxy page and config to include basic authentication in the headers.

     

     

     

    string authInfo = getAuthInfoFromConfigFile(uri);

     

            if (!String.IsNullOrEmpty(authInfo))

     

            {

     

                authInfo = Convert.ToBase64String(Encoding.Default.GetBytes(authInfo));    

     

                req.Headers["Authorization"] = "Basic " + authInfo;

     

            }

    private string getAuthInfoFromConfigFile(string uri)

     

        {

     

            try

     

            {

     

                ProxyConfig config = ProxyConfig.GetCurrentConfig();

     

                if (config != null)

     

                {

     

                    string username = config.GetUsername(uri);

     

                    if(!String.IsNullOrEmpty(username))

     

                    {

     

                        string password=config.GetPassword(uri);

     

                        return username + ":" + password;

     

                    }

     

                    else 

     

                        return string.Empty;

     

                }

     

                else

     

                    throw new ApplicationException(

     

                        "Proxy.config file does not exist at application root, or is not readable.");

     

            }

     

            catch (InvalidOperationException)

     

            {

     

                // Proxy is being used for an unsupported service (proxy.config has mustMatch="true")

     

                HttpResponse response = HttpContext.Current.Response;

     

                response.StatusCode = (int)System.Net.HttpStatusCode.Forbidden;

     

                response.End();

     

            }

     

            catch (Exception e)

     

            {

     

                if (e is ApplicationException)

     

                    throw e;

     

                

     

                // just return an empty string at this point

     

                // -- may want to throw an exception, or add to a log file

     

            }

     

            

     

            return string.Empty;

     

        }

     

     
    0

Bitte melden Sie sich an, um einen Kommentar zu hinterlassen.