Page 1 of 1

xServer.NET To xServer 2 Http Authentification

Posted: Mon Mar 18, 2024 10:46 am
by steiner
Hello PTV Team,

we want to change our Setting xserver 1 + Ajaxmaps-control to xserver 2.31 + xserver.net and i have problems with the http authentification.

The clientsoftware is in c#.net framework 4.8 + xServer.net 1.7.10 + FormsMapCS

I get the map to work without the users.properties in <xserver-install-dir>\conf with the address MainMap.XMapUrl = "http://<myip>:50000/services/";

When i produce the users.properties with <myuser>=<mypassword> and the settings

MainMap.XMapUrl = "http://<myip>10.0.0.73:50000/services/";
MainMap.XMapCredentials = "<myuser>:<mypassword>";

i get following errors in the log-files:

2024-03-18 10:50:16,437;WARN;com.ptvgroup.xserver.runtime.cxf.ServicesLoader;Rejected request to /xmap/ws/XMap because it is invalid!
2024-03-18 10:50:16,888;WARN;com.ptvgroup.xserver.runtime.cxf.PTVServlet;Unauthorized access with user 'unknown' and password 'null' detected.
2024-03-18 10:50:16,901;WARN;com.ptvgroup.xserver.runtime.cxf.PTVServlet;Unauthorized access with user 'xtok' and password '<mypassword>' detected.

It seems the ServicesLoader means, its not a xServer2 (xmap instead of xservices in the path). But it does not make a different, when i add ;version=2.31 to the XMapUrl.

Can you help me?

Jürgen Winklhofer

Re: xServer.NET To xServer 2 Http Authentification

Posted: Mon Mar 18, 2024 12:50 pm
by Oliver Heilig
Hello Jürgen,

looks like the XMapCredentials only works with xsi token authentication and not with generic basic auth for xMap-2. What should work is setting the basic auth header using the ModifyRequest delegate;

Code: Select all

            formsMap.XMapUrl = "http://xserver-2:50000/";
            LayerFactory.ModifyRequest = request =>
            {
                request.Headers["Authorization"] = "Basic "
                    + Convert.ToBase64String(Encoding.UTF8.GetBytes("myUser:myPassword"));
                return request;
            };
Hope that helps
Oli

Re: xServer.NET To xServer 2 Http Authentification

Posted: Mon Mar 18, 2024 1:33 pm
by steiner
Hello Oliver,

now it works. Thanks a lot.

greetings
Jürgen