Fixed: Registration & My Account, Generate new keys with a valid RSA format - http...
authorLoic Baron <loic.baron@lip6.fr>
Thu, 17 Oct 2013 15:36:47 +0000 (17:36 +0200)
committerLoic Baron <loic.baron@lip6.fr>
Thu, 17 Oct 2013 15:36:47 +0000 (17:36 +0200)
plugins/googlemap/static/js/googlemap.js
portal/accountview.py
portal/registrationview.py
portal/resourceview.py

index 8cb652f..424b3aa 100644 (file)
@@ -154,7 +154,7 @@ googlemap_debug_detailed=false;
 
        // this record is *in* the slice
         new_record: function(record) {
-           if (googlemap_debug_detailed) messages.debug ("new_record");
+               if (googlemap_debug_detailed) messages.debug ("new_record");
             if (!(record['latitude'])) return false;
            
             // get the coordinates
@@ -162,33 +162,33 @@ googlemap_debug_detailed=false;
             var longitude=unfold.get_value(record['longitude']);
             var lat_lon = latitude + longitude;
 
-           // check if we've seen anything at that place already
-           // xxx might make sense to allow for some fuzziness, 
-           // i.e. consider 2 places equal if not further away than 300m or so...
-           var marker_s = this.by_lat_lon [lat_lon];
-           if ( marker_s == null ) {
-               marker_s = this.create_marker_struct (this.object, latitude, longitude);
-               this.by_lat_lon [ lat_lon ] = marker_s;
-               this.arm_marker(marker_s.marker, this.map);
-           }
+           // check if we've seen anything at that place already
+           // xxx might make sense to allow for some fuzziness, 
+           // i.e. consider 2 places equal if not further away than 300m or so...
+           var marker_s = this.by_lat_lon [lat_lon];
+           if ( marker_s == null ) {
+                       marker_s = this.create_marker_struct (this.object, latitude, longitude);
+                       this.by_lat_lon [ lat_lon ] = marker_s;
+                       this.arm_marker(marker_s.marker, this.map);
+               }
            
-           // now add a line for this resource in the marker
-           // xxx should compute checked here ?
-           // this is where the checkbox will be appended
-           var ul=marker_s.ul;
-           var checkbox = this.create_record_checkbox (record, ul, false);
-           if ( ! this.key in record ) return;
+           // now add a line for this resource in the marker
+           // xxx should compute checked here ?
+           // this is where the checkbox will be appended
+           var ul=marker_s.ul;
+           var checkbox = this.create_record_checkbox (record, ul, false);
+           if ( ! this.key in record ) return;
             var key_value = record[this.key];
-           // see XXX BACKSLASHES 
-           //var hrn = this.escape_id(key_value).replace(/\\/g, '');
-           var hrn = key_value;
+           // see XXX BACKSLASHES 
+           //var hrn = this.escape_id(key_value).replace(/\\/g, '');
+           var hrn = key_value;
             this.by_hrn[hrn] = {
-               checkbox: checkbox,
-               // xxx Thierry sept 2013
-               // xxx actually we might have just used a domid-based scheme instead of the hash
-               // since at this point we only need to retrieve the checkbox from an hrn
-               // but I was not sure enough that extra needs would not show up so I kept this in place
-               // xxx not sure these are actually useful :
+                   checkbox: checkbox,
+                       // xxx Thierry sept 2013
+                       // xxx actually we might have just used a domid-based scheme instead of the hash
+                       // since at this point we only need to retrieve the checkbox from an hrn
+                       // but I was not sure enough that extra needs would not show up so I kept this in place
+                       // xxx not sure these are actually useful :
                 value: key_value,
                 record: record,
             }
index d97126f..d4b68f4 100644 (file)
@@ -142,19 +142,26 @@ def account_process(request):
         messages.success(request, 'Sucess: Password Updated.')
         return HttpResponseRedirect("/portal/account/")
 
+# XXX TODO: Factorize with portal/registrationview.py
+
     elif 'generate' in request.POST:
         for account_detail in account_details:
             for platform_detail in platform_details:
                 if platform_detail['platform_id'] == account_detail['platform_id']:
                     if 'myslice' in platform_detail['platform']:
+                        from Crypto.PublicKey import RSA
+                        private = RSA.generate(1024)
+                        private_key = json.dumps(private.exportKey())
+                        public  = private.publickey()
+                        public_key = json.dumps(public.exportKey(format='OpenSSH'))
                         # Generate public and private keys using SFA Library
-                        from sfa.trust.certificate  import Keypair
-                        k = Keypair(create=True)
-                        public_key = k.get_pubkey_string()
-                        private_key = k.as_pem()
-                        private_key = ''.join(private_key.split())
-                        public_key = "ssh-rsa " + public_key
-                        keypair = '{"user_public_key":"'+ public_key + '", "user_private_key":"'+ private_key + '"}'
+#                        from sfa.trust.certificate  import Keypair
+#                        k = Keypair(create=True)
+#                        public_key = k.get_pubkey_string()
+#                        private_key = k.as_pem()
+#                        private_key = ''.join(private_key.split())
+#                        public_key = "ssh-rsa " + public_key
+                        keypair = '{"user_public_key":'+ public_key + ', "user_private_key":'+ private_key + '}'
 #                       keypair = re.sub("\r", "", keypair)
 #                       keypair = re.sub("\n", "\\n", keypair)
 #                       #keypair = keypair.rstrip('\r\n')
index aefdaa7..1e0c4f9 100644 (file)
@@ -61,16 +61,24 @@ class RegistrationView (View):
             # XXX validate authority hrn !!
             if PendingUser.objects.filter(email__iexact=reg_email):
                 errors.append('Email already registered.Please provide a new email address.')
+
+# XXX TODO: Factorize with portal/accountview.py
             if 'generate' in request.POST['question']:
-                # Generate public and private keys using SFA Library
-                from sfa.trust.certificate  import Keypair
-                k = Keypair(create=True)
-                public_key = k.get_pubkey_string()
-                private_key = k.as_pem()
-                private_key = ''.join(private_key.split())
-                public_key = "ssh-rsa " + public_key
+                from Crypto.PublicKey import RSA
+                private = RSA.generate(1024)
+                private_key = json.dumps(private.exportKey())
+                public  = private.publickey()
+                public_key = json.dumps(public.exportKey(format='OpenSSH'))
+
+#                # Generate public and private keys using SFA Library
+#                from sfa.trust.certificate  import Keypair
+#                k = Keypair(create=True)
+#                public_key = k.get_pubkey_string()
+#                private_key = k.as_pem()
+#                private_key = ''.join(private_key.split())
+#                public_key = "ssh-rsa " + public_key
                 # Saving to DB
-                keypair = '{"user_public_key":"'+ public_key + '", "user_private_key":"'+ private_key + '"}'
+                keypair = '{"user_public_key":'+ public_key + ', "user_private_key":'+ private_key + '}'
                 #keypair = re.sub("\r", "", keypair)
                 #keypair = re.sub("\n", "\\n", keypair)
                 #keypair = keypair.rstrip('\r\n')
index 1923670..65b369a 100644 (file)
@@ -47,7 +47,7 @@ class ResourceView(TemplateView):
             title      = 'Geographic view',
             domid      = 'resources-map',
             # tab's sons preferably turn this off
-            togglable  = False,
+            togglable  = True,
             query      = resource_query,
             query_all  = resource_query,
             checkboxes = False,