dont save the gid in sign_gid()
[sfa.git] / sfa / server / sfa-ca.py
index f760464..127a267 100755 (executable)
@@ -65,7 +65,6 @@ def sign_gid(gid, parent_key, parent_gid):
     gid.set_issuer(parent_key, parent_gid.get_hrn())
     gid.set_parent(parent_gid)
     gid.sign()
-    gid.save_to_file(outfile, save_parents=True)
     return gid 
 
 def sign(options):
@@ -75,7 +74,7 @@ def sign(options):
     hierarchy = Hierarchy()
     config = Config()
     default_authority = config.SFA_INTERFACE_HRN
-    auth_info = hierarchy.get_auth_info(parent_hrn)
+    auth_info = hierarchy.get_auth_info(default_authority)
 
     # load the gid
     gidfile = os.path.abspath(options.sign)
@@ -107,7 +106,9 @@ def sign(options):
     # check if gid already has a parent
  
     # sign the gid
-    sign_gid(gid, parent_key, parent_gid)
+    gid = sign_gid(gid, parent_key, parent_gid)
+    # save the signed gid
+    gid.save_to_file(outfile, save_parents=True)
     
 
 def export_gid(options):
@@ -181,7 +182,7 @@ def import_gid(options):
     record_dict = defaultdict(list)
     # only get regords that belong to this authority 
     # or any of its sub authorities   
-    all_records = table.find({'hrn': '%s*' % gid.get_hrn()])
+    all_records = table.find({'hrn': '%s*' % gid.get_hrn()})
     for record in records:
         record_dict[record['authority']].append(record) 
 
@@ -209,7 +210,7 @@ def import_gid(options):
 
              # update list of next authorities
             tmp_authorities = set([record['hrn'] for record in records \
-                                   if record['type'] == 'authority']))
+                                   if record['type'] == 'authority'])
             next_authorities.extend(tmp_authorities)
 
         # move on to next set of authorities