I don't yet have an ssl certificate, although I am planning to get that part taken care of soon. I have used the suggested methods above and at one point "I swear" it was working. Now that I have programed the rest of my site it has quit working. I am at Server 10.1. If I send:http.url="http://xyz/arcgis/tokens/arcgis/tokens?request=gettoken&username="+username+"&password="+password;I get a valid token. If I add clientid or expiration to this url, I get invalid tokens. Am I getting invalid tokens b/c I don't yet have the certificate set up? or are the issues with my security settings on the service or server side? or by any chance is this just how it works at 10.1? Also, can anyone tell me if I set up the SSL will it affect my nonsecure services. Or in otherwords, once I get the SSL certificate running is it going to shut down my sites that are not using tokens. Might seem like a silly question, but I've made assumptions before and I am fumbling through this security stuff. Thanks in advance!!
Hi Carmen, thanks for your suggestion. I've tried with your crossdomain.xml idea but with this code nothing works... I use flash 10 with flex 3.5. I think the problem is in the api, because the generated token works properly if I insert it in the mxml tag and in actionscript normally after it generation (in 2nd time) but if I generate the token on the fly and I add the new token generated return token is invalid (viewed with firebugs). Others idea?? Thank you 4 all
<?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:esri="http://www.esri.com/2008/ags" pageTitle="Example - ArcGIS API for Flex connecting to a dynamic secured AGS service" initialize="init()"> <mx:Script> <![CDATA[ import mx.utils.StringUtil; import flash.utils.setTimeout; import mx.binding.utils.BindingUtils; import mx.rpc.http.HTTPService; import mx.controls.Alert; import mx.rpc.events.ResultEvent; import mx.rpc.events.FaultEvent; import com.esri.ags.layers.ArcGISDynamicMapServiceLayer; private var theToken:String; private function init():void { var unsecuredBaseMap:ArcGISDynamicMapServiceLayer = new ArcGISDynamicMapServiceLayer("http://******/arcgis/rest/services/*****/MapServer"); map.addLayer(unsecuredBaseMap); RequestToken('ldapUser','ldapPassword'); } public function RequestToken(username:String, password:String):void { var http:HTTPService = new HTTPService(); // register event handlers (resultHandler and faultHandler functions) http.addEventListener( ResultEvent.RESULT, tokenResultHandler ); http.addEventListener( FaultEvent.FAULT, faultHandler ); http.url = "http://******/arcgis/tokens?request=gettoken&username="+ username +"&password="+ password +"&clientid=ref.http://******.ti.ch&expiration=1440"; http.method = "GET"; http.resultFormat = "text"; http.send(); function faultHandler(event:FaultEvent):void { Alert.show(event.fault.toString()); } function tokenResultHandler(event:ResultEvent):void { theToken = StringUtil.trim(event.result.toString()); caricaLayerProtetti(); } } private function caricaLayerProtetti():void { var protectedMap1:ArcGISDynamicMapServiceLayer = new ArcGISDynamicMapServiceLayer("http://******/arcgis/rest/services/*****/MapServer"); protectedMap1.token = theToken; map.addLayer(protectedMap1); var protectedMap2:ArcGISDynamicMapServiceLayer = new ArcGISDynamicMapServiceLayer("http://******/arcgis/rest/services/*****/MapServer"); protectedMap2.token = theToken; map.addLayer(protectedMap2); } ]]> </mx:Script> <mx:Label text="Java" fontSize="14"/> <esri:Map id="map" /> </mx:Application>
Signed in members can post, follow updates, and more. New here? Register a free account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.