Retrive GPX files from the server using signed urls. This allows downloading of priva...
authorAndy Allan <gravitystorm@gmail.com>
Mon, 11 Oct 2010 17:04:10 +0000 (17:04 +0000)
committerAndy Allan <gravitystorm@gmail.com>
Mon, 11 Oct 2010 17:04:10 +0000 (17:04 +0000)
Currently implemented in a hacky way, so this needs reworking.

net/systemeD/halcyon/connection/Connection.as
net/systemeD/halcyon/connection/XMLConnection.as
net/systemeD/potlatch2/utils/Importer.as

index 7c9b1a8..73e3982 100755 (executable)
@@ -360,6 +360,7 @@ package net.systemeD.halcyon.connection {
                public function closeChangeset():void {}
            public function uploadChanges():void {}
         public function fetchUserTraces():void {}
+        public function signOAuthGet(url:String):String {return 'example.com';}
     }
 
 }
index da8cad6..a7cbde5 100644 (file)
@@ -139,6 +139,13 @@ package net.systemeD.halcyon.connection {
             loader.addEventListener(HTTPStatusEvent.HTTP_STATUS, onStatus);
             loader.load(urlReq);
         }
+
+        override public function signOAuthGet(url:String):String {
+            var sig:IOAuthSignatureMethod = new OAuthSignatureMethod_HMAC_SHA1();
+            var oauthRequest:OAuthRequest = new OAuthRequest("GET", url, null, appID, authToken);
+            var urlStr:Object = oauthRequest.buildRequest(sig, OAuthRequest.RESULT_TYPE_URL_STRING);
+            return String(urlStr);
+        }
         
         override public function uploadChanges():void {
             var changeset:Changeset = getActiveChangeset();
index 8c5d858..80b654c 100644 (file)
@@ -3,6 +3,7 @@ package net.systemeD.potlatch2.utils {
        import net.systemeD.halcyon.MapPaint;
        import net.systemeD.halcyon.ExtendedURLLoader;
        import net.systemeD.halcyon.DebugURLRequest;
+    import net.systemeD.halcyon.connection.*;
        import flash.net.URLLoader;
        import flash.display.LoaderInfo;
        import flash.events.*;
@@ -35,6 +36,9 @@ package net.systemeD.potlatch2.utils {
                        for each (var fn:String in filenames) {
                                Globals.vars.root.addDebug("requesting file "+fn); 
 
+                if ( true ) {
+                  fn = Connection.getConnectionInstance().signOAuthGet(fn);
+                }
                                var request:DebugURLRequest = new DebugURLRequest(fn);
                                var loader:ExtendedURLLoader = new ExtendedURLLoader();
                                loader.info['file']=sp;