CA certs are only given to objects of type authority sfa-1.0-30
authorTony Mack <tmack@paris.CS.Princeton.EDU>
Mon, 15 Aug 2011 22:47:47 +0000 (18:47 -0400)
committerTony Mack <tmack@paris.CS.Princeton.EDU>
Mon, 15 Aug 2011 22:47:47 +0000 (18:47 -0400)
sfa/trust/hierarchy.py

index f28329c..89bebcc 100644 (file)
@@ -231,13 +231,19 @@ class Hierarchy:
 
     def create_gid(self, xrn, uuid, pkey):
         hrn, type = urn_to_hrn(xrn)
+        parent_hrn = get_authority(hrn)
         # Using hrn_to_urn() here to make sure the urn is in the right format
         # If xrn was a hrn instead of a urn, then the gid's urn will be
         # of type None 
         urn = hrn_to_urn(hrn, type)
         gid = GID(subject=hrn, uuid=uuid, hrn=hrn, urn=urn)
 
-        parent_hrn = get_authority(hrn)
+        # is this a CA cert
+        if hrn == self.config.SFA_INTERFACE_HRN or \
+           or not parent_hrn or 'authority' in type:
+            gid.set_intermediate_ca(True)
+
+        # set issuer
         if not parent_hrn or hrn == self.config.SFA_INTERFACE_HRN:
             # if there is no parent hrn, then it must be self-signed. this
             # is where we terminate the recursion
@@ -247,7 +253,6 @@ class Hierarchy:
             parent_auth_info = self.get_auth_info(parent_hrn)
             gid.set_issuer(parent_auth_info.get_pkey_object(), parent_auth_info.hrn)
             gid.set_parent(parent_auth_info.get_gid_object())
-            gid.set_intermediate_ca(True)
 
         gid.set_pubkey(pkey)
         gid.encode()