Select to view content in your preferred language

@Robert's 2009 post token security

1526
13
08-18-2011 06:16 AM
SaugatJoshi
Deactivated User
Hi Robert,

Is there a way I can change this to flex viewer 2.3.1. I am looking for something like you mentioned in your post http://forums.esri.com/Thread.asp?c=158&f=2421&t=280353

What I have done ..
1.Removed token tag from config.xml completely.
2. Received token from the Arcgis server in init() function of Mapmanager.mxml using httpservice.
3. Used it in the case "dynamic": of mapmanager.mxml as dynlayer.token=received token.
4.On these steps I cannot see the mapservice in the first place. When I refresh, I see the service working (through Fiddler), also in TOC, but cannot see the map. Again does not work for any other browser than IE.

I saw your post in 2009 relating similar issue.Below is your suggestion.How can I translate this to flex viewer 2.3.1

//In the Config.xml for each secured map service add
token="x"

//In the ConfigManager.as look for the
    //================================================ 
    //map
//section and add
     var msToken:String = mapserviceList.@token;
//right above 'var msLabel:String = mapserviceList.@label;'
//then replace
     var mapservice:Object = 
     {
      label: msLabel,
      type: msType,
      visible: msVisible,
      alpha: msAlpha,
      url: msURL
     }
//with
     var mapservice:Object = 
     {
      label: msLabel,
      type: msType,
      visible: msVisible,
      alpha: msAlpha,
      url: msURL,
      token: msToken
     }

//Now in MapManger look for 'for (i = 0; i < configData.configMap.length; i++)'
//and add
           var token:String = configData.configMap.token;
//to the list of vars

//Then look for case "tiled": and add 

       if(token)
        tiledlayer.token = token;
//before 'map.addLayer(tiledlayer);'

//Then look for case "dynamic": and add 

       if(token)
        dynlayer.token = token;
//before 'map.addLayer(dynlayer);'
//That should do it.


Really appreciate your feedback.

Thank you.
Tags (2)
0 Kudos
13 Replies
SaugatJoshi
Deactivated User
Robert, following the same problem I had...I  managed it by dispatching the event only after I receive the req. info and then loading the configload() function. So, inside the result handler I have

ViewerContainer.dispatchEvent( new AppEvent("secTokenReceived",data) );
   loadConfig();


Then in the init() of mapmanger.mxml I have

ViewerContainer.addEventListener("secTokenReceived", secTokenHandler);


The token can now be seen in the switch statement.

Now, I want to receive the same information in your identify widget (Version 2.2.3f - Mar. 29, 2011) so in the init() of Identify Widget  I added

drawTool.addEventListener("secTokenReceived", resultHandler);


and in the result handler
private function resultHandler(event:AppEvent):void
   {
    secToken = event.data.secToken;
    Alert.show(secToken);   
   }


However, I do not see anything in the alert.The event is already dispatched in configmanager.as.  What am I missing here? To summarize I have the secToken in configManager.as(from where I dispatch the event) and I want the token in the IdentifyWidget. How can I achieve this?

Thank you.
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Saugat,

   Just create a public var in the mapManager that you can get using ViewerContainer.getInstance().mapManager.yourpublicvar.

Also why are you adding the listener to the drawTool???
drawTool.addEventListener("secTokenReceived", resultHandler);


it should be to the ViewerContainer.
0 Kudos
SaugatJoshi
Deactivated User
Robert,

Thank you for the solution. However, I have a small question...since  you use
ViewerContainer.getInstance().mapManager.yourpublicvar


is 
viewerContainer.addEventListener("secTokenReceived", resultHandler)

even required in the init() function.

Thanks.
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Saugat,

   No, I just wanted to point out that you were adding the listener to the wrong object.
0 Kudos