Setting up HttpRequestConfiguration to ArcGIS Android SDK for security

3411
1
01-06-2016 01:54 AM
SalihYalcin
New Contributor III

Hello everyone,

I am developing an app that uses some features of esri android sdk, I know there is some ways to provide security to my esri services (eg. user credentials , token etc.) So my question is another way to provide security.

Esri Android SDK has HttpRequestHandler to access to some features of HTTP requests.

HttpRequestHandler |  ArcGIS Android 10.2.7 API

In order to provide security I defined ArcGIS Server Link like below (Some places of link has been changed by me);

ArcGISTiledMapServiceLayer BaseMap = new ArcGISTiledMapServiceLayer("http://gisproxy.company.gov.tr/proxy.ashx?http://gis.company.gov.tr/arcgis/rest/services/CityGuide/M... );

Actually I have to send Header to HttpRequest for access my features and services. I could afford the write this functionality for code side but it didn't worked.

HttpRequestHandler mHttpRequest = HttpRequestHandler.getInstance();

mHttpRequest.setHttpRequestListener(new HttpRequestListener() {
   @Override
   public void onRequestInterception(org.apache.http.HttpRequest httpRequest, org.apache.http.protocol.HttpContext httpContext) {

  httpRequest.addHeader("HTTP_REFERER", "Android SH");
  Header[] mheader = httpRequest.getAllHeaders();
   for (Header item : mheader) {
  Log.d("RequestHeader", "Headers-----" + item);
  }
  Log.d("Contex", "RequestContext----" + httpContext);

  }
});

So How could I solve this issue ? How canI send header parameter to http request  ?   Or stuff that I trying is not supported for this usage.

Dan O'Neill

Will Crick

1 Reply
WillCrick
Occasional Contributor

I assume you are trying to use the ArcGIS Proxy Service using a self hosted proxy service?

Working with Proxy Services | ArcGIS for Developers

If so, this is currently not supported in the 10.2.x Android SDK.

However you may be able to do one of the following: 

1. Change the self hosted proxy service on the server to accept a valid HTTP query parameter for the URL to the actual resource you want to access. Currently the default just appends the URL of the service on to the end of the URL of the proxy without a parameter name (e.g. its http://proxyurl.com?http://serviceurl.com rather than something like http://proxyurl.com/?url=http://serviceurl.com - note the addition of the "url=" in the second url).

2. Add the proxy service URL in the same format as the proxy page requires to each request to the resource in the onRequestInterception() method of the HttpRequestListener. This gets fired for every http request, you can check what the outgoing URL is to see if its the resource you are interested in, and then modify the request as required.