# *.DBINFO - database info
##
-### $Id$
-### $URL$
-
import os
-from sfa.util.sfalogging import sfa_logger
+from sfa.util.faults import *
+from sfa.util.sfalogging import logger
+from sfa.util.xrn import get_leaf, get_authority, hrn_to_urn, urn_to_hrn
from sfa.trust.certificate import Keypair
-from sfa.trust.credential import *
+from sfa.trust.credential import Credential
from sfa.trust.gid import GID, create_uuid
-from sfa.util.namespace import *
from sfa.util.config import Config
from sfa.util.sfaticket import SfaTicket
gid_filename = None
privkey_filename = None
dbinfo_filename = None
-
##
# Initialize and authority object.
#
def create_auth(self, xrn, create_parents=False):
hrn, type = urn_to_hrn(xrn)
- sfaImporter.logger.info("Hierarchy: creating authority: " + hrn)
+ logger.debug("Hierarchy: creating authority: %s"% hrn)
# create the parent authority if necessary
parent_hrn = get_authority(hrn)
pass
if os.path.exists(privkey_filename):
- sfa_logger.debug("using existing key %r for authority %r"%(privkey_filename,hrn))
+ logger.debug("using existing key %r for authority %r"%(privkey_filename,hrn))
pkey = Keypair(filename = privkey_filename)
else:
pkey = Keypair(create = True)
# @param xrn the human readable name of the authority to create (urn will be converted to hrn).
def get_auth_info(self, xrn):
-
- sfaImporter.logger.info("Hierarchy: getting authority: " + hrn)
hrn, type = urn_to_hrn(xrn)
if not self.auth_exists(hrn):
+ logger.warning("Hierarchy: mising authority - xrn=%s, hrn=%s"%(xrn,hrn))
raise MissingAuthority(hrn)
(directory, gid_filename, privkey_filename, dbinfo_filename) = \
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
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()